Skip to content

Commit 3f0fccf

Browse files
committed
cleanup of code
Signed-off-by: Ashima-Ashima1 <[email protected]>
1 parent cd71dc7 commit 3f0fccf

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

controllers/ibmobjectcsi_controller.go

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,11 @@ func (r *IBMObjectCSIReconciler) Reconcile(ctx context.Context, req ctrl.Request
128128
}
129129
// If the deletion timestamp is set, perform cleanup operations and remove a finalizer before returning from the reconciliation process.
130130
if !instance.GetDeletionTimestamp().IsZero() {
131-
isFinalizerExists, err := r.ControllerHelper.HasFinalizer(instance)
132-
if err != nil {
131+
if err := r.deleteClusterRoleBindings(instance); err != nil {
133132
return reconcile.Result{}, err
134133
}
135-
// If the finalizer doesn't exist, return early, indicating that no further action is needed.
136-
137-
if !isFinalizerExists {
138-
return reconcile.Result{}, nil
139-
}
140134

141-
if err := r.deleteClusterRolesAndBindings(instance); err != nil {
135+
if err := r.deleteClusterRoles(instance); err != nil {
142136
return reconcile.Result{}, err
143137
}
144138

@@ -460,17 +454,6 @@ func (r *IBMObjectCSIReconciler) deleteCSIDriver(instance *crutils.IBMObjectCSI)
460454
return nil
461455
}
462456

463-
func (r *IBMObjectCSIReconciler) deleteClusterRolesAndBindings(instance *crutils.IBMObjectCSI) error {
464-
if err := r.deleteClusterRoleBindings(instance); err != nil {
465-
return err
466-
}
467-
468-
if err := r.deleteClusterRoles(instance); err != nil {
469-
return err
470-
}
471-
return nil
472-
}
473-
474457
func (r *IBMObjectCSIReconciler) deleteClusterRoleBindings(instance *crutils.IBMObjectCSI) error {
475458
clusterRoleBindings := r.getClusterRoleBindings(instance)
476459
return r.ControllerHelper.DeleteClusterRoleBindings(clusterRoleBindings)

controllers/util/common/common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,6 @@ func (ch *ControllerHelper) getClusterRole(cr *rbacv1.ClusterRole) (*rbacv1.Clus
178178
return found, err
179179
}
180180

181-
func (ch *ControllerHelper) HasFinalizer(instance crutils.Instance) (bool, error) {
182-
accessor, finalizerName, err := ch.getAccessorAndFinalizerName(instance)
183-
if err != nil {
184-
return false, err
185-
}
186-
187-
return util.Contains(accessor.GetFinalizers(), finalizerName), nil
188-
}
189-
190181
func (ch *ControllerHelper) AddFinalizerIfNotPresent(instance crutils.Instance,
191182
unwrappedInstance client.Object) error {
192183
logger := ch.Log.WithName("AddFinalizerIfNotPresent")

0 commit comments

Comments
 (0)