Skip to content

Commit 8080f67

Browse files
committed
DecomissionController: Wait for eviction condition
It doesn't make sense to poll openstack for the hypervisors, when we are still evicting.
1 parent c822237 commit 8080f67

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

internal/controller/decomission_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ func (r *NodeDecommissionReconciler) Reconcile(ctx context.Context, req ctrl.Req
7878
return ctrl.Result{}, nil
7979
}
8080

81-
log.Info("removing host from nova")
81+
if !meta.IsStatusConditionFalse(hv.Status.Conditions, kvmv1.ConditionTypeEvicting) {
82+
// Either has not evicted yet, or is still evicting VMs, so we have to wait for that to finish
83+
return ctrl.Result{}, nil
84+
}
8285

8386
hypervisor, err := openstack.GetHypervisorByName(ctx, r.computeClient, hostname, true)
8487
if errors.Is(err, openstack.ErrNoHypervisor) {

internal/controller/decomission_controller_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ var _ = Describe("Decommission Controller", func() {
135135
Expect(k8sClient.Status().Update(ctx, hypervisor)).To(Succeed())
136136
})
137137

138-
When("the hypervisor was set to ready", func() {
138+
When("the hypervisor was set to ready and has been evicted", func() {
139139
getHypervisorsCalled := 0
140140
BeforeEach(func(ctx SpecContext) {
141141
hv := &kvmv1.Hypervisor{}
@@ -148,6 +148,12 @@ var _ = Describe("Decommission Controller", func() {
148148
Message: "dontcare",
149149
},
150150
)
151+
meta.SetStatusCondition(&hv.Status.Conditions, metav1.Condition{
152+
Type: kvmv1.ConditionTypeEvicting,
153+
Status: metav1.ConditionFalse,
154+
Reason: "dontcare",
155+
Message: "dontcare",
156+
})
151157
Expect(k8sClient.Status().Update(ctx, hv)).To(Succeed())
152158

153159
fakeServer.Mux.HandleFunc("GET /os-hypervisors/detail", func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)