-
Notifications
You must be signed in to change notification settings - Fork 246
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
Add filesystem cleanExcept directive to preserve wanted files #1316
Conversation
The wipeFilesystem directive causes all state to be lost. A more fine-grained mechanism is needed to clean a filesystem from previous unwanted state while allowing for some files or directories to be kept. Add a new cleanExcept directive that when specified will remove all directories and files on the filesystem except those that match a list of regular expressions.
fa72e70
to
4a3227b
Compare
Ok, didn't get yet how to do the translation (
|
Thanks for the PR! Note that the the I'd like to know more about the use case:
The second one is the use case I was imagining. Could you expand on the first one? It sounds as though you're trying to rerun Ignition to modify an existing OS installation, which is explicitly not supported. |
The files stage is also good, I just had placed it close to wipeFilesystem which is the only similar option available now, and initially I wanted it to work per filesystem. When moving it to the files stage it would clean all filesystems but that's ok if it's documented. On the use case, yes, this is about rerunning Ignition - currently this is possible with wipeFilesystem but it still discards too much local data, thus the idea here of preserving selectively. |
I see a few related issues here:
|
Thanks for the link to the OS reset discussions. I think it makes sense to have that it Ignition because it is close to the configuration the user specifies. Whether preserving something is valid or not is tied to the application. Yes, you are right, it's even more tied to the OS and it seems strange to give this into the hand of the user, but in Flatcar's case we can wipe everything on the rootfs and the user would only state paths to preserve that the user cares about. Having this as part of the OS reset is also ok, maybe we could clean the rootfs in the systemd shutdown hook shortly before the reboot instead of continuing with this PR, it just gets "farer" away from the single config file Ignition would give me to express all this. |
Point 1 doesn't require not reconfiguring nodes while they're running, it requires not reconfiguring them at all. If you want to rerun Ignition, the only safe way is to reset the node to factory state first. Otherwise, if the user's config fails to properly perform the reset, the node will still boot successfully, but with a mix of old and new customizations. (And if the machine ID isn't cleared, any new systemd services won't be enabled correctly.) This violates the principle that Ignition should fail if it can't deliver what was requested. Even if we accepted that possibility for Flatcar, we'd still be adding a special feature for factory reset which doesn't help OSes with more complicated reset procedures. I agree that it's unfortunate to require the user to specify preserved directories in a separate command, outside the Ignition config. One option is for Flatcar to define a config file, say (Or the tool could parse the config file out of the new Ignition config, but that's ugly.) By the way, unless Flatcar fixed this, wiping |
The idea was that cleanExcept deletes everything except the paths given there to avoid ending up with mix of old and new customizations. The requirement is that the path does not include old configurations. In this regard your idea to couple it to the old config instead of the new config makes sense. I will close this and rather move the cleaning step to a new factory reset action. In the end for Flatcar it's the same thing, just done before the reboot instead of by Ignition. The factory reset action could also ensure that the user doesn't try to preserve |
Sounds good. Thanks for the discussion! |
The wipeFilesystem directive causes all state to be lost. A more
fine-grained mechanism is needed to clean a filesystem from previous
unwanted state while allowing for some files or directories to be kept.
Add a new cleanExcept directive that when specified will remove all
directories and files on the filesystem except those that match a list
of regular expressions.
(Didn't look into tests yet)
Please give any feedback, I find this valuable for handling configuration changes without config drift but it could also be used for reusing data disks as alternative to wiping them.