Skip to content

Commit

Permalink
test: delete GAR repositories on teardown (#1392)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdowell authored Aug 14, 2024
1 parent 51f958d commit d501221
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions e2e/nomostest/registryproviders/artifact_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d501221

Please sign in to comment.