@@ -47,10 +47,28 @@ func e2e(
4747 Status string `json:"status"`
4848 }
4949 replicatedCluster := ReplicatedCluster {}
50- if err := json .Unmarshal ([]byte (out ), & replicatedCluster ); err != nil {
50+ err = json .Unmarshal ([]byte (out ), & replicatedCluster )
51+ if err != nil {
5152 return fmt .Errorf ("failed to unmarshal cluster: %w" , err )
5253 }
5354
55+ // Defer cluster deletion if we got a cluster ID
56+ if replicatedCluster .ID != "" {
57+ defer func () {
58+ fmt .Printf ("Cleaning up cluster %s of distribution %s and version %s...\n " , replicatedCluster .ID , distribution , version )
59+ cleanupCtr := dag .Container ().From ("replicated/vendor-cli:latest" ).
60+ WithSecretVariable ("REPLICATED_API_TOKEN" , replicatedServiceAccount ).
61+ WithExec ([]string {"/replicated" , "cluster" , "rm" , replicatedCluster .ID })
62+
63+ cleanupOut , cleanupErr := cleanupCtr .Stdout (ctx )
64+ if cleanupErr != nil {
65+ fmt .Printf ("Warning: failed to delete cluster %s of distribution %s and version %s: %v\n " , replicatedCluster .ID , distribution , version , cleanupErr )
66+ } else {
67+ fmt .Printf ("Successfully deleted cluster %s of distribution %s and version %s: %s\n " , replicatedCluster .ID , distribution , version , cleanupOut )
68+ }
69+ }()
70+ }
71+
5472 // get the kubeconfig
5573 ctr = dag .Container ().From ("replicated/vendor-cli:latest" ).
5674 WithSecretVariable ("REPLICATED_API_TOKEN" , replicatedServiceAccount ).
@@ -631,7 +649,7 @@ spec:
631649 var allImagesSet map [string ]struct {}
632650 // Now we expect both the alpine/curl from default namespace AND busybox from kube-system
633651 nowRequired := []string {
634- "docker.io/alpine/curl:latest" , // from replicated-ssl-test in default namespace
652+ "docker.io/alpine/curl:latest" , // from replicated-ssl-test in default namespace
635653 "docker.io/library/busybox:latest" , // from kube-system namespace
636654 }
637655 maxAttempts := 5
0 commit comments