-
Notifications
You must be signed in to change notification settings - Fork 488
deploy-from-self if skopeo < 1.22.2 #5863
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -2758,8 +2758,10 @@ func (dn *Daemon) updateLayeredOS(config *mcfgv1.MachineConfig) error { | |
| // If the host isn't new enough to understand the new container model natively, run as a privileged container. | ||
| // See https://github.com/coreos/rpm-ostree/pull/3961 and https://issues.redhat.com/browse/MCO-356 | ||
| // This currently will incur a double reboot; see https://github.com/coreos/rpm-ostree/issues/4018 | ||
| if !newEnough { | ||
| logSystem("rpm-ostree is not new enough for layering; forcing an update via container") | ||
| // If Skopeo used by rpm-ostree is an older version supporting multi-arch Sigstore verificaiton, run as a privileged container which has updated skopeo. | ||
| // See https://redhat.atlassian.net/browse/OCPBUGS-83826 and https://redhat.atlassian.net/browse/OCPBUGS-81187 | ||
| if !newEnough || !skopeoSupportsMultiArchSigstore() { | ||
| logSystem("rpm-ostree or skopeo is not new enough for layering; forcing an update via container") | ||
| return dn.InplaceUpdateViaNewContainer(newURL) | ||
| } | ||
|
|
||
|
|
@@ -2938,6 +2940,46 @@ func podmanSupportsSigstore() bool { | |
| return podmanSigstoreSupportedValue | ||
| } | ||
|
|
||
| var ( | ||
| skopeoMultiArchSigstoreSupported sync.Once | ||
| skopeoMultiArchSigstoreSupportedValue bool | ||
| ) | ||
|
|
||
| func skopeoSupportsMultiArchSigstore() bool { | ||
| skopeoMultiArchSigstoreSupported.Do(func() { | ||
| // https://issues.redhat.com/browse/OCPBUGS-81187 | ||
| // Multi-arch Sigstore fixed in skopeo 1.22.2 | ||
| cmd := exec.Command("skopeo", "--version") | ||
| out, err := cmd.CombinedOutput() | ||
| if err != nil { | ||
| klog.Errorf("failed to run skopeo --version: %v", err) | ||
| skopeoMultiArchSigstoreSupportedValue = false | ||
| return | ||
| } | ||
| // Output format: "skopeo version 1.21.0-dev commit: d8be59c1ecc5c1860b7bab4f60721d55da2cda9a" | ||
| fields := strings.Fields(strings.TrimSpace(string(out))) | ||
| if len(fields) < 3 { | ||
| klog.Errorf("unexpected skopeo version output format: %s", string(out)) | ||
| skopeoMultiArchSigstoreSupportedValue = false | ||
| return | ||
| } | ||
|
|
||
| versionStr := fields[2] | ||
| if dashIdx := strings.Index(versionStr, "-"); dashIdx != -1 { | ||
| versionStr = versionStr[:dashIdx] | ||
| } | ||
| skopeoVersion, err := semver.NewVersion(versionStr) | ||
| if err != nil { | ||
| klog.Errorf("failed to parse skopeo version %s: %v", versionStr, err) | ||
| skopeoMultiArchSigstoreSupportedValue = false | ||
| return | ||
| } | ||
| minSkopeoVersionForMultiArchSigstore := "1.22.2" | ||
| skopeoMultiArchSigstoreSupportedValue = skopeoVersion.Compare(*semver.New(minSkopeoVersionForMultiArchSigstore)) >= 0 | ||
| }) | ||
| return skopeoMultiArchSigstoreSupportedValue | ||
| } | ||
|
Comment on lines
+2948
to
+2981
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. Avoid fail-open downgrade when the skopeo probe fails. At Line 2958, Line 2967, and Line 2978, probe/parsing errors force 🔧 Suggested direction-var (
- skopeoMultiArchSigstoreSupported sync.Once
- skopeoMultiArchSigstoreSupportedValue bool
-)
+var (
+ skopeoMultiArchSigstoreSupported sync.Once
+ skopeoMultiArchSigstoreSupportedValue bool
+ skopeoMultiArchSigstoreProbeErr error
+)
-func skopeoSupportsMultiArchSigstore() bool {
+func skopeoSupportsMultiArchSigstore() (bool, error) {
skopeoMultiArchSigstoreSupported.Do(func() {
cmd := exec.Command("skopeo", "--version")
out, err := cmd.CombinedOutput()
if err != nil {
- klog.Errorf("failed to run skopeo --version: %v", err)
- skopeoMultiArchSigstoreSupportedValue = false
+ skopeoMultiArchSigstoreProbeErr = fmt.Errorf("failed to run skopeo --version: %w", err)
return
}
...
if err != nil {
- klog.Errorf("failed to parse skopeo version %s: %v", versionStr, err)
- skopeoMultiArchSigstoreSupportedValue = false
+ skopeoMultiArchSigstoreProbeErr = fmt.Errorf("failed to parse skopeo version %s: %w", versionStr, err)
return
}
skopeoMultiArchSigstoreSupportedValue = skopeoVersion.Compare(*semver.New(minSkopeoVersionForMultiArchSigstore)) >= 0
})
- return skopeoMultiArchSigstoreSupportedValue
+ return skopeoMultiArchSigstoreSupportedValue, skopeoMultiArchSigstoreProbeErr
}Then gate permissive fallback only when probe succeeded and version is truly below minimum. 🤖 Prompt for AI Agents |
||
|
|
||
| // Log a message to the systemd journal as well as our stdout | ||
| func logSystem(format string, a ...interface{}) { | ||
| message := fmt.Sprintf(format, a...) | ||
|
|
||
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.
Fix fallback comment wording (reversed meaning + typo).
The comment currently says older skopeo versions are “supporting” multi-arch Sigstore verification and has a typo (“verificaiton”). It should say older versions do not support it.
✏️ Proposed comment fix
📝 Committable suggestion
🤖 Prompt for AI Agents