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: Cleanup ginkgo test artifacts #25833

Merged
merged 2 commits into from
Jun 6, 2023
Merged
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
67 changes: 0 additions & 67 deletions test/helpers/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3618,58 +3618,6 @@ func (kub *Kubectl) DumpCiliumCommandOutput(ctx context.Context, namespace strin
return
}

ReportOnPod := func(pod string) {
logger := kub.Logger().WithField("CiliumPod", pod)

logsPath := filepath.Join(kub.BasePath(), testPath)

// Get bugtool output. Since bugtool output is dumped in the pod's filesystem,
// copy it over with `kubectl cp`.
bugtoolCmd := fmt.Sprintf("%s exec -n %s %s -- %s %s",
KubectlCmd, namespace, pod, CiliumBugtool, CiliumBugtoolArgs)
res := kub.ExecContext(ctx, bugtoolCmd, ExecOptions{SkipLog: true})
if !res.WasSuccessful() {
logger.Errorf("%s failed: %s", bugtoolCmd, res.CombineOutput().String())
return
}
// Default output directory is /tmp for bugtool.
res = kub.ExecContext(ctx, fmt.Sprintf("%s exec -n %s %s -- ls /tmp/", KubectlCmd, namespace, pod))
tmpList := res.ByLines()
for _, line := range tmpList {
// Only copy over bugtool output to directory.
if !strings.Contains(line, CiliumBugtool) {
continue
}

res = kub.ExecContext(ctx, fmt.Sprintf("%[1]s cp %[2]s/%[3]s:/tmp/%[4]s /tmp/%[4]s",
KubectlCmd, namespace, pod, line),
ExecOptions{SkipLog: true})
if !res.WasSuccessful() {
logger.Errorf("'%s' failed: %s", res.GetCmd(), res.CombineOutput())
continue
}

archiveName := filepath.Join(logsPath, fmt.Sprintf("bugtool-%s", pod))
res = kub.ExecContext(ctx, fmt.Sprintf("mkdir -p %q", archiveName))
if !res.WasSuccessful() {
logger.WithField("cmd", res.GetCmd()).Errorf(
"cannot create bugtool archive folder: %s", res.CombineOutput())
continue
}

cmd := fmt.Sprintf("tar -xf /tmp/%s -C %q --strip-components=1", line, archiveName)
res = kub.ExecContext(ctx, cmd, ExecOptions{SkipLog: true})
if !res.WasSuccessful() {
logger.WithField("cmd", cmd).Errorf(
"Cannot untar bugtool output: %s", res.CombineOutput())
continue
}
//Remove bugtool artifact, so it'll be not used if any other fail test
_ = kub.ExecPodCmdBackground(ctx, namespace, pod, "cilium-agent", fmt.Sprintf("rm /tmp/%s", line))
}

}

pods, err := kub.GetCiliumPodsContext(ctx, namespace)
if err != nil {
kub.Logger().WithError(err).Error("cannot retrieve cilium pods on ReportDump")
Expand All @@ -3691,7 +3639,6 @@ func (kub *Kubectl) DumpCiliumCommandOutput(ctx context.Context, namespace strin
kub.reportMapContext(kvstoreCmdCtx, testPath, ciliumKubCLICommandsKVStore, namespace, CiliumSelector)

for _, pod := range pods {
ReportOnPod(pod)
kub.GatherCiliumCoreDumps(ctx, pod)
}
}
Expand All @@ -3700,14 +3647,6 @@ func (kub *Kubectl) DumpCiliumCommandOutput(ctx context.Context, namespace strin
// directory
func (kub *Kubectl) GatherLogs(ctx context.Context) {
reportCmds := map[string]string{
"kubectl get pods --all-namespaces -o json": "pods.json",
"kubectl get services --all-namespaces -o json": "svc.json",
"kubectl get nodes -o json": "nodes.json",
"kubectl get cn -o json": "ciliumnodes.json",
"kubectl get ds --all-namespaces -o json": "ds.json",
"kubectl get cnp --all-namespaces -o json": "cnp.json",
"kubectl get cep --all-namespaces -o json": "cep.json",
"kubectl get netpol --all-namespaces -o json": "netpol.json",
"kubectl describe pods --all-namespaces": "pods_status.txt",
"kubectl get replicationcontroller --all-namespaces -o json": "replicationcontroller.json",
"kubectl get deployment --all-namespaces -o json": "deployment.json",
Expand All @@ -3716,12 +3655,6 @@ func (kub *Kubectl) GatherLogs(ctx context.Context) {
"kubectl get serviceaccount --all-namespaces -o json": "serviceaccounts.json",
"kubectl get clusterrole -o json": "clusterroles.json",
"kubectl get clusterrolebinding -o json": "clusterrolebindings.json",

fmt.Sprintf("kubectl get cm cilium-config -n %s -o json", CiliumNamespace): "cilium-config.json",
fmt.Sprintf("kubectl logs -l k8s-app=cilium -n %s --timestamps -c clean-cilium-state --tail -1", CiliumNamespace): "cilium-init-container-logs.txt",
fmt.Sprintf("kubectl logs -l k8s-app=cilium -n %s --timestamps -c clean-cilium-state --previous --tail -1", CiliumNamespace): "cilium-init-container-logs-previous.txt",
fmt.Sprintf("kubectl logs -l k8s-app=cilium -n %s --timestamps --all-containers --tail -1", CiliumNamespace): "cilium-combined-logs.txt",
fmt.Sprintf("kubectl logs -l k8s-app=cilium -n %s --timestamps --all-containers --previous --tail -1", CiliumNamespace): "cilium-combined-logs-previous.txt",
}

kub.GeneratePodLogGatheringCommands(ctx, reportCmds)
Expand Down