Skip to content

Commit 77d41e0

Browse files
Merge pull request #30153 from eggfoobar/operator-availability-excepton-for-two-node
OCPBUGS-60842: fix: add exception for csi snapshot controller on two node
2 parents d1a0543 + a02399e commit 77d41e0

File tree

1 file changed

+31
-10
lines changed
  • pkg/monitortests/clusterversionoperator/legacycvomonitortests

1 file changed

+31
-10
lines changed

pkg/monitortests/clusterversionoperator/legacycvomonitortests/operators.go

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/sirupsen/logrus"
1515

1616
configv1 "github.com/openshift/api/config/v1"
17-
clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned"
17+
clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
1818
"github.com/openshift/origin/pkg/monitor/monitorapi"
1919
"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
2020
platformidentification2 "github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
@@ -46,11 +46,11 @@ func checkAuthenticationAvailableExceptions(condition *configv1.ClusterOperatorS
4646
}
4747

4848
func testStableSystemOperatorStateTransitions(events monitorapi.Intervals, clientConfig *rest.Config) []*junitapi.JUnitTestCase {
49-
isSingleNode, err := isSingleNodeCheck(clientConfig)
49+
topology, err := getControlPlaneTopology(clientConfig)
5050
if err != nil {
51-
logrus.Warnf("Error checking for Single Node configuration on upgrade (unable to make exception): %v", err)
52-
isSingleNode = false
51+
logrus.Warnf("Error checking for ControlPlaneTopology configuration (unable to make topology exceptions): %v", err)
5352
}
53+
isSingleNode := topology == configv1.SingleReplicaTopologyMode
5454

5555
except := func(operator string, condition *configv1.ClusterOperatorStatusCondition, _ monitorapi.Interval, clientConfig *rest.Config) (string, error) {
5656
if condition.Status == configv1.ConditionTrue {
@@ -147,13 +147,22 @@ func testStableSystemOperatorStateTransitions(events monitorapi.Intervals, clien
147147
return testOperatorStateTransitions(events, []configv1.ClusterStatusConditionType{configv1.OperatorAvailable, configv1.OperatorDegraded}, except, clientConfig)
148148
}
149149

150-
func isSingleNodeCheck(clientConfig *rest.Config) (bool, error) {
150+
func getControlPlaneTopology(clientConfig *rest.Config) (configv1.TopologyMode, error) {
151151
configClient, err := clientconfigv1.NewForConfig(clientConfig)
152152
if err != nil {
153153
logrus.WithError(err).Error("Error creating config client to check for Single Node configuration")
154-
return false, err
154+
return "", err
155155
}
156-
return exutil.IsSingleNode(context.Background(), configClient)
156+
157+
topo, err := exutil.GetControlPlaneTopologyFromConfigClient(configClient)
158+
if err != nil {
159+
return "", err
160+
}
161+
// Should not happen since the error should be returned if the topology is nil in the previous call, but just in case
162+
if topo == nil {
163+
return "", fmt.Errorf("when fetching control plane topology, the topology was nil, this is extremely unusual")
164+
}
165+
return *topo, nil
157166
}
158167

159168
// isInUpgradeWindow determines if the given eventInterval falls within an upgrade window.
@@ -239,12 +248,14 @@ func isInUpgradeWindow(upgradeWindows []*upgradeWindowHolder, eventInterval moni
239248

240249
func testUpgradeOperatorStateTransitions(events monitorapi.Intervals, clientConfig *rest.Config) []*junitapi.JUnitTestCase {
241250
upgradeWindows := getUpgradeWindows(events)
242-
isSingleNode, err := isSingleNodeCheck(clientConfig)
251+
topology, err := getControlPlaneTopology(clientConfig)
243252
if err != nil {
244-
logrus.Warnf("Error checking for Single Node configuration on upgrade (unable to make exception): %v", err)
245-
isSingleNode = false
253+
logrus.Warnf("Error checking for ControlPlaneTopology configuration on upgrade (unable to make topology exceptions): %v", err)
246254
}
247255

256+
isSingleNode := topology == configv1.SingleReplicaTopologyMode
257+
isTwoNode := topology == configv1.HighlyAvailableArbiterMode || topology == configv1.DualReplicaTopologyMode
258+
248259
except := func(operator string, condition *configv1.ClusterOperatorStatusCondition, eventInterval monitorapi.Interval, clientConfig *rest.Config) (string, error) {
249260
if condition.Status == configv1.ConditionTrue {
250261
if condition.Type == configv1.OperatorAvailable {
@@ -256,6 +267,16 @@ func testUpgradeOperatorStateTransitions(events monitorapi.Intervals, clientConf
256267
}
257268
}
258269

270+
if isTwoNode {
271+
switch operator {
272+
case "csi-snapshot-controller":
273+
if condition.Type == configv1.OperatorAvailable && condition.Status == configv1.ConditionFalse &&
274+
strings.Contains(condition.Message, `Waiting for Deployment`) {
275+
return "csi snapshot controller is allowed to have Available=False due to CSI webhook test on two node", nil
276+
}
277+
}
278+
}
279+
259280
withinUpgradeWindowBuffer := isInUpgradeWindow(upgradeWindows, eventInterval) && eventInterval.To.Sub(eventInterval.From) < 10*time.Minute
260281
if !withinUpgradeWindowBuffer {
261282
switch operator {

0 commit comments

Comments
 (0)