From 488ff97a50d55345b853d93ad1d90b69295a67cd Mon Sep 17 00:00:00 2001 From: Nawaz Hussain Khazielakha Date: Wed, 11 Dec 2024 14:11:31 -0800 Subject: [PATCH] fix errors --- test/e2e/azure_apiserver_ilb.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/test/e2e/azure_apiserver_ilb.go b/test/e2e/azure_apiserver_ilb.go index e663fcc866f..49ad3bbdd75 100644 --- a/test/e2e/azure_apiserver_ilb.go +++ b/test/e2e/azure_apiserver_ilb.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - /* Copyright 2024 The Kubernetes Authors. @@ -279,6 +276,8 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe By("Getting the kubeconfig path for the workload cluster") workloadClusterKubeConfigPath := workloadClusterProxy.GetKubeconfigPath() workloadClusterKubeConfig, err := clientcmd.BuildConfigFromFlags("", workloadClusterKubeConfigPath) + fmt.Fprintf(GinkgoWriter, "workloadClusterKubeConfig: %v\n", workloadClusterKubeConfig) + if err != nil { return false, fmt.Errorf("failed to build workload cluster kubeconfig from flags: %v", err) } @@ -308,7 +307,7 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe } for expectedCmdOutput, execCommand := range listOfCommands { fmt.Fprintf(GinkgoWriter, "Trying to exec into the pod %s at namespace %s and running the command %s\n", nodeDebugPod.Name, nodeDebugPod.Namespace, strings.Join(execCommand, " ")) - req := workloadClusterClientSet.CoreV1().RESTClient().Post().Resource("pods").Name(nodeDebugPod.Name). + execRequest := workloadClusterClientSet.CoreV1().RESTClient().Post().Resource("pods").Name(nodeDebugPod.Name). Namespace(nodeDebugPod.Namespace). SubResource("exec") @@ -320,40 +319,34 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe TTY: false, } - req.VersionedParams( + execRequest.VersionedParams( option, scheme.ParameterCodec, ) - // podExecOperationTimeout := 10 * time.Second - // podExecOperationSleepBetweenRetries := 3 * time.Second - // Eventually(func(g Gomega) { - exec, err := remotecommand.NewSPDYExecutor(workloadClusterKubeConfig, "POST", req.URL()) - // g.Expect(err).NotTo(HaveOccurred()) + fmt.Fprintf(GinkgoWriter, "Creating executor for the pod %s using the URL %v\n", nodeDebugPod.Name, execRequest.URL()) + exec, err := remotecommand.NewSPDYExecutor(workloadClusterKubeConfig, "POST", execRequest.URL()) if err != nil { return false, fmt.Errorf("failed to create executor: %v", err) } By("Streaming stdout/err from the daemonset") var stdout, stderr bytes.Buffer - err = exec.StreamWithContext(ctx, remotecommand.StreamOptions{ + err = exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{ Stdin: nil, Stdout: &stdout, Stderr: &stderr, Tty: false, }) - // g.Expect(err).NotTo(HaveOccurred()) if err != nil { return false, fmt.Errorf("failed to stream stdout/err from the daemonset: %v", err) } output := stdout.String() fmt.Fprintf(GinkgoWriter, "Captured output!!!!!!!!\n\t\t%s\n", output) - // g.Expect(output).To(ContainSubstring(expectedCmdOutput)) if strings.Contains(output, expectedCmdOutput) { testResult[expectedCmdOutput] = true } - // }, podExecOperationTimeout, podExecOperationSleepBetweenRetries).Should(Succeed()) } if testResult[apiServerILBPrivateIP] && testResult["Hello from node-debug pod"] {