Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Dec 11, 2024
1 parent 74ce820 commit 488ff97
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions test/e2e/azure_apiserver_ilb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build e2e
// +build e2e

/*
Copyright 2024 The Kubernetes Authors.
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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")

Expand All @@ -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"] {
Expand Down

0 comments on commit 488ff97

Please sign in to comment.