Skip to content

Commit 46485ae

Browse files
committed
monitortests: update flaking namespaces and exclude managed services
1 parent 6897e4b commit 46485ae

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

pkg/monitortests/authentication/requiredsccmonitortests/monitortest.go

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/openshift/origin/pkg/monitor/monitorapi"
1111
"github.com/openshift/origin/pkg/monitortestframework"
1212
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
13+
exutil "github.com/openshift/origin/test/extended/util"
1314
v1 "k8s.io/api/core/v1"
1415
"k8s.io/apimachinery/pkg/util/sets"
1516

@@ -36,6 +37,7 @@ var nonStandardSCCNamespaces = map[string]sets.Set[string]{
3637
"machine-api-termination-handler": sets.New("openshift-machine-api"),
3738
}
3839

40+
// namespacesWithPendingSCCPinning includes namespaces with workloads that have pending SCC pinning.
3941
var namespacesWithPendingSCCPinning = sets.NewString(
4042
"openshift-cluster-csi-drivers",
4143
"openshift-cluster-version",
@@ -45,8 +47,28 @@ var namespacesWithPendingSCCPinning = sets.NewString(
4547
"openshift-ingress-operator",
4648
"openshift-insights",
4749
"openshift-machine-api",
48-
"openshift-marketplace",
4950
"openshift-monitoring",
51+
// run-level namespaces
52+
"openshift-cloud-controller-manager",
53+
"openshift-cloud-controller-manager-operator",
54+
"openshift-cluster-api",
55+
"openshift-cluster-machine-approver",
56+
"openshift-dns",
57+
"openshift-dns-operator",
58+
"openshift-etcd",
59+
"openshift-etcd-operator",
60+
"openshift-kube-apiserver",
61+
"openshift-kube-apiserver-operator",
62+
"openshift-kube-controller-manager",
63+
"openshift-kube-controller-manager-operator",
64+
"openshift-kube-proxy",
65+
"openshift-kube-scheduler",
66+
"openshift-kube-scheduler-operator",
67+
"openshift-multus",
68+
"openshift-network-operator",
69+
"openshift-ovn-kubernetes",
70+
"openshift-sdn",
71+
"openshift-storage",
5072
)
5173

5274
// systemNamespaces includes namespaces that should be treated as flaking.
@@ -90,19 +112,18 @@ func (w *requiredSCCAnnotationChecker) CollectData(ctx context.Context, storageD
90112

91113
junits := []*junitapi.JUnitTestCase{}
92114
for _, ns := range namespaces.Items {
93-
// require that all workloads in openshift, kube-* or default namespaces must have the required-scc annotation
115+
// skip managed service namespaces
116+
if exutil.ManagedServiceNamespaces.Has(ns.Name) {
117+
continue
118+
}
119+
120+
// require that all workloads in openshift, kube-*, or default namespaces must have the required-scc annotation
94121
// ignore openshift-must-gather-* namespaces which are generated dynamically
95122
isPermanentOpenShiftNamespace := (ns.Name == "openshift" || strings.HasPrefix(ns.Name, "openshift-")) && !strings.HasPrefix(ns.Name, "openshift-must-gather-")
96123
if !strings.HasPrefix(ns.Name, "kube-") && ns.Name != "default" && !isPermanentOpenShiftNamespace {
97124
continue
98125
}
99126

100-
// check if the namespace should be treated as flaking when failed
101-
flakeWhenFailed := ns.Labels["openshift.io/run-level"] == "0" ||
102-
ns.Labels["openshift.io/run-level"] == "1" ||
103-
namespacesWithPendingSCCPinning.Has(ns.Name) ||
104-
systemNamespaces.Has(ns.Name)
105-
106127
pods, err := w.kubeClient.CoreV1().Pods(ns.Name).List(ctx, metav1.ListOptions{})
107128
if err != nil {
108129
return nil, nil, err
@@ -168,8 +189,8 @@ func (w *requiredSCCAnnotationChecker) CollectData(ctx context.Context, storageD
168189
FailureOutput: &junitapi.FailureOutput{Output: failureMsg},
169190
})
170191

171-
// add a successful test with the same name to cause a flake
172-
if flakeWhenFailed {
192+
// add a successful test with the same name to cause a flake if the namespace should be flaking
193+
if namespacesWithPendingSCCPinning.Has(ns.Name) || systemNamespaces.Has(ns.Name) {
173194
junits = append(junits,
174195
&junitapi.JUnitTestCase{
175196
Name: testName,

0 commit comments

Comments
 (0)