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

Implement ex livefs --replace #1028

Closed
wants to merge 5 commits into from
Closed

Conversation

cgwalters
Copy link
Member

Lots of tradeoffs in this. See the comments in the code for
more info. WIP for now.

@cgwalters cgwalters added the WIP label Oct 2, 2017
@dustymabe
Copy link
Member

what does livefs --replace give us? wholesale replace of /usr/ ?

@cgwalters
Copy link
Member Author

what does livefs --replace give us? wholesale replace of /usr/ ?

Yep.

@cgwalters
Copy link
Member Author

Related: GNOME/libglnx#89

@dustymabe
Copy link
Member

Yep.

just wondering.. what problem does that solve? just wondering why users might be interested in such a feature

@cgwalters
Copy link
Member Author

Some of the use cases here go into what's currently covered by ostree admin unlock. The problem with admin unlock is rpm-ostree has no idea what's going on anymore (and the changes don't persist).
Let's say I want to test an ex override replace docker live; going down this path leaves /usr still appearing to be read-only, rpm-ostree is still in full control, and it is persistent.

Another case is doing quick testing of e.g. a FAH release update live. Yes, you don't get the new kernel, but OTOH you can do some things quickly. If things go wrong, you have the rollback.

In general, supporting this goes much farther down the path of having an option to do live updates where possible.

@jlebon
Copy link
Member

jlebon commented Oct 2, 2017

Let's say I want to test an ex override replace docker live; going down this path leaves /usr still appearing to be read-only, rpm-ostree is still in full control, and it is persistent.

Hmm, TBH I'm still leaning towards either (1) not including the livefs deployment in the boot entries and/or (2) make the livefs deployment as "ephemeral" as possible. (Those were discussed in #639). Why do we want the changes to be persistent? The usefulness of livefs is that you essentially delay a reboot, but if you're rebooting anyway, we want to encourage users to go to either the pending deployment or the rollback, right? Esp. that we have override replace now, you should be able to move forward while avoiding a buggy package if needed.

Anyway, the above isn't directly related to this PR, which looks sane at a quick glance (though maybe we should rename the switch to --hold-my-beer-and-replace-usr).

@cgwalters
Copy link
Member Author

I completely agree that it's broken to boot into something that says it was live-modified. The whole livefs thing is clearly going to go through a lot of changes before we lift the ex flag. It's not clear to me that it even makes sense as a separate command so much as a "mode".

Anyways back to this PR; if I'm doing override replace, I think in a lot of cases I want that to be persistent (assuming it works!) I may also want it to be live to test it (which becomes a bit circular ∞, yes).

Lots of tradeoffs in this.  See the comments in the code for
more info.  WIP for now.
@cgwalters cgwalters changed the title WIP: Implement ex livefs --replace Implement ex livefs --replace Oct 3, 2017
@cgwalters cgwalters removed the WIP label Oct 3, 2017
@cgwalters
Copy link
Member Author

OK, I added a basic sanity test. Lifting WIP, though this could still use more tests.

@cgwalters
Copy link
Member Author

Rawr.

  • vm_cmd test -f /usr/share/licenses/ostree/COPYING

C7 doesn't have the license bits standardized. Will hack around this.

@cgwalters
Copy link
Member Author

Fixed up.

break;
const char *name = dent->d_name;
/* Keep track of what entries are in the new /usr */
g_hash_table_add (seen_new_children, g_strdup (name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're leaking this, right? Hash table should probably be g_hash_table_new_full (..., ..., g_free, NULL)

* all of it. We could do a diff, but doing that precisely and quickly depends
* on https://github.com/ostreedev/ostree/issues/1224
*
* In this approach, we iterate over and exchange subdirectories. Some issues
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not recursing, let's clarify that it's only first-level subdirectories of /usr.

@@ -522,6 +522,106 @@ replace_subpath (OstreeRepo *repo,
return TRUE;
}

/* The sledgehammer 🔨 approach. Because /usr is a mount point, we can't replace
* all of it. We could do a diff, but doing that precisely and quickly depends
* on https://github.com/ostreedev/ostree/issues/1224
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's true, we are talking about a lot of fdopendir/readdir/stat calls, though I do still wonder how bad it would be.

Actually, that reminds me of cgwalters#2, in which I measured adding a stat penalty on a real compose to be around ~60 ms. Of course, it'd be much larger, but even so, even if it's say, 1 second, it seems like an OK tradeoff considering the added safety? E.g. I would be very hesitant to ever use this feature on my Atomic Workstation; feels a bit too violent. ⚡️ 🔥 💻 😱

assert_file_has_content livefs-analysis.txt 'livefs OK (dry run)'
vm_assert_status_jq '.deployments|length == 2' '.deployments[0]["live-replaced"]|not' \
'.deployments[1]["live-replaced"]|not'
vm_rpmostree ex livefs --replace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add another vm_assert_status_jq here to confirm it's what we expect?

(cat vmcheck/usr/bin/ls; echo more stuff) > vmcheck/usr/bin/ls.new
chmod a+x vmcheck/usr/bin/ls.new
mv vmcheck/usr/bin/ls{.new,}
(date; echo "JUST KIDDING DO WHATEVER") >vmcheck/${dummy_file_to_modify}.new && mv vmcheck/${dummy_file_to_modify}{.new,}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a corner-case, maybe also mkdir vmcheck/usr/newdir and check that it was created later on down there?

@jlebon
Copy link
Member

jlebon commented Oct 5, 2017

Hmm, weird. Not sure what's going on with the CentOS one. Let's give it a try.
@rh-atomic-bot r+ 8e941dd

@rh-atomic-bot
Copy link

⌛ Testing commit 8e941dd with merge 95227f0...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing 95227f0 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants