@@ -894,25 +894,34 @@ var _ = g.Describe("[Jira:Node/Kubelet][sig-node][Feature:NodeSwap][Serial][Disr
894894
895895 g .By ("Checking initial OS-level swap status" )
896896 framework .Logf ("Running: swapon -s" )
897- initialSwapOutput , _ := ExecOnNodeWithChroot (oc , cnvWorkerNode , "swapon" , "-s" )
897+ initialSwapOutput , err := ExecOnNodeWithChroot (oc , cnvWorkerNode , "swapon" , "-s" )
898+ o .Expect (err ).NotTo (o .HaveOccurred (), "Failed to check initial swap status on node %s: %v" , cnvWorkerNode , err )
898899 framework .Logf ("Initial swapon -s output:\n %s" , initialSwapOutput )
899900 initialHasSwap := strings .TrimSpace (initialSwapOutput ) != "" && initialSwapOutput != "Filename\t \t \t \t Type\t \t Size\t \t Used\t \t Priority"
900901
901902 // If swap is already enabled, disable it for this test
902903 if initialHasSwap {
903904 g .By ("Disabling existing OS-level swap for test" )
904905 framework .Logf ("Running: swapoff -a" )
905- _ , _ = ExecOnNodeWithNsenter (oc , cnvWorkerNode , "swapoff" , "-a" )
906+ swapoffOutput , swapoffErr := ExecOnNodeWithNsenter (oc , cnvWorkerNode , "swapoff" , "-a" )
907+ if swapoffErr != nil {
908+ framework .Failf ("Failed to disable swap on node %s: %v (output: %s)" , cnvWorkerNode , swapoffErr , swapoffOutput )
909+ }
906910 framework .Logf ("OS-level swap disabled" )
907911 }
908912
909913 g .By ("Verifying no OS-level swap is present" )
910914 framework .Logf ("Running: swapon -s" )
911- swapOutput , _ := ExecOnNodeWithChroot (oc , cnvWorkerNode , "swapon" , "-s" )
915+ swapOutput , err := ExecOnNodeWithChroot (oc , cnvWorkerNode , "swapon" , "-s" )
916+ o .Expect (err ).NotTo (o .HaveOccurred (), "Failed to verify swap status on node %s: %v" , cnvWorkerNode , err )
912917 framework .Logf ("swapon -s output:\n %s" , swapOutput )
913918 hasOSSwap := strings .TrimSpace (swapOutput ) != "" && swapOutput != "Filename\t \t \t \t Type\t \t Size\t \t Used\t \t Priority"
914919 if hasOSSwap {
915- framework .Logf ("Warning: Could not disable OS swap, but continuing with test" )
920+ if initialHasSwap {
921+ framework .Failf ("OS-level swap still present on node %s after swapoff attempt. Output:\n %s" , cnvWorkerNode , swapOutput )
922+ } else {
923+ framework .Failf ("Unexpected OS-level swap found on node %s. Output:\n %s" , cnvWorkerNode , swapOutput )
924+ }
916925 } else {
917926 framework .Logf ("Confirmed: No OS-level swap on node %s" , cnvWorkerNode )
918927 }
@@ -924,7 +933,7 @@ var _ = g.Describe("[Jira:Node/Kubelet][sig-node][Feature:NodeSwap][Serial][Disr
924933 g .By ("Creating LimitedSwap drop-in configuration" )
925934 framework .Logf ("Creating drop-in file: %s" , cnvDropInFilePath )
926935 framework .Logf ("Content:\n %s" , loadConfigFromFile (cnvLimitedSwapConfigPath ))
927- err : = createDropInFile (oc , cnvWorkerNode , cnvDropInFilePath , loadConfigFromFile (cnvLimitedSwapConfigPath ))
936+ err = createDropInFile (oc , cnvWorkerNode , cnvDropInFilePath , loadConfigFromFile (cnvLimitedSwapConfigPath ))
928937 o .Expect (err ).NotTo (o .HaveOccurred ())
929938 framework .Logf ("Drop-in file created successfully" )
930939
@@ -1099,9 +1108,16 @@ var _ = g.Describe("[Jira:Node/Kubelet][sig-node][Feature:NodeSwap][Serial][Disr
10991108 }
11001109
11011110 g .By (fmt .Sprintf ("Disabling any existing swap for %s test" , swapSize .name ))
1102- framework .Logf ("Running: swapoff -a" )
1103- ExecOnNodeWithNsenter (oc , cnvWorkerNode , "swapoff" , "-a" )
1104- ExecOnNodeWithChroot (oc , cnvWorkerNode , "rm" , "-f" , swapFilePath )
1111+ framework .Logf ("Running: swapoff -a on node %s" , cnvWorkerNode )
1112+ swapoffOutput , swapoffErr := ExecOnNodeWithNsenter (oc , cnvWorkerNode , "swapoff" , "-a" )
1113+ if swapoffErr != nil {
1114+ framework .Failf ("Failed to disable swap on node %s for %s test: %v (output: %s)" , cnvWorkerNode , swapSize .name , swapoffErr , swapoffOutput )
1115+ }
1116+ framework .Logf ("Running: rm -f %s on node %s" , swapFilePath , cnvWorkerNode )
1117+ rmOutput , rmErr := ExecOnNodeWithChroot (oc , cnvWorkerNode , "rm" , "-f" , swapFilePath )
1118+ if rmErr != nil {
1119+ framework .Failf ("Failed to remove swap file %s on node %s for %s test: %v (output: %s)" , swapFilePath , cnvWorkerNode , swapSize .name , rmErr , rmOutput )
1120+ }
11051121
11061122 g .By (fmt .Sprintf ("Creating %dMB swap file" , swapSize .sizeMB ))
11071123 framework .Logf ("Running: dd if=/dev/zero of=%s bs=1M count=%d" , swapFilePath , swapSize .sizeMB )
0 commit comments