diff --git a/pkg/cincinnati/cincinnati.go b/pkg/cincinnati/cincinnati.go index 0e735f78e..e704284fe 100644 --- a/pkg/cincinnati/cincinnati.go +++ b/pkg/cincinnati/cincinnati.go @@ -219,6 +219,7 @@ func (c Client) GetUpdates(ctx context.Context, uri *url.URL, arch string, chann if len(conditionalUpdates[i].Risks[j].MatchingRules) == 0 { klog.Warningf("Conditional update to %s, risk %q, has empty pruned matchingRules; dropping this target to avoid rejections when pushing to the Kubernetes API server. Pruning results: %s", conditionalUpdates[i].Release.Version, risk.Name, err) conditionalUpdates = append(conditionalUpdates[:i], conditionalUpdates[i+1:]...) + break } else if err != nil { klog.Warningf("Conditional update to %s, risk %q, has pruned matchingRules (although other valid, recognized matchingRules were given, and are sufficient to keep the conditional update): %s", conditionalUpdates[i].Release.Version, risk.Name, err) } diff --git a/pkg/cincinnati/cincinnati_test.go b/pkg/cincinnati/cincinnati_test.go index c46b31bd9..28b8193cc 100644 --- a/pkg/cincinnati/cincinnati_test.go +++ b/pkg/cincinnati/cincinnati_test.go @@ -488,6 +488,63 @@ func TestGetUpdates(t *testing.T) { ] } ] +}`, + expectedQuery: "arch=test-arch&channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.1.0", + current: configv1.Release{ + Version: "4.1.0", + Image: "quay.io/openshift-release-dev/ocp-release:4.1.0", + URL: "https://example.com/errata/4.1.0", + Channels: []string{"channel-a", "test-channel"}, + }, + }, { + name: "condition with risks after invalid risk", + version: "4.1.0", + graph: `{ + "nodes": [ + { + "version": "4.1.0", + "payload": "quay.io/openshift-release-dev/ocp-release:4.1.0", + "metadata": { + "url": "https://example.com/errata/4.1.0", + "io.openshift.upgrades.graph.release.channels": "test-channel,channel-a" + } + }, + { + "version": "4.1.1", + "payload": "quay.io/openshift-release-dev/ocp-release:4.1.1", + "metadata": { + "url": "https://example.com/errata/4.1.1", + "io.openshift.upgrades.graph.release.channels": "test-channel" + } + } + ], + "conditionalEdges": [ + { + "edges": [{"from": "4.1.0", "to": "4.1.1"}], + "risks": [ + { + "url": "https://example.com/bug/123", + "name": "BugA", + "message": "This risk has no recognized rules, and so the conditional update to 4.1.1 will be dropped to avoid rejections when pushing to the Kubernetes API server.", + "matchingRules": [ + { + "type": "does-not-exist" + } + ] + }, + { + "url": "https://example.com/bug/456", + "name": "BugB", + "message": "All 4.1.0 clusters are incompatible with 4.1.1.", + "matchingRules": [ + { + "type": "Always" + } + ] + } + ] + } + ] }`, expectedQuery: "arch=test-arch&channel=test-channel&id=01234567-0123-0123-0123-0123456789ab&version=4.1.0", current: configv1.Release{