From d5012210e0c135ec1bd790bc8afcb39d59553e77 Mon Sep 17 00:00:00 2001 From: Sam Dowell Date: Tue, 13 Aug 2024 17:19:26 -0700 Subject: [PATCH] test: delete GAR repositories on teardown (#1392) Some side effects have been noticed in the periodic jobs, such as an image never getting deleted if the cleanup fails on a prior execution. As an example this can cause TestHelmLatestVersion to become flaky, since the 3.0.0 helm chart already exists before the test starts. Tearing down the entire GAR repository allows the periodic jobs to self heal side effects after a failed cleanup. --- .../registryproviders/artifact_registry.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/e2e/nomostest/registryproviders/artifact_registry.go b/e2e/nomostest/registryproviders/artifact_registry.go index 1d2c2c284f..bc851cf37f 100644 --- a/e2e/nomostest/registryproviders/artifact_registry.go +++ b/e2e/nomostest/registryproviders/artifact_registry.go @@ -61,9 +61,18 @@ func (a *ArtifactRegistryProvider) Type() string { } // Teardown preforms teardown -// Does nothing currently. We may want to have this delete the repository to -// minimize side effects. +// This deletes the repository to prevent side effects across executions. func (a *ArtifactRegistryProvider) Teardown() error { + out, err := a.gcloudClient.Gcloud("artifacts", "repositories", + "delete", a.repositoryName, + "--quiet", + "--location", a.location, + "--project", a.project) + if err != nil { + if !strings.Contains(string(out), "NOT_FOUND") { + return fmt.Errorf("failed to delete repository: %w", err) + } + } return nil }