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

tmpfiles: Support multiple generations #1151

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

cgwalters
Copy link
Collaborator

Way back in rpm-ostree's original code here, it always assumed that it owned The Build.

But in a container-native flow we may have a chain of builds across an organization and want to generate tmpfiles.d entries multiple times.

When we do this, we can't just blow away the existing /usr/lib/tmpfiles.d/bootc-generated.conf.

Teach the tmpfiles code to have "generations" - we pick a new file name like bootc-generated-0.conf, bootc-generated-1.conf etc.

Also, change the generation code to return a struct with more info about what it did, which will be used in the linting code.

Way back in rpm-ostree's original code here, it always assumed
that it owned The Build.

But in a container-native flow we may have a chain of builds
across an organization and want to generate tmpfiles.d entries
multiple times.

When we do this, we can't just blow away the existing `/usr/lib/tmpfiles.d/bootc-generated.conf`.

Teach the tmpfiles code to have "generations" - we pick a new
file name like `bootc-generated-0.conf`, `bootc-generated-1.conf`
etc.

Also, change the generation code to return a struct with more
info about what it did, which will be used in the linting code.

Signed-off-by: Colin Walters <[email protected]>
@cgwalters cgwalters enabled auto-merge February 27, 2025 17:59
@jeckersb jeckersb disabled auto-merge February 27, 2025 19:33
Copy link
Contributor

@jeckersb jeckersb left a comment

Choose a reason for hiding this comment

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

Turned off auto-merge and approving just to let you consider the nit, if you disagree just merge it as-is!

struct BootcTmpfilesGeneration(u32);

impl BootcTmpfilesGeneration {
fn increment(&self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pedantic nit (take it or leave it), this should probably either consume self then hand it back, or take &mut self and do the increment in-place, just to avoid having multiple copies of the generation and accidentally using the wrong one. It's fine right now since in usage you're always overwriting the old generation with the new instance but changing it would let the type system enforce that.

Worst case, derive clone and make it explicit that you intended to have two 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, will do in a followup

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

queued in 2f028eb

@cgwalters cgwalters merged commit d957678 into bootc-dev:main Feb 27, 2025
23 checks passed
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.

2 participants