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

Don't allow downgrading the system target release #7807

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

plotnick
Copy link
Contributor

Attempting to set the target system release to an earlier version should fail. That constraint is now enforced and tested.

Attempting to set the target system release to an earlier version
should fail. That constraint is now enforced and tested.
@@ -6442,14 +6442,30 @@ impl NexusExternalApi for NexusExternalApiImpl {
crate::context::op_context_for_external_api(&rqctx).await?;
let params = body.into_inner();
let system_version = params.system_version;

let current_target_release =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool. I like the test, too.

I wonder if this condition needs to be checked transactionally with the update, though? I'm thinking of the time-of-check-to-time-of-use race where say the system is at version 14, the user is trying to update to 15, but someone else comes in and sets it to 16 in the meantime, then we overwrite that with 15. But maybe this is prevented because at L6469 below, we construct the next target release with a generation number of 1 + whatever we just saw (that was version 14), so we'll necessarily fail the database update if someone else comes in in between? If that's the case, could we add a comment here explaining why this race isn't a problem?

Copy link
Contributor Author

@plotnick plotnick Mar 22, 2025

Choose a reason for hiding this comment

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

That is indeed the case; documented in c2233b9.

if version > system_version {
return Err(HttpError::for_bad_request(
None,
"can't downgrade system".into(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"can't downgrade system".into(),
"The requested target system release ({system_version}) is older than the current target system release ({version}). This is not supported.".into()

I'm imagining an end user might see this message and want to make sure it's clear what's going on and what they've done wrong.

Copy link
Contributor Author

@plotnick plotnick Mar 22, 2025

Choose a reason for hiding this comment

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

Indeed, thanks! Also added in c2233b9.

@@ -0,0 +1,87 @@
# This is an artifact manifest that generates fake entries for all components.
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about calling this fake-old.toml and adding a comment here that the only difference from fake.toml is the version numbers of everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#7832 added a (non-semver-containing) 2.0.0 and made the test use that, so e019fda just tries to revert back to 1.0.0 and removes this file entirely.

@plotnick plotnick force-pushed the no-downgrades branch 2 times, most recently from 0a76d62 to e019fda Compare March 23, 2025 15:38
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