Change:
} } <ins> // Process Volume-Attachment objects. // Should be called only after populating attached volumes in the ASW. // For each VA object, this function checks if its present in the ASW. // If not, adds the volume to ASW as an "uncertain" attachment. // In the reconciler, the logic checks if the volume is present in the DSW; //   if yes, the reconciler will attempt attach on the volume; //   if not (could be a dangling attachment), the reconciler will detach this volume. func (adc *attachDetachController) processVolumeAttachments() error { vas, err := adc.volumeAttachmentLister.List(labels.Everything()) if err != nil { klog.Errorf("failed to list VolumeAttachment objects: %v", err) return err } for _, va := range vas { nodeName := types.NodeName(va.Spec.NodeName) pvName := va.Spec.Source.PersistentVolumeName if pvName == nil { // Currently VA objects are created for CSI volumes only. nil pvName is unexpected, generate a warning klog.Warningf("Skipping the va as its pvName is nil, va.Name: %q, nodeName: %q", va.Name, nodeName) continue } pv, err := adc.pvLister.Get(*pvName) if err != nil { klog.Errorf("Unable to lookup pv object for: %q, err: %v", *pvName, err) continue } volumeSpec := volume.NewSpecFromPersistentVolume(pv, false) plugin, err := adc.volumePluginMgr.FindAttachablePluginBySpec(volumeSpec) if err != nil || plugin == nil { // Currently VA objects are created for CSI volumes only. nil plugin is unexpected, generate a warning klog.Warningf( "Skipping processing the volume %q on nodeName: %q, no attacher interface found. err=%v", *pvName, nodeName, err) continue } volumeName, err := volumeutil.GetUniqueVolumeNameFromSpec(plugin, volumeSpec) if err != nil { klog.Errorf( "Failed to find unique name for volume:%q, va.Name:%q, nodeName:%q: %v", *pvName, va.Name, nodeName, err) continue } attachState := adc.actualStateOfWorld.GetAttachState(volumeName, nodeName) if attachState == cache.AttachStateDetached { klog.V(1).Infof("Marking volume attachment as uncertain as volume:%q (%q) is not attached (%v)", volumeName, nodeName, attachState) err = adc.actualStateOfWorld.MarkVolumeAsUncertain(volumeName, volumeSpec, nodeName) if err != nil { klog.Errorf("MarkVolumeAsUncertain fail to add the volume %q (%q) to ASW. err: %s", volumeName, nodeName, err) } } } return nil } </ins> var _ volume.VolumeHost = &attachDetachController{} var _ volume.AttachDetachVolumeHost = &attachDetachController{}

Discussion:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: Background: The attach/detach controller create objects for CSI Volumes to indicate that a volume needs to be attached to a node. It deletes the object to indicate that the volume should be detached. Problem: If the Attach/Detach controller crashes, and in the meantime the pod using that volume is deleted, when the AD controller restarts, it won't know that the volume was previously attached and should be cleaned up. What you expected to happen: Proposal: We should have the AD controller periodically list all objects and for any that are not accounted for, update its internal actual/desired state caches so that the volume is gracefully detached. How to reproduce it (as minimally and precisely as possible): Anything else we need to know?: /sig storage Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others:
could I take it?
/assign
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
Stale issues rot after 30d of inactivity. Mark the issue as fresh with . Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle rotten
Rotten issues close after 30d of inactivity. Reopen the issue with . Mark the issue as fresh with . Send feedback to sig-testing, kubernetes/test-infra and/or . /close
Closing this issue. <detailsIn response to : Rotten issues close after 30d of inactivity. Reopen the issue with . Mark the issue as fresh with . /close Instructions for interacting with me using PR comments are available .

If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/reopen
Reopened this issue. <detailsIn response to : /reopen Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
Rotten issues close after 30d of inactivity. Reopen the issue with . Mark the issue as fresh with . Send feedback to sig-testing, kubernetes/test-infra and/or . /close
Closing this issue. <detailsIn response to : Rotten issues close after 30d of inactivity. Reopen the issue with . Mark the issue as fresh with . /close Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/lifecycle frozen /reopen
Reopened this issue. <detailsIn response to : /lifecycle frozen /reopen Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/assign
should address this