Skip to content
Merged
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
26 changes: 26 additions & 0 deletions test/extended/operators/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ var _ = g.Describe("[sig-arch][Early] Managed cluster should", func() {
e2e.Failf("ClusterVersion Progressing=%s: %s: %s", cond.Get("status").String(), cond.Get("reason").String(), cond.Get("message").String())
}

g.By("determining if the cluster is in a TechPreview state")
fgc := dc.Resource(schema.GroupVersionResource{Group: "config.openshift.io", Resource: "featuregates", Version: "v1"})
fgObj, err := fgc.Get(context.Background(), "cluster", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

fg := objx.Map(fgObj.UnstructuredContent())
featureSet := fg.Get("spec.featureSet").String()
isTechPreview := featureSet == "TechPreviewNoUpgrade"

// gate on all clusteroperators being ready
g.By("ensuring all cluster operators are stable")
coc := dc.Resource(schema.GroupVersionResource{Group: "config.openshift.io", Resource: "clusteroperators", Version: "v1"})
Expand All @@ -74,6 +83,13 @@ var _ = g.Describe("[sig-arch][Early] Managed cluster should", func() {
badConditions, missingTypes := surprisingConditions(co)
if len(badConditions) > 0 {
worstCondition := badConditions[0]

// kube-apiserver blocks upgrades when feature gates are present.
// Allow testing of TechPreviewNoUpgrade clusters by ignoring this condition.
if isTechPreview && name == "kube-apiserver" && isKubeAPIUpgradableTechPreviewCondition(worstCondition) {
continue
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.

Does this risk ignoring other failure conditions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This may depend on what surprisingConditions returns. I would expect this condition to be relatively low down the list of bad conditions, but it's something I need to check.

If my assumption that this isn't a terrible condition is correct, then another failure should take precedence in assignment of worstCondition and we should be safe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed, Upgradable is the last one it looks for when it's searching the conditions, this should be safe as is, if the available or degraded conditions are not as expected they will take precedence

}

unready = append(unready, fmt.Sprintf("%s (%s=%s %s: %s)",
name,
worstCondition.Type,
Expand Down Expand Up @@ -235,3 +251,13 @@ func surprisingConditions(co objx.Map) ([]configv1.ClusterOperatorStatusConditio
}
return badConditions, missingTypes
}

// When a TechPreviewNoUpgrade feature set is in force in the cluster, the following condition
// is set on the kube-apiserver cluster operator
// Ref: https://github.com/openshift/cluster-kube-apiserver-operator/blob/39a98d67c3b825b9215454a7817ffadb0577609b/pkg/operator/featureupgradablecontroller/feature_upgradeable_controller_test.go#L41-L46
func isKubeAPIUpgradableTechPreviewCondition(cond configv1.ClusterOperatorStatusCondition) bool {
return cond.Reason == "FeatureGates_RestrictedFeatureGates_TechPreviewNoUpgrade" &&
cond.Status == "False" &&
cond.Type == "Upgradeable" &&
cond.Message == "FeatureGatesUpgradeable: \"TechPreviewNoUpgrade\" does not allow updates"
}