Skip to content

Commit 6c48344

Browse files
Merge pull request #29870 from RishabhSaini/metalDisconnected
MCO-1722: Handle check for Disconnnected Clusters for PIS Testing using curl
2 parents 202a238 + 36da583 commit 6c48344

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

test/extended/machine_config/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ func IsTwoNodeArbiter(oc *exutil.CLI) bool {
128128

129129
// `IsDisconnected` returns true if the cluster is a Disconnected cluster and false otherwise
130130
func IsDisconnected(oc *exutil.CLI, nodeName string) bool {
131-
networkStatus, _ := exutil.DebugNodeRetryWithOptionsAndChroot(oc, nodeName, "openshift-machine-config-operator", "systemctl", "is-active", "NetworkManager-wait-online.service")
132-
if networkStatus == "active" {
131+
networkStatus, _ := exutil.DebugNodeRetryWithOptionsAndChroot(oc, nodeName, "openshift-machine-config-operator", "sh", "-c", "curl -s --connect-timeout 5 http://fedoraproject.org/static/hotspot.txt &>/dev/null && echo \"Connected\" || echo \"Disconnected\"")
132+
if networkStatus == "Connected" {
133133
return false
134134
}
135135
return true

test/extended/machine_config/pinnedimages.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,17 @@ func SimplePISTest(oc *exutil.CLI, kubeClient *kubernetes.Clientset, clientSet *
363363

364364
func detectXCondition(oc *exutil.CLI, node corev1.Node, mcn *mcfgv1.MachineConfigNode, appliedPIS *mcfgv1.PinnedImageSet, detectingSuccess bool, isMetalDisconnected bool) (bool, bool, error) {
365365
if detectingSuccess {
366+
if isMetalDisconnected {
367+
crictlStatus, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, node.Name, "openshift-machine-config-operator", "crictl", "inspecti", emptyImagePin)
368+
if err != nil {
369+
return false, false, fmt.Errorf("failed to execute `crictl inspecti %s` on node %s: %w", emptyImagePin, node.Name, err)
370+
}
371+
if !strings.Contains(crictlStatus, "imageSpec") {
372+
return false, false, fmt.Errorf("Image %s not present on node %s: %w", emptyImagePin, node.Name, err)
373+
}
374+
return true, false, nil
375+
}
376+
366377
for _, cond := range mcn.Status.Conditions {
367378
if mcfgv1.StateProgress(cond.Type) == mcfgv1.MachineConfigNodePinnedImageSetsDegraded && cond.Status == "True" {
368379
return false, true, fmt.Errorf("PIS degraded for MCN %s with reason: %s and message: %s", mcn.Name, cond.Reason, cond.Message)
@@ -373,16 +384,6 @@ func detectXCondition(oc *exutil.CLI, node corev1.Node, mcn *mcfgv1.MachineConfi
373384
}
374385
}
375386
for _, img := range appliedPIS.Spec.PinnedImages {
376-
if isMetalDisconnected {
377-
crictlStatus, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, node.Name, "openshift-machine-config-operator", "crictl", "inspecti", emptyImagePin)
378-
if err != nil {
379-
return false, false, fmt.Errorf("failed to execute `crictl inspecti %s` on node %s: %w", img.Name, node.Name, err)
380-
}
381-
if !strings.Contains(crictlStatus, "imageSpec") {
382-
return false, false, fmt.Errorf("Image %s not present on node %s: %w", img.Name, node.Name, err)
383-
}
384-
break
385-
}
386387
crictlStatus, err := exutil.DebugNodeRetryWithOptionsAndChroot(oc, node.Name, "openshift-machine-config-operator", "crictl", "inspecti", string(img.Name))
387388
if err != nil {
388389
return false, false, fmt.Errorf("failed to execute `crictl inspecti %s` on node %s: %w", img.Name, node.Name, err)

0 commit comments

Comments
 (0)