From b7befc1cb521001a21181188237c12430f5894ae Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Mon, 13 Nov 2023 21:16:53 -0600 Subject: [PATCH] Don't get cluster --full when attempting leak cleanup If a job's --down was interrupted, the state store can be in an inconsistent state. This can cause `kops get cluster --full` to fail if certain additional objects are missing, yet `kops get cluster` would succeed. We omit `--full` to ensure `kops get cluster` succeeds and leak cleanup is reattempted. --- tests/e2e/kubetest2-kops/deployer/down.go | 2 +- tests/e2e/pkg/kops/state.go | 7 +++++-- tests/e2e/pkg/tester/tester.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/e2e/kubetest2-kops/deployer/down.go b/tests/e2e/kubetest2-kops/deployer/down.go index d74f4bdd7f0b0..ca9f48b5fa008 100644 --- a/tests/e2e/kubetest2-kops/deployer/down.go +++ b/tests/e2e/kubetest2-kops/deployer/down.go @@ -33,7 +33,7 @@ func (d *deployer) Down() error { } // There is no point running the rest of this function if the cluster doesn't exist - cluster, _ := kops.GetCluster(d.KopsBinaryPath, d.ClusterName, nil) + cluster, _ := kops.GetCluster(d.KopsBinaryPath, d.ClusterName, nil, false) if cluster == nil { return nil } diff --git a/tests/e2e/pkg/kops/state.go b/tests/e2e/pkg/kops/state.go index e5b14fb115ebe..0b3ddd12b5c1f 100644 --- a/tests/e2e/pkg/kops/state.go +++ b/tests/e2e/pkg/kops/state.go @@ -29,9 +29,12 @@ import ( ) // GetCluster will retrieve the specified Cluster from the state store. -func GetCluster(kopsBinary, clusterName string, env []string) (*api.Cluster, error) { +func GetCluster(kopsBinary, clusterName string, env []string, full bool) (*api.Cluster, error) { args := []string{ - kopsBinary, "get", "cluster", clusterName, "-ojson", "--full", + kopsBinary, "get", "cluster", clusterName, "-ojson", + } + if full { + args = append(args, "--full") } c := exec.Command(args[0], args[1:]...) c.SetEnv(env...) diff --git a/tests/e2e/pkg/tester/tester.go b/tests/e2e/pkg/tester/tester.go index 88ac260a8786d..111d1b1be0142 100644 --- a/tests/e2e/pkg/tester/tester.go +++ b/tests/e2e/pkg/tester/tester.go @@ -107,7 +107,7 @@ func (t *Tester) getKopsCluster() (*api.Cluster, error) { kopsClusterName := currentContext - cluster, err := kops.GetCluster("kops", kopsClusterName, nil) + cluster, err := kops.GetCluster("kops", kopsClusterName, nil, true) if err != nil { return nil, err }