@@ -203,11 +203,8 @@ var _ = Describe("StackitCluster Controller", func() {
203203 })
204204
205205 It ("cleans up bastion resources during deletion even when bastion status was never persisted" , func () {
206- // The cloud-cleanup block used to be gated on persisted status for the
207- // bastion, while the load balancer was gated on its spec flag. A bastion
208- // created without its status patch landing (process restart, conflict)
209- // therefore skipped cleanup entirely and leaked server, public IP and
210- // security group.
206+ // A bastion whose status patch never landed must still be cleaned up, so
207+ // cleanup follows the spec flag rather than persisted status.
211208 createOwnerCluster (ctx , clusterName + "-nolb" )
212209 defer deleteIfExists (ctx , & clusterv1.Cluster {
213210 ObjectMeta : metav1.ObjectMeta {Name : clusterName + "-nolb" , Namespace : namespace },
@@ -247,10 +244,8 @@ var _ = Describe("StackitCluster Controller", func() {
247244 })
248245
249246 It ("finalizes deletion when the credentials Secret is already gone" , func () {
250- // A missing credentials Secret cannot be recovered from, and it commonly
251- // disappears first during namespace teardown. Broadening the delete gate
252- // to spec.Bastion.Enabled made a working cloud client mandatory for every
253- // bastion cluster, which would strand such a cluster in Terminating.
247+ // The Secret commonly disappears first during namespace teardown, and
248+ // without it no cloud client can be built at all.
254249 createOwnerCluster (ctx , clusterName + "-nocreds" )
255250 defer deleteIfExists (ctx , & clusterv1.Cluster {
256251 ObjectMeta : metav1.ObjectMeta {Name : clusterName + "-nocreds" , Namespace : namespace },
@@ -284,10 +279,8 @@ var _ = Describe("StackitCluster Controller", func() {
284279 })
285280
286281 It ("tears the bastion down when disabled even if its status was never persisted" , func () {
287- // Counterpart to the deletion path: disabling the bastion used to be
288- // gated on hasBastionStatus alone. With the status lost, nothing was torn
289- // down while the condition reported "bastion disabled" — leaving port 22
290- // open for the rest of the cluster's life.
282+ // With the status lost, a status-gated teardown would report the bastion
283+ // as disabled while leaving port 22 open.
291284 got := & infrav1.StackitCluster {}
292285 Expect (k8sClient .Get (ctx , stackitKey , got )).To (Succeed ())
293286 got .Spec .Bastion = validBastionSpec ()
@@ -316,8 +309,7 @@ var _ = Describe("StackitCluster Controller", func() {
316309
317310 It ("tears the bastion down when disabled even if only its status was lost" , func () {
318311 // Narrower than the case above: the condition survives and still reports
319- // the bastion as available, only the bastion status fields are gone.
320- // Gating the cleanup on hasBastionStatus left the server running here.
312+ // the bastion as available, only the status fields are gone.
321313 got := & infrav1.StackitCluster {}
322314 Expect (k8sClient .Get (ctx , stackitKey , got )).To (Succeed ())
323315 got .Spec .Bastion = validBastionSpec ()
@@ -345,10 +337,8 @@ var _ = Describe("StackitCluster Controller", func() {
345337 })
346338
347339 It ("cleans up the load balancer during deletion when it was disabled and its status was lost" , func () {
348- // Counterpart to the bastion case: flipping apiServerLoadBalancer.enabled
349- // off neither deletes the load balancer nor clears its ID, so with the
350- // status patch lost the deletion gate matched nothing and the load
351- // balancer stayed behind.
340+ // Flipping apiServerLoadBalancer.enabled off neither deletes the load
341+ // balancer nor clears its ID, so deletion cannot rely on either.
352342 _ , err := reconciler .Reconcile (ctx , request )
353343 Expect (err ).NotTo (HaveOccurred ())
354344 Expect (fakeCloud .LoadBalancerCount ()).To (Equal (1 ))
@@ -595,12 +585,8 @@ var _ = Describe("StackitCluster Controller", func() {
595585 }).Should (BeTrue ())
596586 })
597587
598- // AddFinalizer only mutated the object in memory, and the write to etcd
599- // happened in the deferred PatchObject at the end of Reconcile — after the
600- // load balancer and the bastion had been created. A process dying in between
601- // left those resources behind an object with no finalizer to clean them up.
602- // GetNetwork is the first cloud call of the reconcile, so a hook there
603- // proves the ordering rather than only the end result.
588+ // GetNetwork is the first cloud call of the reconcile, so a hook there proves
589+ // the ordering rather than only the end result.
604590 It ("persists the finalizer before the first cloud call" , func () {
605591 var finalizersAtFirstCall []string
606592 fakeCloud .BeforeGetNetwork = func () {
@@ -617,13 +603,10 @@ var _ = Describe("StackitCluster Controller", func() {
617603 "cloud resources were created while the API server had no finalizer to clean them up" )
618604 })
619605
620- // The finalizer used to go away regardless of remaining Machines. Their
621- // controllers reach credentials and project context through this
622- // StackitCluster, so once it is gone they can neither delete their servers
623- // nor drop their own finalizers — the VMs are orphaned and the Machines
624- // hang. Cluster API orders this correctly when the deletion starts at the
625- // Cluster, but a namespace teardown or a direct delete of this object
626- // bypasses that ordering.
606+ // Machine controllers reach credentials and project context through this
607+ // StackitCluster, so it has to outlive them. Cluster API orders this
608+ // correctly when deletion starts at the Cluster, but a namespace teardown or
609+ // a direct delete of this object bypasses that ordering.
627610 It ("keeps the finalizer while Machines still exist for the cluster" , func () {
628611 _ , err := reconciler .Reconcile (ctx , request )
629612 Expect (err ).NotTo (HaveOccurred ())
0 commit comments