Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Pass container to ExecPodCmdBackground() #16435

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions test/helpers/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,10 @@ func (kub *Kubectl) ExecPodCmdContext(ctx context.Context, namespace string, pod
// To receive the output of this function, the caller must invoke either
// kub.WaitUntilFinish() or kub.WaitUntilMatch() then subsequently fetch the
// output out of the result.
func (kub *Kubectl) ExecPodCmdBackground(ctx context.Context, namespace string, pod string, cmd string, options ...ExecOptions) *CmdRes {
func (kub *Kubectl) ExecPodCmdBackground(ctx context.Context, namespace string, pod, container string, cmd string, options ...ExecOptions) *CmdRes {
if container != "" {
pod += " -c " + container
}
command := fmt.Sprintf("%s exec -n %s %s -- %s", KubectlCmd, namespace, pod, cmd)
return kub.ExecInBackground(ctx, command, options...)
}
Expand Down Expand Up @@ -3246,7 +3249,7 @@ func (kub *Kubectl) CiliumReport(commands ...string) {
ginkgoext.GinkgoPrint("Fetching command output from pods %s", pods)
for _, pod := range pods {
for _, cmd := range commands {
res = kub.ExecPodCmdBackground(ctx, CiliumNamespace, pod, cmd, ExecOptions{SkipLog: true})
res = kub.ExecPodCmdBackground(ctx, CiliumNamespace, pod, "cilium-agent", cmd, ExecOptions{SkipLog: true})
results = append(results, res)
}
}
Expand Down Expand Up @@ -3566,7 +3569,7 @@ func (kub *Kubectl) DumpCiliumCommandOutput(ctx context.Context, namespace strin
continue
}
//Remove bugtool artifact, so it'll be not used if any other fail test
_ = kub.ExecPodCmdBackground(ctx, namespace, pod, fmt.Sprintf("rm /tmp/%s", line))
_ = kub.ExecPodCmdBackground(ctx, namespace, pod, "cilium-agent", fmt.Sprintf("rm /tmp/%s", line))
}

}
Expand Down Expand Up @@ -4204,9 +4207,9 @@ func (kub *Kubectl) HubbleObserve(pod string, args string) *CmdRes {
}

// HubbleObserveFollow runs `hubble observe --follow --output=json <args>` on
// 'ns/pod' in the background. The process is stopped when ctx is cancelled.
// the Cilium pod 'ns/pod' in the background. The process is stopped when ctx is cancelled.
func (kub *Kubectl) HubbleObserveFollow(ctx context.Context, pod string, args string) *CmdRes {
return kub.ExecPodCmdBackground(ctx, CiliumNamespace, pod, fmt.Sprintf("hubble observe --follow --output=json %s", args))
return kub.ExecPodCmdBackground(ctx, CiliumNamespace, pod, "cilium-agent", fmt.Sprintf("hubble observe --follow --output=json %s", args))
}

// WaitForIPCacheEntry waits until the given ipAddr appears in "cilium bpf ipcache list"
Expand Down
4 changes: 2 additions & 2 deletions test/k8sT/Chaos.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ var _ = SkipDescribeIf(helpers.RunsOn54Kernel, "K8sChaosTest", func() {
res := kubectl.ExecPodCmdBackground(
ctx,
helpers.DefaultNamespace,
netperfClient,
netperfClient, "",
fmt.Sprintf("netperf -l 60 -t TCP_STREAM -H %s", podsIps[netperfServer]))

restartCilium()
Expand All @@ -250,7 +250,7 @@ var _ = SkipDescribeIf(helpers.RunsOn54Kernel, "K8sChaosTest", func() {
res := kubectl.ExecPodCmdBackground(
ctx,
helpers.DefaultNamespace,
netperfClient,
netperfClient, "",
fmt.Sprintf("netperf -l 60 -t TCP_STREAM -H %s", podsIps[netperfServer]))

By("Installing the L3-L4 Policy")
Expand Down