Change:
} return true, obj, nil }) <ins> nodes = &v1.NodeList{} nodeNamePrefix := "mynode" for i := 0; i < 5; i++ { var nodeName string if i != 0 { nodeName = fmt.Sprintf("%s-%d", nodeNamePrefix, i) } else { // We want also the "mynode" node since all the testing pods live there nodeName = nodeNamePrefix } attachVolumeToNode("lostVolumeName", nodeName) } </ins> fakeClient.AddReactor("list", "nodes", func(action core.Action) (handled bool, ret runtime.Object, err error) { obj := &v1.NodeList{} <del> nodeNamePrefix := "mynode" for i := 0; i < 5; i++ { var nodeName string if i != 0 { nodeName = fmt.Sprintf("%s-%d", nodeNamePrefix, i) } else { // We want also the "mynode" node since all the testing pods live there nodeName = nodeNamePrefix } node := v1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: nodeName, Labels: map[string]string{ "name": nodeName, }, Annotations: map[string]string{ util.ControllerManagedAttachAnnotation: "true", }, }, Status: v1.NodeStatus{ VolumesAttached: []v1.AttachedVolume{ { Name:       TestPluginName + "/lostVolumeName", DevicePath: "fake/path", }, }, }, } obj.Items = append(obj.Items, node) } </del> <ins> obj.Items = append(obj.Items, nodes.Items...) </ins> return true, obj, nil }) <ins> volumeAttachments = &storagev1.VolumeAttachmentList{} fakeClient.AddReactor("list", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) { obj := &storagev1.VolumeAttachmentList{} obj.Items = append(obj.Items, volumeAttachments.Items...) return true, obj, nil }) fakeClient.AddReactor("create", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) { createAction := action.(core.CreateAction) va := createAction.GetObject().(*storagev1.VolumeAttachment) volumeAttachments.Items = append(volumeAttachments.Items, *va) return true, createAction.GetObject(), nil }) pvs = &v1.PersistentVolumeList{} fakeClient.AddReactor("list", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) { obj := &v1.PersistentVolumeList{} obj.Items = append(obj.Items, pvs.Items...) return true, obj, nil }) fakeClient.AddReactor("create", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) { createAction := action.(core.CreateAction) pv := createAction.GetObject().(*v1.PersistentVolume) pvs.Items = append(pvs.Items, *pv) return true, createAction.GetObject(), nil }) </ins> fakeWatch := watch.NewFake() fakeClient.AddWatchReactor("*", core.DefaultWatchReactor(fakeWatch, nil))

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