11/*
2- SPDX-FileCopyrightText: Copyright 2024 SAP SE or an SAP affiliate company and cobaltcore-dev contributors
2+ SPDX-FileCopyrightText: Copyright 2026 SAP SE or an SAP affiliate company and cobaltcore-dev contributors
33SPDX-License-Identifier: Apache-2.0
44
55Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,7 +36,7 @@ import (
3636 kvmv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
3737)
3838
39- var _ = Describe ("Decommission Controller" , func () {
39+ var _ = Describe ("Offboarding Controller" , func () {
4040 const (
4141 EOF = "EOF"
4242 serviceId = "service-1234"
@@ -45,10 +45,10 @@ var _ = Describe("Decommission Controller", func() {
4545 )
4646
4747 var (
48- decommissionReconciler * NodeDecommissionReconciler
49- resourceName = types.NamespacedName {Name : hypervisorName }
50- reconcileReq = ctrl.Request {NamespacedName : resourceName }
51- fakeServer testhelper.FakeServer
48+ offboardingReconciler * HypervisorOffboardingReconciler
49+ resourceName = types.NamespacedName {Name : hypervisorName }
50+ reconcileReq = ctrl.Request {NamespacedName : resourceName }
51+ fakeServer testhelper.FakeServer
5252 )
5353
5454 BeforeEach (func (ctx SpecContext ) {
@@ -67,8 +67,8 @@ var _ = Describe("Decommission Controller", func() {
6767 os .Unsetenv ("KVM_HA_SERVICE_URL" )
6868 })
6969
70- By ("Creating the NodeDecommissionReconciler " )
71- decommissionReconciler = & NodeDecommissionReconciler {
70+ By ("Creating the HypervisorOffboardingReconciler " )
71+ offboardingReconciler = & HypervisorOffboardingReconciler {
7272 Client : k8sClient ,
7373 Scheme : k8sClient .Scheme (),
7474 computeClient : client .ServiceClient (fakeServer ),
@@ -101,7 +101,7 @@ var _ = Describe("Decommission Controller", func() {
101101 Context ("When marking the hypervisor terminating" , func () {
102102 JustBeforeEach (func (ctx SpecContext ) {
103103 By ("Reconciling first to add the finalizer" )
104- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
104+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
105105 Expect (err ).NotTo (HaveOccurred ())
106106
107107 By ("Marking the hypervisor for termination" )
@@ -176,7 +176,7 @@ var _ = Describe("Decommission Controller", func() {
176176 })
177177
178178 It ("should set the hypervisor ready condition" , func (ctx SpecContext ) {
179- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
179+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
180180 Expect (err ).NotTo (HaveOccurred ())
181181
182182 hypervisor := & kvmv1.Hypervisor {}
@@ -185,14 +185,14 @@ var _ = Describe("Decommission Controller", func() {
185185 SatisfyAll (
186186 HaveField ("Type" , kvmv1 .ConditionTypeReady ),
187187 HaveField ("Status" , metav1 .ConditionFalse ),
188- HaveField ("Reason" , "Decommissioning " ),
188+ HaveField ("Reason" , "Offboarding " ),
189189 ),
190190 ))
191191 })
192192
193193 It ("should set the hypervisor offboarded condition" , func (ctx SpecContext ) {
194194 for range 3 {
195- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
195+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
196196 Expect (err ).NotTo (HaveOccurred ())
197197 }
198198 Expect (getHypervisorsCalled ).To (BeNumerically (">" , 0 ))
@@ -227,8 +227,8 @@ var _ = Describe("Decommission Controller", func() {
227227 hypervisor .Status .HypervisorID = "c48f6247-abe4-4a24-824e-ea39e108874f"
228228 Expect (k8sClient .Status ().Update (ctx , hypervisor )).To (Succeed ())
229229
230- By ("Reconciling - decommission controller will wait for aggregates to be cleared" )
231- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
230+ By ("Reconciling - offboarding controller will wait for aggregates to be cleared" )
231+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
232232 Expect (err ).NotTo (HaveOccurred ())
233233
234234 By ("Simulating aggregates controller clearing aggregates" )
@@ -238,21 +238,21 @@ var _ = Describe("Decommission Controller", func() {
238238
239239 By ("Reconciling again after aggregates are cleared" )
240240 for range 3 {
241- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
241+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
242242 Expect (err ).NotTo (HaveOccurred ())
243243 }
244244
245245 By ("Verifying Status.Aggregates is empty" )
246246 Expect (k8sClient .Get (ctx , resourceName , hypervisor )).To (Succeed ())
247- Expect (hypervisor .Status .Aggregates ).To (BeEmpty (), "Status.Aggregates should be cleared after decommissioning " )
247+ Expect (hypervisor .Status .Aggregates ).To (BeEmpty (), "Status.Aggregates should be cleared after offboarding " )
248248 })
249249 })
250250 })
251251 })
252252
253253 Context ("Guard Conditions" , func () {
254254 JustBeforeEach (func (ctx SpecContext ) {
255- result , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
255+ result , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
256256 Expect (err ).NotTo (HaveOccurred ())
257257 Expect (result ).To (Equal (ctrl.Result {}))
258258 })
@@ -291,14 +291,14 @@ var _ = Describe("Decommission Controller", func() {
291291 })
292292
293293 Context ("Failure Modes" , func () {
294- var sharedDecommissioningErrorCheck = func (ctx SpecContext , expectedMessageSubstring string ) {
294+ var sharedOffboardingErrorCheck = func (ctx SpecContext , expectedMessageSubstring string ) {
295295 hypervisor := & kvmv1.Hypervisor {}
296296 Expect (k8sClient .Get (ctx , resourceName , hypervisor )).To (Succeed ())
297297 Expect (hypervisor .Status .Conditions ).To (ContainElement (
298298 SatisfyAll (
299299 HaveField ("Type" , kvmv1 .ConditionTypeReady ),
300300 HaveField ("Status" , metav1 .ConditionFalse ),
301- HaveField ("Reason" , "Decommissioning " ),
301+ HaveField ("Reason" , "Offboarding " ),
302302 HaveField ("Message" , ContainSubstring (expectedMessageSubstring )),
303303 ),
304304 ))
@@ -320,10 +320,10 @@ var _ = Describe("Decommission Controller", func() {
320320 })
321321 })
322322
323- It ("should set decommissioning condition with error" , func (ctx SpecContext ) {
324- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
323+ It ("should set offboarding condition with error" , func (ctx SpecContext ) {
324+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
325325 Expect (err ).NotTo (HaveOccurred ())
326- sharedDecommissioningErrorCheck (ctx , "" )
326+ sharedOffboardingErrorCheck (ctx , "" )
327327 })
328328 })
329329
@@ -352,10 +352,10 @@ var _ = Describe("Decommission Controller", func() {
352352 })
353353 })
354354
355- It ("should set decommissioning condition about running VMs" , func (ctx SpecContext ) {
356- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
355+ It ("should set offboarding condition about running VMs" , func (ctx SpecContext ) {
356+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
357357 Expect (err ).NotTo (HaveOccurred ())
358- sharedDecommissioningErrorCheck (ctx , "still has 2 running VMs" )
358+ sharedOffboardingErrorCheck (ctx , "still has 2 running VMs" )
359359 })
360360 })
361361
@@ -391,9 +391,9 @@ var _ = Describe("Decommission Controller", func() {
391391 })
392392
393393 It ("should wait for aggregates to be cleared" , func (ctx SpecContext ) {
394- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
394+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
395395 Expect (err ).NotTo (HaveOccurred ())
396- sharedDecommissioningErrorCheck (ctx , "Waiting for aggregates to be removed" )
396+ sharedOffboardingErrorCheck (ctx , "Waiting for aggregates to be removed" )
397397 })
398398 })
399399
@@ -424,10 +424,10 @@ var _ = Describe("Decommission Controller", func() {
424424 })
425425 })
426426
427- It ("should set decommissioning condition with error" , func (ctx SpecContext ) {
428- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
427+ It ("should set offboarding condition with error" , func (ctx SpecContext ) {
428+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
429429 Expect (err ).NotTo (HaveOccurred ())
430- sharedDecommissioningErrorCheck (ctx , "cannot delete service" )
430+ sharedOffboardingErrorCheck (ctx , "cannot delete service" )
431431 })
432432 })
433433
@@ -462,10 +462,10 @@ var _ = Describe("Decommission Controller", func() {
462462 })
463463 })
464464
465- It ("should set decommissioning condition with error" , func (ctx SpecContext ) {
466- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
465+ It ("should set offboarding condition with error" , func (ctx SpecContext ) {
466+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
467467 Expect (err ).NotTo (HaveOccurred ())
468- sharedDecommissioningErrorCheck (ctx , "cannot get resource provider" )
468+ sharedOffboardingErrorCheck (ctx , "cannot get resource provider" )
469469 })
470470 })
471471
@@ -512,10 +512,10 @@ var _ = Describe("Decommission Controller", func() {
512512 })
513513 })
514514
515- It ("should set decommissioning condition with error" , func (ctx SpecContext ) {
516- _ , err := decommissionReconciler .Reconcile (ctx , reconcileReq )
515+ It ("should set offboarding condition with error" , func (ctx SpecContext ) {
516+ _ , err := offboardingReconciler .Reconcile (ctx , reconcileReq )
517517 Expect (err ).NotTo (HaveOccurred ())
518- sharedDecommissioningErrorCheck (ctx , "cannot clean up resource provider" )
518+ sharedOffboardingErrorCheck (ctx , "cannot clean up resource provider" )
519519 })
520520 })
521521 })
0 commit comments