Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stay beneath data dir / run dir when cleaning up paths during reset #5187

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Nov 7, 2024

Description

The current way of cleaning up the data directory is too simple to ensure that the recursive directory removal won't remove data that's not beneath it.

Re-implement the recursive directory traversal in a way that won't cross mount points unintentionally, but unmounts everything recursively instead.

Add a script to the reset integration test that tries to clutter the data directory by placing files and directories with odd permissions, adding symlinks to stuff outside the data directory, and adding bind mounts in various ways. This is to prove that k0's reset will never delete anything that is not beneath the data directory.

Fixes #4318.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@twz123 twz123 added the bug Something isn't working label Nov 7, 2024
@twz123 twz123 requested a review from ncopa November 7, 2024 13:43
The DirFD newtype around os.File provides methods for opening, statting
and listing files or directories relative to a dirfd file descriptor.
Provides robust handling of directory relative operations, maintaining
directory access consistency across rename/move operations.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 force-pushed the reset-cleanup-beneath-directory branch 2 times, most recently from d1a4c89 to ec2fd13 Compare November 7, 2024 16:38
The current way of cleaning up the data directory is too simple to ensure
that the recursive directory removal won't remove data that's not beneath
it.

Re-implement the recursive directory traversal in a way that won't
cross mount points unintentionally, but unmounts everything recursively
instead.

Signed-off-by: Tom Wieczorek <[email protected]>
Add a script to the reset integration test that tries to clutter the
data directory by placing files and directories with odd permissions,
adding symlinks to stuff outside the data directory, and adding bind
mounts in various ways.

This is to prove that k0's reset will never delete anything that is not
beneath the data directory.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 force-pushed the reset-cleanup-beneath-directory branch from ec2fd13 to ee8b1a0 Compare November 7, 2024 16:52
@twz123 twz123 marked this pull request as ready for review November 8, 2024 07:02
@twz123 twz123 requested review from a team as code owners November 8, 2024 07:02
@twz123 twz123 requested a review from jnummelin November 8, 2024 07:02
@ncopa
Copy link
Collaborator

ncopa commented Nov 8, 2024

I have a simpler alternative #5193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k0s reset deleted all data on persistent volumes
2 participants