Skip to content

Commit

Permalink
Fix support bundle collection (#595)
Browse files Browse the repository at this point in the history
Add common labels to worker, build and signing pods so that their logs
are collected in the support bundle.
  • Loading branch information
qbarrand authored Oct 10, 2023
1 parent 95e7c76 commit 3f05a76
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
13 changes: 7 additions & 6 deletions .github/actions/collect-troubleshooting/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Collect troubleshooting data

description: This action fetches some troubleshooting data for KMM

inputs:
output-file:
description: Name of the archive file
required: true

runs:
using: composite

Expand All @@ -12,15 +17,11 @@ runs:
echo "PATH=${KREW_ROOT:-$HOME/.krew}/bin:$PATH" >> "$GITHUB_ENV"
shell: bash

- name: Set the output file
run: echo "OUTPUT_FILE=${{ github.job }}-support-bundle.tar.gz" >> "$GITHUB_ENV"
shell: bash

- name: Collect a support bundle
run: kubectl support-bundle -o $OUTPUT_FILE ./support/kmm.spec.yaml
run: kubectl support-bundle -o ${{ inputs.output-file }} ./support/kmm.spec.yaml
shell: bash

- uses: actions/upload-artifact@v3
with:
name: support-bundle
path: ${{ env.OUTPUT_FILE }}
path: ${{ inputs.output-file }}
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ jobs:
- name: Collect troubleshooting data
uses: ./.github/actions/collect-troubleshooting
if: ${{ always() }}
with:
output-file: ${{ matrix.name }}-support-bundle.tar.gz
7 changes: 6 additions & 1 deletion internal/controllers/nmc_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,12 @@ func (p *podManagerImpl) baseWorkerPod(
ObjectMeta: metav1.ObjectMeta{
Namespace: item.Namespace,
Name: workerPodName(nodeName, item.Name),
Labels: map[string]string{constants.ModuleNameLabel: item.Name},
Labels: map[string]string{
"app.kubernetes.io/name": "kmm",
"app.kubernetes.io/component": "worker",
"app.kubernetes.io/part-of": "kmm",
constants.ModuleNameLabel: item.Name,
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
Expand Down
10 changes: 7 additions & 3 deletions internal/controllers/nmc_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1432,12 +1432,16 @@ softdep b pre: c
Name: workerPodName(nmcName, moduleName),
Namespace: namespace,
Labels: map[string]string{
actionLabelKey: string(action),
constants.ModuleNameLabel: moduleName,
"app.kubernetes.io/component": "worker",
"app.kubernetes.io/name": "kmm",
"app.kubernetes.io/part-of": "kmm",
actionLabelKey: string(action),
constants.ModuleNameLabel: moduleName,
},
Annotations: map[string]string{
configAnnotationKey: configAnnotationValue,
modulesOrderKey: modulesOrderValue},
modulesOrderKey: modulesOrderValue,
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
Expand Down
8 changes: 7 additions & 1 deletion internal/utils/podhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ func (ph *podHelper) IsPodChanged(existingPod *v1.Pod, newPod *v1.Pod) (bool, er
}

func (ph *podHelper) PodLabels(modName string, targetKernel string, podType string) map[string]string {
return moduleKernelLabels(modName, targetKernel, podType)
labels := moduleKernelLabels(modName, targetKernel, podType)

labels["app.kubernetes.io/name"] = "kmm"
labels["app.kubernetes.io/component"] = podType
labels["app.kubernetes.io/part-of"] = "kmm"

return labels
}

func (ph *podHelper) GetModulePodByKernel(ctx context.Context, modName, namespace, targetKernel, podType string, owner metav1.Object) (*v1.Pod, error) {
Expand Down
13 changes: 10 additions & 3 deletions internal/utils/podhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ var _ = Describe("PodLabels", func() {
mgr := NewPodHelper(clnt)
labels := mgr.PodLabels(mod.Name, "targetKernel", "podType")

Expect(labels).To(HaveKeyWithValue(constants.ModuleNameLabel, "moduleName"))
Expect(labels).To(HaveKeyWithValue(constants.TargetKernelTarget, "targetKernel"))
Expect(labels).To(HaveKeyWithValue(constants.PodType, "podType"))
expected := map[string]string{
"app.kubernetes.io/name": "kmm",
"app.kubernetes.io/component": "podType",
"app.kubernetes.io/part-of": "kmm",
constants.ModuleNameLabel: "moduleName",
constants.TargetKernelTarget: "targetKernel",
constants.PodType: "podType",
}

Expect(labels).To(Equal(expected))
})
})

Expand Down

0 comments on commit 3f05a76

Please sign in to comment.