Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/release-controller-api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,14 @@ func (c *Controller) apiReleaseInfo(w http.ResponseWriter, req *http.Request) {
})
}

wg.Go(func() {
wg.Add(1)
go func() {
defer wg.Done()
// Skip node image info for 4.18 and earlier: rpmdb collection requires
// pulling the entire rhel-coreos image for those releases.
if !releasecontroller.ReleaseTagHasCheapRpmdb(tagInfo.Tag) {
return
}
streams, err := c.releaseInfo.ListMachineOSStreams(tagInfo.TagPullSpec)
if err != nil {
nodeImageErr = newHTTPError(http.StatusInternalServerError, "listing machine-OS streams for %s: %w", tagInfo.Tag, err)
Expand Down Expand Up @@ -771,7 +778,7 @@ func (c *Controller) apiReleaseInfo(w http.ResponseWriter, req *http.Request) {
result = append(result, e.APINodeImageStream)
}
nodeImageStreams = result
})
}()

wg.Wait()

Expand Down
13 changes: 13 additions & 0 deletions cmd/release-controller-api/http_changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func (c *Controller) getChangeLog(ctx context.Context, ch chan renderResult, chN
return
}

// Skip node image info for 4.18 and earlier: rpmdb collection requires
// pulling the entire rhel-coreos image for those releases.
if !releasecontroller.ReleaseTagHasCheapRpmdb(toTag) {
chNodeInfo <- renderResult{}
return
}

toImagePullspec := toImage.GenerateDigestPullSpec()
fromImagePullspec := fromImage.GenerateDigestPullSpec()

Expand Down Expand Up @@ -200,6 +207,12 @@ func (c *Controller) renderChangeLog(w http.ResponseWriter, fromPull string, fro
return
}

// Skip node image info for 4.18 and earlier: rpmdb collection requires
// pulling the entire rhel-coreos image for those releases.
if !releasecontroller.ReleaseTagHasCheapRpmdb(toTag) {
return
}

fmt.Fprintf(w, "<h2 id=\"node-image-info\">Node Image Info</h2>")
fmt.Fprintf(w, `<p id="node_loading" class="alert alert-info">Loading node image info, this may take a while ...</p>`)
flusher.Flush()
Expand Down
14 changes: 14 additions & 0 deletions pkg/release-controller/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,17 @@ func ReleaseTagIsDualRHCOS(toTag string) bool {
}
return v.Major == 4 && v.Minor >= 21
}

// ReleaseTagHasCheapRpmdb reports whether the target release tag supports
// rpmdb collection without pulling the entire rhel-coreos image.
// Releases 4.19 and later store the rpmdb separately; 4.18 and earlier
// require pulling the full image, so Node Info is omitted for those releases.
// If the tag cannot be parsed as a semver version, it is assumed to support
// cheap rpmdb (i.e., nightly or CI tags are not gated).
func ReleaseTagHasCheapRpmdb(toTag string) bool {
v, err := SemverParseTolerant(toTag)
if err != nil {
return true
}
return !(v.Major == 4 && v.Minor <= 18)
Comment on lines +184 to +189

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does github.com/blang/semver/v4 ParseTolerant accept prerelease tags like 4.18.0-0.nightly-2024-01-01-000000and4.18.0-0.ci-2024-01-01-000000 as valid semantic versions?

💡 Result:

Yes, github.com/blang/semver/v4's ParseTolerant function accepts version strings like 4.18.0-0.nightly-2024-01-01-000000 and 4.18.0-0.ci-2024-01-01-000000 as valid semantic versions [1][2]. ParseTolerant is designed to parse version strings that do not strictly adhere to the Semantic Versioning 2.0.0 specification by normalizing them—such as removing a "v" prefix or adding missing patch numbers—before passing them to the standard Parse function [2][3][4]. Because your example strings already contain valid major, minor, and patch components (4.18.0) followed by valid prerelease tags, they are compatible with the library's parsing logic [3][4]. While an issue in 2019 (Issue #55) identified a regression where certain versions with prerelease tags were incorrectly rejected due to logic related to leading-zero removal, this was addressed in a subsequent pull request (PR #56) that was merged into the master branch [5][6]. Consequently, modern versions of the library correctly handle these formats [7][6].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the helper and nearby context
sed -n '140,220p' pkg/release-controller/semver.go

# Find its call sites
rg -n "ReleaseTagHasCheapRpmdb|apiReleaseInfo|renderChangeLog" pkg/release-controller -A3 -B3

Repository: openshift/release-controller

Length of output: 2865


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "ReleaseTagHasCheapRpmdb\(" -S .
rg -n "Node Info|rpmdb|apiReleaseInfo|renderChangeLog" pkg/release-controller -A6 -B6

Repository: openshift/release-controller

Length of output: 17493


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '80,130p' cmd/release-controller-api/http_changelog.go
sed -n '190,240p' cmd/release-controller-api/http_changelog.go
sed -n '680,745p' cmd/release-controller-api/http.go

Repository: openshift/release-controller

Length of output: 5452


Nightly/CI prerelease tags are still gated4.18.0-0.nightly-* and 4.18.0-0.ci-* parse as semver, so ReleaseTagHasCheapRpmdb() returns false for them and the node-image-info path stays disabled in both changelog/API callers. If nightly/CI releases should remain exempt, detect those tag classes before the semver minor check.

🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 189-189: QF1001: could apply De Morgan's law

(staticcheck)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/release-controller/semver.go` around lines 184 - 189,
ReleaseTagHasCheapRpmdb currently treats prerelease tags like 4.18.0-0.nightly-*
and 4.18.0-0.ci-* as regular semver, so they still get gated by the Major/Minor
check. Update ReleaseTagHasCheapRpmdb in semver.go to recognize nightly/CI
release tag classes before evaluating the semver minor rule, and keep those tags
exempt so the node-image-info path remains enabled for them.

}