Repository navigation
fix(release): render stack inventories that pin a chart released after the cut #2974
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
Changes from all commits
a279943
c61f902
65a5d4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -858,7 +858,12 @@ func materializeResolvedInventorySourceCharts( | |
| return nil, fmt.Errorf("source chart %s: %w", name, err) | ||
| } | ||
| if !inSource { | ||
| return nil, fmt.Errorf("source chart %s tag %s is not an ancestor of stack commit %s%s", name, tag, stackSource.Commit, lineage.describeOrigins()) | ||
| branch, branches := chartReleaseBranchContaining(repoRoot, tag, sourceChart.TagPrefix, release.Version) | ||
| if branch == "" { | ||
| return nil, fmt.Errorf("source chart %s tag %s is not an ancestor of stack commit %s%s, nor of chart release branch %s", | ||
| name, tag, stackSource.Commit, lineage.describeOrigins(), strings.Join(branches, " or ")) | ||
| } | ||
| fmt.Fprintf(os.Stderr, "source chart %s tag %s is outside stack commit %s; using the release from %s\n", name, tag, stackSource.Commit, branch) | ||
|
Comment on lines
+861
to
+866
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| chartPath := filepath.Join(chartRoot, name, release.Version) | ||
| if err := extractResolvedInventoryGitChart(repoRoot, tag, sourceChart.Path, chartPath); err != nil { | ||
|
|
@@ -982,6 +987,33 @@ func releaseSnapshotOrigins(repoRoot, stackCommit string) ([]string, error) { | |
| return origins, nil | ||
| } | ||
|
|
||
| const ( | ||
| // chartReleaseRemote holds a remote-tracking ref for every branch in the | ||
| // release workflow's full-history checkout. | ||
| chartReleaseRemote = "origin" | ||
| chartReleaseDefaultBranch = "main" | ||
| ) | ||
|
|
||
| // chartReleaseBranchContaining returns the reviewed branch a chart tag was | ||
| // released from, or "" with the branches it checked. A chart releases from | ||
| // the default branch or from its maintenance branch for the tag's minor, | ||
| // release-<tagPrefix>X.Y. A stack patch can pin such a release after its | ||
| // train was cut, when the tag is not in the stack's history. | ||
| func chartReleaseBranchContaining(repoRoot, tag, tagPrefix, version string) (string, []string) { | ||
| major, rest, _ := strings.Cut(version, ".") | ||
| minor, _, _ := strings.Cut(rest, ".") | ||
| branches := []string{ | ||
| chartReleaseRemote + "/" + chartReleaseDefaultBranch, | ||
| chartReleaseRemote + "/release-" + tagPrefix + major + "." + minor, | ||
| } | ||
| for _, branch := range branches { | ||
| if _, err := gitOutput(repoRoot, "merge-base", "--is-ancestor", tag, "refs/remotes/"+branch); err == nil { | ||
| return branch, nil | ||
| } | ||
| } | ||
| return "", branches | ||
| } | ||
|
|
||
| func extractResolvedInventoryGitChart(repoRoot, tag, sourcePath, destination string) error { | ||
| raw, err := gitOutput(repoRoot, "archive", "--format=tar", tag, "--", sourcePath) | ||
| if err != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State the tooling prerequisite for existing train branches.
If a train branch predates this change, its tag workflow runs the old
docs-version-syncfrom the stack tag. That validator still rejects a post-cut chart tag. Tell maintainers to backport this tooling to the train branch before merging the pin update. (raw.githubusercontent.com)