fix: downgrade gate flags rc-to-release finalization as downgrade#160
Merged
Conversation
…sion The downgrade gate compared every promotion's target env against the source env's raw version (result.SourceVersion). In a cascade across the publish boundary the version that lands differs per env: prerelease envs receive the rc (v1.0.0-rc.0) while release and prod receive the stripped semver (v1.0.0). An rc sorts below its release under semver precedence, so finalizing v1.0.0-rc.0 onto a release env already holding v1.0.0 was wrongly flagged as a downgrade and blocked. Compare each env against promo.Version (the version that actually lands on that env), falling back to SourceVersion only for version-less promotions. Real downgrades stay blocked because a genuine downgrade carries the older version in promo.Version for every affected env. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Trunk e2e went red after the downgrade gate (#156) landed.
TestMultiStepScenarios/Four_Environment_Cascade_Promotionstep 18 ("Cascade promote release to prod with breaking flag", expected to SUCCEED) failed:Root cause: product false positive (not a scenario artifact)
The scenario uses
environments: [dev, qa, uat, prod]. Step 18 iscascade, target: prod; the harness defaults the cascade source to the first env, so it runsdev-to-prodfromdevholdingv1.0.0-rc.0. Across the publish boundary the cascade materializes a virtualreleasepromotion whoseVersionis the stripped semverv1.0.0(stripRCSuffix), and aprodpromotion also atv1.0.0. The release env already holds the previously publishedv1.0.0, so the version that actually LANDS is equal, not older.checkDowngradecompared every target env againstresult.SourceVersion(the single source env's raw version,v1.0.0-rc.0) instead of each promotion'sVersion(what lands on that env). An rc sorts below its release under semver precedence, so the rc-to-release finalization was wrongly flagged as a downgrade. This is the normal cascade flow, so the gate, not the scenario, is wrong.Fix
internal/promote/preflight.gocheckDowngrade: compare each env's current version againstpromo.Version(the version that lands on that env), falling back toresult.SourceVersiononly for version-less promotions.Real downgrades stay blocked: a genuine downgrade carries the older version in
promo.Versionfor every affected env (default-mode and the release-marker/publish paths all populate it).Verification
internal/promote/downgrade_test.go: publish-boundary rc-to-release is not a downgrade; a real downgrade viapromo.Versionstill blocks; rc progressing forward into a prerelease env passes. Existing downgrade tests stay green.go build ./... && go test ./...: 1289 passed.golangci-lint run ./...and e2ego vet/golangci-lint: clean.--- PASS: TestMultiStepScenarios/Four_Environment_Cascade_Promotion (83.23s)locally (Docker).