Skip to content

Commit 5891e83

Browse files
committed
ClusterOperators should not go Progressing only for cluster scaling
This is to cover the cluster scaling case from the rule [1] that is introduced recently: ``` Operators should not report Progressing only because DaemonSets owned by them are adjusting to a new node from cluster scaleup or a node rebooting from cluster upgrade. ``` The test plugs into the existing scaling test. It checks each CO's Progressing condition before and after the test, and identifies every CO that either left Progressing=False or re-entered Progressing=False with a different LastTransitionTime. [1]. https://github.com/openshift/api/blob/61248d910ff74aef020492922d14e6dadaba598b/config/v1/types_cluster_operator.go#L163-L164
1 parent 92f0f58 commit 5891e83

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

test/extended/machines/scale.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
g "github.com/onsi/ginkgo/v2"
1111
o "github.com/onsi/gomega"
12+
configv1 "github.com/openshift/api/config/v1"
13+
configclient "github.com/openshift/client-go/config/clientset/versioned"
1214
bmhelper "github.com/openshift/origin/test/extended/baremetal"
1315
"github.com/stretchr/objx"
1416
corev1 "k8s.io/api/core/v1"
@@ -186,12 +188,31 @@ func scaleMachineSet(name string, replicas int) error {
186188
return nil
187189
}
188190

191+
func getOperatorsNotProgressing(c configclient.Interface) map[string]metav1.Time {
192+
operators, err := c.ConfigV1().ClusterOperators().List(context.Background(), metav1.ListOptions{})
193+
o.Expect(err).NotTo(o.HaveOccurred())
194+
result := map[string]metav1.Time{}
195+
for _, operator := range operators.Items {
196+
if operator.Name == "machine-config" {
197+
continue
198+
}
199+
for _, condition := range operator.Status.Conditions {
200+
if condition.Type == configv1.OperatorProgressing && condition.Status == configv1.ConditionFalse {
201+
result[operator.Name] = condition.LastTransitionTime
202+
}
203+
}
204+
}
205+
return result
206+
}
207+
189208
var _ = g.Describe("[sig-cluster-lifecycle][Feature:Machines][Serial] Managed cluster should", func() {
190209

191210
var (
192-
c *kubernetes.Clientset
193-
dc dynamic.Interface
194-
helper *bmhelper.BaremetalTestHelper
211+
c *kubernetes.Clientset
212+
configClient configclient.Interface
213+
dc dynamic.Interface
214+
helper *bmhelper.BaremetalTestHelper
215+
operatorsNotProgressing map[string]metav1.Time
195216
)
196217

197218
g.BeforeEach(func() {
@@ -210,10 +231,26 @@ var _ = g.Describe("[sig-cluster-lifecycle][Feature:Machines][Serial] Managed cl
210231
helper.Setup()
211232
helper.DeployExtraWorker(0)
212233
}
234+
235+
configClient, err = configclient.NewForConfig(cfg)
236+
o.Expect(err).NotTo(o.HaveOccurred())
237+
operatorsNotProgressing = getOperatorsNotProgressing(configClient)
213238
})
214239

215240
g.AfterEach(func() {
216241
helper.DeleteAllExtraWorkers()
242+
243+
// No cluster operator should leave Progressing=False only up to cluster scaling
244+
// https://github.com/openshift/api/blob/61248d910ff74aef020492922d14e6dadaba598b/config/v1/types_cluster_operator.go#L163-L164
245+
operatorsNotProgressingAfter := getOperatorsNotProgressing(configClient)
246+
var violations []string
247+
for operator, t1 := range operatorsNotProgressing {
248+
t2, ok := operatorsNotProgressingAfter[operator]
249+
if !ok || t1.Unix() != t2.Unix() {
250+
violations = append(violations, operator)
251+
}
252+
}
253+
o.Expect(violations).To(o.BeEmpty(), "those cluster operators left Progressing=False while cluster was scaling: %v", violations)
217254
})
218255

219256
// The 30m timeout is essentially required by the baremetal platform environment,

0 commit comments

Comments
 (0)