From dc4bf7ec366008c0d949781610c4cf6df91a7ea6 Mon Sep 17 00:00:00 2001 From: Amir Balaie Date: Wed, 30 Oct 2024 15:45:31 -0700 Subject: [PATCH] chore: fixing lint-check version and cleaning up e2e test pods --- .github/workflows/lint-markdown-links.yml | 2 +- internal/k8s.go | 2 +- internal/noCloudResources.go | 12 ++++++++++++ internal/resourceApplied.go | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-markdown-links.yml b/.github/workflows/lint-markdown-links.yml index d179022..2766157 100644 --- a/.github/workflows/lint-markdown-links.yml +++ b/.github/workflows/lint-markdown-links.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: gaurav-nelson/github-action-markdown-link-check@v1 + - uses: gaurav-nelson/github-action-markdown-link-check@d53a906aa6b22b8979d33bc86170567e619495ec with: use-verbose-mode: 'no' config-file: '.mlc.config.json' diff --git a/internal/k8s.go b/internal/k8s.go index 62ed51f..428716a 100644 --- a/internal/k8s.go +++ b/internal/k8s.go @@ -172,7 +172,7 @@ func (c *k8sClient) List(ctx context.Context, kind, namespace, labelSelector str params = append(params, "-n", namespace) } if labelSelector != "" { - params = append(params, "-l", "'"+labelSelector+"'") + params = append(params, "-l", labelSelector) } params = append(params, "-o", "json") diff --git a/internal/noCloudResources.go b/internal/noCloudResources.go index 3deb483..211f24c 100644 --- a/internal/noCloudResources.go +++ b/internal/noCloudResources.go @@ -9,6 +9,18 @@ import ( func noCloudResources(ctx context.Context) error { kfrCtx := KfrFromContext(ctx) + + // First deleting pods that are created for E2E tests so they don't block PVC, PV and NfsVolume deletion + podsForE2ETests, err := kfrCtx.K8S.List(ctx, "pods", "-A", "context=cloud-manager-tests") + if err != nil { + return err + } + for _, pod := range podsForE2ETests { + if err := kfrCtx.K8S.Delete(ctx, "pods", pod.Name, pod.Namespace, false); err != nil { + return fmt.Errorf("error deleting pod %s/%s: %w", pod.Namespace, pod.Name, err) + } + } + kinds, err := kfrCtx.K8S.CloudResourceKinds(ctx) if err != nil { return err diff --git a/internal/resourceApplied.go b/internal/resourceApplied.go index 81327f1..0211e3f 100644 --- a/internal/resourceApplied.go +++ b/internal/resourceApplied.go @@ -56,6 +56,9 @@ func resourceApplied(ctx context.Context, ref string, txt *godog.DocString) erro return errors.New("zero length kind") } + // set context label to all resources + err = unstructured.SetNestedField(val, map[string]interface{}{"context": "cloud-manager-tests"}, "metadata", "labels") + if len(ref) > 0 { rd = kfrCtx.Get(ref) if rd == nil {