Skip to content

Commit 8d4e01b

Browse files
Merge pull request #31312 from mdbooth/investigate-qos-debug-race
OCPBUGS-89351: Fix flake in best-effort QoS test due to debug pods
2 parents dd883a7 + 50ce7fa commit 8d4e01b

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

test/extended/node/node_utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ func getPureWorkerNodes(nodes []corev1.Node) []corev1.Node {
9595
}
9696

9797
const (
98-
// debugNamespace is the namespace for debug pods
99-
debugNamespace = "openshift-machine-config-operator"
98+
// DebugNamespace is the namespace for debug pods
99+
DebugNamespace = "openshift-machine-config-operator"
100100
// cnvNamespace is the namespace for CNV operator
101101
cnvNamespace = "openshift-cnv"
102102
// cnvOperatorGroup is the name of the CNV operator group
@@ -158,7 +158,7 @@ func getCNVWorkerNodeName(ctx context.Context, oc *exutil.CLI) string {
158158

159159
// ExecOnNodeWithChroot runs a command on a node using oc debug with chroot /host
160160
func ExecOnNodeWithChroot(oc *exutil.CLI, nodeName string, cmd ...string) (string, error) {
161-
args := append([]string{"node/" + nodeName, "-n" + debugNamespace, "--", "chroot", "/host"}, cmd...)
161+
args := append([]string{"node/" + nodeName, "-n" + DebugNamespace, "--", "chroot", "/host"}, cmd...)
162162
stdOut, _, err := oc.AsAdmin().WithoutNamespace().Run("debug").Args(args...).Outputs()
163163
return stdOut, err
164164
}
@@ -167,7 +167,7 @@ func ExecOnNodeWithChroot(oc *exutil.CLI, nodeName string, cmd ...string) (strin
167167
// This is needed for swap operations (swapon/swapoff) that require direct namespace access
168168
func ExecOnNodeWithNsenter(oc *exutil.CLI, nodeName string, cmd ...string) (string, error) {
169169
nsenterCmd := append([]string{"nsenter", "-a", "-t", "1"}, cmd...)
170-
args := append([]string{"node/" + nodeName, "-n" + debugNamespace, "--"}, nsenterCmd...)
170+
args := append([]string{"node/" + nodeName, "-n" + DebugNamespace, "--"}, nsenterCmd...)
171171
stdOut, _, err := oc.AsAdmin().WithoutNamespace().Run("debug").Args(args...).Outputs()
172172
return stdOut, err
173173
}

test/extended/operators/qos.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"k8s.io/apimachinery/pkg/util/sets"
1313
e2e "k8s.io/kubernetes/test/e2e/framework"
1414

15+
"github.com/openshift/origin/test/extended/node"
1516
exutil "github.com/openshift/origin/test/extended/util"
1617
)
1718

@@ -69,6 +70,16 @@ var _ = Describe("[sig-arch] Managed cluster should", func() {
6970
if hasPrefixSet(pod.Name, excludePodPrefix) {
7071
continue
7172
}
73+
// Exclude ephemeral oc debug node pods created by the
74+
// node.ExecOnNode*() helper functions.
75+
//
76+
// These are privileged, transient pods with no resource requests.
77+
// They are best-effort QoS by design. They are created by many
78+
// other tests, and will cause this test to fail if one happens to
79+
// be present while it executes.
80+
if pod.Namespace == node.DebugNamespace && isEphemeralDebugPod(&pod) {
81+
continue
82+
}
7283
if pod.Status.QOSClass == v1.PodQOSBestEffort {
7384
invalidPodQoS.Insert(fmt.Sprintf("%s/%s is running in best-effort QoS", pod.Namespace, pod.Name))
7485
}
@@ -79,3 +90,15 @@ var _ = Describe("[sig-arch] Managed cluster should", func() {
7990
}
8091
})
8192
})
93+
94+
func isEphemeralDebugPod(pod *v1.Pod) bool {
95+
// Debug pods created by oc can be identified via:
96+
// - the managed-by label set by modern oc versions
97+
// - the source-resource annotation set by modern oc versions
98+
// - the "-debug-" name pattern used by all oc versions
99+
// The name pattern is the only reliable signal for older oc binaries
100+
// (e.g. oc/v4.2.0) that predate the label/annotation.
101+
return pod.Labels["debug.openshift.io/managed-by"] == "oc-debug" ||
102+
pod.Annotations["debug.openshift.io/source-resource"] != "" ||
103+
strings.Contains(pod.Name, "-debug-")
104+
}

0 commit comments

Comments
 (0)