Skip to content

Conversation

@sunshowers
Copy link
Contributor

@sunshowers sunshowers commented Jun 21, 2025

Add a new TufRepoPolicy struct that currently consists of the target release generation plus the TufRepoDescription, and use it for both tuf_repo and old_repo.

We're going to need tuf_repo.generation for MUPdate override work (RFD 556). We don't anticipate needing old_repo.generation for now but logically it makes sense to have.

Depends on:

Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@sunshowers
Copy link
Contributor Author

old_repo stays the same because the generation is implicit there.

Actually, I don't think this is quite right in general, though it seems to be the logic for PlanningInputFromDb. Are we going to need the old repo's generation number, though? I'm not quite sure.

Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@sunshowers
Copy link
Contributor Author

Actually, I don't think this is quite right in general, though it seems to be the logic for PlanningInputFromDb. Are we going to need the old repo's generation number, though? I'm not quite sure.

Updated this PR to also include the generation number for the old repo. See #8056 (comment) for some more discussion.

Copy link
Contributor

@plotnick plotnick left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

// This generation is successively incremented for each TUF repo. We use
// generation 2 to represent the first generation with a TUF repo
// attached.
let target_release_generation = Generation::new().next();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just me, but I find Generation::from_u32(2) more explicit and therefore preferable for this kind of initialization. It keeps me from wondering (even though I know) whether the initial generation is 0 or 1 each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'm fine with either. Changed it to from_u32.

};

self.tuf_repo = new_repo;
// XXX: should this set old_repo to the current tuf_repo?
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any reason why not, and I can't think of any other places where we'd want to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly I'd say it's because old_repo is really the current release. This system doesn't enforce the invariant that setting a new target release is disallowed while an update is in progress (#8056 (comment)) so I think an unconditional self.old_repo = self.tuf_repo isn't quite what we want.

We may want to have a more explicit operation for this in the future, but it depends on how tests for this feature play out -- so I'd like to defer this until we get some more experience with that.

Comment on lines -171 to +181
.internal_context("fetching current target release")?
.internal_context("fetching previous target release")?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch, thanks!

@sunshowers sunshowers changed the base branch from sunshowers/spr/main.18n-add-target-release-generation-to-planning-input to main June 25, 2025 00:18
Created using spr 1.3.6-beta.1
@sunshowers sunshowers enabled auto-merge (squash) June 25, 2025 00:21
@sunshowers sunshowers merged commit 2f8d2cd into main Jun 25, 2025
16 checks passed
@sunshowers sunshowers deleted the sunshowers/spr/18n-add-target-release-generation-to-planning-input branch June 25, 2025 01:58
smklein added a commit that referenced this pull request Jun 27, 2025
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