Skip to content

Commit d8fd2d5

Browse files
committed
fix(chore): address comments from review
Signed-off-by: Piotr Skamruk <piotr.skamruk@gmail.com>
1 parent 479d69f commit d8fd2d5

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

docs/user-guides/cluster/offboarding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Off-board a `Cluster` in Greenhouse is initiated by calling the command:
3737
kubectl --namespace=<greenhouse-organization-name> delete cluster <cluster-name>
3838
```
3939

40-
Another option to trigger `Cluster` off-boarding is manual deleting the cluster `Secret`, what can be done by calling the command:
40+
Another option to trigger `Cluster` off-boarding is manually deleting the cluster `Secret`, which can be done by calling the command:
4141
```shell
4242
kubectl --namespace=<greenhouse-organization-name> delete secret <cluster-name>
4343
```

e2e/cluster/e2e_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,16 @@ var _ = Describe("Cluster E2E", Ordered, func() {
140140
By("getting cluster secret")
141141
secret := &corev1.Secret{}
142142
err := adminClient.Get(ctx, client.ObjectKey{Name: remoteClusterHName, Namespace: env.TestNamespace}, secret)
143-
if apierrors.IsNotFound(err) {
144-
return
145-
}
146143
Expect(err).NotTo(HaveOccurred())
147144

148145
By("removing the secret resource")
149146
err = adminClient.Delete(ctx, secret)
150-
Expect(err).NotTo(HaveOccurred())
147+
Expect(err).NotTo(HaveOccurred(), "cluster secret should exist")
151148

152149
By("checking the cluster resource is eventually deleted")
153150
cluster := &greenhousev1alpha1.Cluster{}
154151
Eventually(func(g Gomega) {
155-
err := adminClient.Get(ctx, client.ObjectKey{Name: name, Namespace: namespace}, cluster)
152+
err := adminClient.Get(ctx, client.ObjectKey{Name: remoteClusterHName, Namespace: env.TestNamespace}, cluster)
156153
g.Expect(apierrors.IsNotFound(err)).To(BeTrue(), "cluster resource should be deleted")
157154
}).Should(Succeed(), "cluster resource should be deleted")
158155
})

internal/controller/cluster/bootstrap_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (r *BootstrapReconciler) requestClusterDeletion(ctx context.Context, namesp
226226
if err := r.Get(ctx, namespacedName, &cluster); err != nil {
227227
return client.IgnoreNotFound(err)
228228
}
229-
log.FromContext(ctx).Info("KubeConfig secret for Cluster %s not found, requesting Cluster deletion", namespacedName.String())
229+
log.FromContext(ctx).Info("Cluster secret not found, requesting Cluster deletion", "cluster", namespacedName.String())
230230
return client.IgnoreNotFound(r.Delete(ctx, &cluster))
231231
}
232232

internal/controller/cluster/bootstrap_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var _ = Describe("Bootstrap controller", Ordered, func() {
140140
By("Deleting the kubeconfig secret and checking the cluster is deleted")
141141
test.MustDeleteCluster(test.Ctx, test.K8sClient, cluster)
142142
})
143-
It("Should remove cluster when secret disapears", func() {
143+
It("Should remove cluster when secret disappears", func() {
144144
By("Creating a kubeconfig secret with label")
145145
kubeConfigSecret := setup.CreateSecret(test.Ctx, bootstrapTestCase+"-secret-removal",
146146
test.WithSecretType(greenhouseapis.SecretTypeKubeConfig),
@@ -157,9 +157,9 @@ var _ = Describe("Bootstrap controller", Ordered, func() {
157157
test.MustDeleteSecret(test.Ctx, test.K8sClient, kubeConfigSecret)
158158

159159
Eventually(func(g Gomega) bool {
160-
g.Expect(apierrors.IsNotFound(test.K8sClient.Get(test.Ctx, id, cluster))).Should(BeTrue(), "the cluster should have been created")
160+
g.Expect(apierrors.IsNotFound(test.K8sClient.Get(test.Ctx, id, cluster))).Should(BeTrue(), "the cluster should be deleted")
161161
return true
162-
}).Should(BeTrue(), "getting the cluster should succeed eventually")
162+
}).Should(BeTrue(), "the cluster should be deleted eventually")
163163
})
164164
})
165165
})

0 commit comments

Comments
 (0)