Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 63c7821

Browse files
committed
Remove finalizer in controller
1 parent 3ffbb6a commit 63c7821

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

pkg/controller/istiocontrolplane/istiocontrolplane_controller.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ func (r *ReconcileIstioControlPlane) Reconcile(request reconcile.Request) (recon
111111
return reconcile.Result{}, err
112112
}
113113
deleted := u.GetDeletionTimestamp() != nil
114-
finalizers := u.GetFinalizers()
115-
finalizerIndex := indexOf(finalizers, finalizer)
116114

117115
// declare read-only icp instance to create the reconciler
118116
icp := &v1alpha2.IstioControlPlane{}
@@ -132,48 +130,13 @@ func (r *ReconcileIstioControlPlane) Reconcile(request reconcile.Request) (recon
132130
log.Infof("Got IstioControlPlaneSpec: \n\n%s\n", string(os))
133131

134132
if deleted {
135-
if finalizerIndex < 0 {
136-
log.Info("IstioControlPlane deleted")
137-
return reconcile.Result{}, nil
138-
}
139-
log.Info("Deleting IstioControlPlane")
140-
141133
reconciler, err := r.factory.New(icp, r.client)
142134
if err == nil {
143135
err = reconciler.Delete()
144136
} else {
145137
log.Errorf("failed to create reconciler: %s", err)
146138
}
147-
// TODO: for now, nuke the resources, regardless of errors
148-
finalizers = append(finalizers[:finalizerIndex], finalizers[finalizerIndex+1:]...)
149-
u.SetFinalizers(finalizers)
150-
finalizerError := r.client.Update(context.TODO(), u)
151-
for retryCount := 0; errors.IsConflict(finalizerError) && retryCount < finalizerMaxRetries; retryCount++ {
152-
// workaround for https://github.com/kubernetes/kubernetes/issues/73098 for k8s < 1.14
153-
// TODO: make this error message more meaningful.
154-
log.Info("conflict during finalizer removal, retrying")
155-
_ = r.client.Get(context.TODO(), request.NamespacedName, u)
156-
finalizers = u.GetFinalizers()
157-
finalizerIndex = indexOf(finalizers, finalizer)
158-
finalizers = append(finalizers[:finalizerIndex], finalizers[finalizerIndex+1:]...)
159-
u.SetFinalizers(finalizers)
160-
finalizerError = r.client.Update(context.TODO(), u)
161-
}
162-
if finalizerError != nil {
163-
log.Errorf("error removing finalizer: %s", finalizerError)
164-
return reconcile.Result{}, finalizerError
165-
}
166139
return reconcile.Result{}, err
167-
} else if finalizerIndex < 0 {
168-
// TODO: make this error message more meaningful.
169-
log.Infof("Adding finalizer %v", finalizer)
170-
finalizers = append(finalizers, finalizer)
171-
u.SetFinalizers(finalizers)
172-
err = r.client.Update(context.TODO(), u)
173-
if err != nil {
174-
log.Errorf("Failed to update IstioControlPlane with finalizer, %v", err)
175-
return reconcile.Result{}, err
176-
}
177140
}
178141

179142
log.Info("Updating IstioControlPlane")

0 commit comments

Comments
 (0)