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

upgrader: Generate "computed" origin #2972

Merged
merged 2 commits into from
Jul 13, 2021
Merged

Conversation

cgwalters
Copy link
Member

This is is part of reducing internal complexity - in particular
our "representations of state". The code here is basically
printing a warning if a requested package is already in the base
tree, and avoid passing that package down to the core.
To accomplish this original code here was doing:

origin -> (computed state) -> treespec

Now that we dropped treespec in a recent PR, it's going:

origin -> (computed state) -> treefile

Instead of having anonymous (computed state) we can
just make that a new (filtered) origin file. IOW
we now do:

origin -> origin -> treefile

This is easier to understand and debug. Note
how duplication around checking "requires local
assembly" between the upgrader and origin code
just drops out!

@cgwalters cgwalters force-pushed the upgrader-origin branch 2 times, most recently from 941541b to cf5ae87 Compare July 9, 2021 14:16
@cgwalters
Copy link
Member Author

Pushed:

rust/origin: Don't mutate input origin, do translate override

Ahhhh that was so confusing and tricky to debug. But, hooray again for the test suite!

And here's where Rust's `&` vs `&mut` would have saved us
in Rust-native code.  Our translation code here was mutating
the input, which broke things when trying to use it in
the upgrader code.  But because dealing with `&/&mut` with
GLib would have been too hard, the GLib bindings accept `&`
but still support mutating the underlying object.

Further, we don't want to remove all the "transient" state
here anyways.  The history of ostree and origin files is tangled.
We just want to drop `libostree-transient` (ostree should
have an API for this).  Or stated positively, we do want
to translate the `override-commit`.
@lucab
Copy link
Contributor

lucab commented Jul 13, 2021

we can just make that a new (filtered) origin file. [...] This is easier to understand and debug.

Direction and code looks fine to me, however I disagree with this claim. This now has two members (origin and computed_origin) in the same scope with the same type and very subtle/minimal differences. They can be freely mixed up by human mistake, and compiler can't help catching that. Overall IMHO this increases cognitive load and adds more foggy corners to debugging.

In this context, I would naively have expected computed_origin to be the only thing laying around, with the pristine origin possibly reconstructed on the fly when eventually calling into libostree (or, if that's not possible, to have the keyfile further encapsulated within RpmOstreeOrigin).
Have you already considered and discarded that approach for some reason?

@@ -73,6 +73,7 @@ struct RpmOstreeSysrootUpgrader {
OstreeDeployment *cfg_merge_deployment;
OstreeDeployment *origin_merge_deployment;
RpmOstreeOrigin *origin;
RpmOstreeOrigin *computed_origin;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be happier if we can keep only a single RpmOstreeOrigin * in this scope (i.e. the computed one), see longer comment in the PR.

@cgwalters
Copy link
Member Author

This now has two members (origin and computed_origin) in the same scope with the same type and very subtle/minimal differences. They can be freely mixed up by human mistake, and compiler can't help catching that. Overall IMHO this increases cognitive load and adds more foggy corners to debugging.

We replaced 3 previous variables with one though. Hmm. I can rename the other one to original_origin or something too?

In this context, I would naively have expected computed_origin to be the only thing laying around,

I was alluding to the reason we can't do that in the commit message here:

The code here is basically printing a warning if a requested package is already in the base tree, and avoid passing that package down to the core.

The core problem is around the case where someone does e.g. rpm-ostree install --allow-inactive docker on FCOS. That command is saying "I want docker even though it's currently in the base. If at some point in the future it drops out of the base, start layering it".

What this logic in the upgrader is doing is emitting the warning around having the package in the base, and also drops out the request to install it (because at time t0 it is in the base). But that request needs to stay in the origin file so that we remember to start layering at time t1 later if needed.

@lucab
Copy link
Contributor

lucab commented Jul 13, 2021

Yes, I fully agree with the direction of this (both for the reduction of variables, and for the explicit computed state). The concern is mainly around having two subtly-diverging entities available in the same scope.
If there is no way around that then we can merge this and reap the benefits already. But from a "humans are fallible" point of view, the one above is IMHO a sharp edge and I wanted to check whether different arrangements are feasible.

This is is part of reducing internal complexity - in particular
our "representations of state".  The code here is basically
printing a warning if a requested package is already in the base
tree, and avoid passing that package down to the core.
To accomplish this original code here was doing:

origin -> (computed state) -> treespec

Now that we dropped treespec in a recent PR, it's going:

origin -> (computed state) -> treefile

Instead of having anonymous (computed state) we can
just make that a new (filtered) origin file.  IOW
we now do:

origin -> origin -> treefile

This is easier to understand and debug.  Note
how duplication around checking "requires local
assembly" between the upgrader and origin code
just drops out!
@cgwalters
Copy link
Member Author

I don't see a way to get down to just one thing while preserving the current semantics. But very clearly some comments here were warranted 😄 I added a big one at the top, and also renamed the first variable to original_origin.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

LGTM! Approach makes a lot of sense to me. The ability to use e.g. rpmostree_origin_has_packages on the computed origin is nice.

@jlebon jlebon enabled auto-merge July 13, 2021 19:36
@jlebon jlebon merged commit 76453ea into coreos:main Jul 13, 2021
jlebon added a commit to jlebon/rpm-ostree that referenced this pull request Jul 26, 2021
This stopped being used after coreos#2972.
cgwalters pushed a commit that referenced this pull request Jul 27, 2021
This stopped being used after #2972.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants