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
bridge: Migrate /var/lib/cockpit/machines.json to /etc #5963
Conversation
09118ff
to
cb5e93f
Compare
What is the goal of migrating? If the goal is documentation and discoverability, would just trying to create a symlink to |
The goal is to have all the actual config files in the documented place, |
I think we can combine the ideas to simplify this:
My gut feeling is that 2. is the right approach, this is what I was heading towards in this PR. @stefwalter , opinions? |
Actually, I think it's better to move the file rather than symlinking:
|
cb5e93f
to
aad9a3e
Compare
Reworked like discussed above; this is simpler and more robust. |
I added another commit on top to fix the unit tests when /var/lib/cockpit/machines.json exists (what @stefwalter pointed out yesterday). |
@larskarlitski found out in the meeting that current master's dashboard doesn't work with the latest released bridge (error message about missing |
992f53d
to
305781f
Compare
src/bridge/cockpitdbusmachines.c
Outdated
} | ||
else /* different g_file_move() error than EXISTS */ | ||
{ | ||
g_warning ("migration of %s to %s failed: %s", var_path, etc_path, error->message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fail to EPERM or EACCESS? If so then this is not a g_warning() ... in fact we should probably just ignore that failure quietly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, the caller only checks if we can access the destination, and no check whether we can remove stuff from the source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point we already asserted g_access (machines_json_dir (), W_OK)
(from the call below), so this could happen if /var/lib/cockpit/
isn't writable. So this really is a Should Not Happen™ situation, and if someone gets here they wedged up their system. So IMHO g_warning()
is not too strong at all.
tools/min-base-version
Outdated
@@ -28,14 +28,14 @@ from glob import glob | |||
proj_dir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) | |||
|
|||
max_version = '0' | |||
for manifest in glob(os.path.join(proj_dir, 'pkg/*/manifest.json')): | |||
for manifest in glob(os.path.join(proj_dir, 'pkg/*/manifest.json.in')): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a follow up but we cannot conflate all the "requires" here. Certain distros don't ship all the packages at the same time. We need to start doing these individually or manually curating these. Such a change could be a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, let's handle that in a separate PR. Right now the dependency calculation is completely broken, so one way or another we need to fix this for 133.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tought about this in issue #5997, and I think I have a reasonably good solution for this (at least much better than what we have now). So I think this particular hunk could stay, but I'm happy to revert the bumping of the dependency in pkg/dashboard/manifest.json.in
(i. e. remove the topmost commit here) in this PR, as it will not actually influence the dependency of -dashboard
(that doesn't use the manifest dependencies, it's just hardcoded at "same version as -ws") and unecessarily bump the dependency of all "plugin" packages.
This should alleviate the dependency concerns but still keep the unbreaking of min-base-version.
305781f
to
621f378
Compare
Re-pushed with dropping the depenency bump and |
621f378
to
349f55d
Compare
349f55d
to
0935dc3
Compare
Otherwise an existing /var/lib/cockpit/machines.json would fail the tests.
We moved machines.json into /etc and a directory because we want it to be a public API. Don't document the "avatar" property for now, as it does not really work right now.
0935dc3
to
f545f8b
Compare
Rebased to adjust to changes from #5990 (dropping |
Priority, this should be included in 133, otherwise the migration will be more complicated/less clean. |
f545f8b
to
986eb08
Compare
986eb08
to
7f891d9
Compare
On startup, migrate the old machines.json file in /var to the new canonical location /etc/cockpit/machines.d/99-webui.json, so that the entire configuration is in the one documented place. If that already exists (unlikely, but maybe a previous migration attempt failed and then the user manually added a new machine), move it to 98-migrated.json instead. We still keep reading the file in /var for some time, to ensure the migration has run for everyone. Closes cockpit-project#5963
Adjusted once again, older glib versions (debian-8/centos-7) have a different error message, which caused a mismatch in the expected journal messages. I made this more general now. |
On startup, migrate the old machines.json file in /var to the new canonical location /etc/cockpit/machines.d/99-webui.json, so that the entire configuration is in the one documented place. Much of the code tries to handle the (rather unlikely) case that both the old /var/lib/cockpit/machines.json and the new /etc/cockpit/machines.d/99-webui.json already exist; this could happen when upgrading to the new version, the initial migration fails due to some weird permissions error (directory not writable by root), and then the user adds some new hosts. This can never be made fully robust by nature, but the code tries to cope as well as possible. Maybe this is also overengineered and we should simply not support that case, not sure.
We still need to keep reading the file in /var for some time as there is no guarantee that the migration actually works.
The second commit documents the file format. You can see what the generated result looks like at http://piware.de/tmp/feature-machines.html, except that there is a light blue box missing around the example (I didn't want to spend too much time figuring out which CSS to put where).