Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete deletion of CnsFileAccessConfig instance if associated nodeVM instance is not found #3151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,27 @@ func (r *ReconcileCnsFileAccessConfig) Reconcile(ctx context.Context,
msg := fmt.Sprintf("Failed to get virtualmachine instance for the VM with name: %q. Error: %+v",
instance.Spec.VMName, err)
log.Error(msg)
// If virtualmachine instance is NotFound and if deletion timestamp is set on CnsFileAccessConfig instance,
// then proceed with the deletion of CnsFileAccessConfig instance.
if apierrors.IsNotFound(err) && instance.DeletionTimestamp != nil {
log.Infof("CnsFileAccessConfig instance %q has deletion timestamp set, but VM instance with "+
"name %q is not found. Processing the deletion of CnsFileAccessConfig instance.",
instance.Name, instance.Spec.VMName)
removeFinalizerFromCRDInstance(ctx, instance)
err = updateCnsFileAccessConfig(ctx, r.client, instance)
if err != nil {
msg := fmt.Sprintf("failed to update CnsFileAccessConfig instance: %q on namespace: %q. Error: %+v",
instance.Name, instance.Namespace, err)
recordEvent(ctx, r, instance, v1.EventTypeWarning, msg)
return reconcile.Result{RequeueAfter: timeout}, nil
}
// Cleanup instance entry from backOffDuration map.
backOffDurationMapMutex.Lock()
delete(backOffDuration, instance.Name)
backOffDurationMapMutex.Unlock()
return reconcile.Result{}, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return success here, we will miss the deletePermission on the fileshare.

I think we need to invoke
"err = r.configureNetPermissionsForFileVolume(ctx, volumeID, vm, instance, true)".

I'm not sure how you can fetch the vm info though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since VM is already deleted we won't get VM object. So, it is not possible to run configureNerPermissionsForFileVolume. I am also not sure if we can do anything else here.
@divyenpatel Can you please review these changes once.

}

setInstanceError(ctx, r, instance, msg)
return reconcile.Result{RequeueAfter: timeout}, nil
}
Expand Down