diff --git a/internal/monitor/controller.go b/internal/monitor/controller.go index 5cfb18b..af8d917 100644 --- a/internal/monitor/controller.go +++ b/internal/monitor/controller.go @@ -262,6 +262,23 @@ func (cm *PodMonitorType) controllerCleanupPod(pod *v1.Pod, node *v1.Node, reaso if cm.SkipArrayConnectionValidation && taintnoexec { log.WithFields(fields).Info("SkipArrayConnectionValidation is set and taintnoexec is true- proceeding") } else { + if err != nil { + log.WithFields(fields).Info("Aborting pod cleanup due to error: ", err.Error()) + if strings.Contains(err.Error(), "Could not determine CSI NodeID for node") { + if err = K8sAPI.CreateEvent(podmon, pod, k8sapi.EventTypeWarning, reason, + "podmon aborted pod cleanup %s due to missing CSI annotations", + string(pod.ObjectMeta.UID), node.ObjectMeta.Name); err != nil { + log.Errorf("Failed to send %s event: %s", reason, err.Error()) + } + } else { + if err = K8sAPI.CreateEvent(podmon, pod, k8sapi.EventTypeWarning, reason, + "podmon aborted pod cleanup %s due to error while validating volume host connectivity", + string(pod.ObjectMeta.UID), node.ObjectMeta.Name); err != nil { + log.Errorf("Failed to send %s event: %s", reason, err.Error()) + } + } + return false + } log.WithFields(fields).Info("Aborting pod cleanup because array still connected and/or recently did I/O") if err = K8sAPI.CreateEvent(podmon, pod, k8sapi.EventTypeWarning, reason, "podmon aborted pod cleanup %s array connected or recent I/O", diff --git a/internal/monitor/features/controller.feature b/internal/monitor/features/controller.feature index 17045dd..6cb15c4 100644 --- a/internal/monitor/features/controller.feature +++ b/internal/monitor/features/controller.feature @@ -22,7 +22,7 @@ Feature: Controller Monitor | "node1" | 2 | "DeleteVolumeAttachment" | "node1" | "false" | "Couldn't delete VolumeAttachment" | | "node1" | 2 | "DeletePod" | "node1" | "false" | "Delete pod failed" | | "node1" | 2 | "ControllerUnpublishVolume" | "node1" | "false" | "errors calling ControllerUnpublishVolume to fence" | - | "node1" | 2 | "ValidateVolumeHostConnectivity" | "node1" | "false" | "Aborting pod cleanup because array still connected" | + | "node1" | 2 | "ValidateVolumeHostConnectivity" | "node1" | "false" | "Aborting pod cleanup due to error" | | "node1" | 2 | "CreateEvent" | "node1" | "true" | "Successfully cleaned up pod" | @controller-mode @@ -52,8 +52,8 @@ Feature: Controller Monitor | "node1" | 2 | "NotReady" | "false" | "noexec" | "CreateEvent" | "Updated" | "true" | "false" | "Successfully cleaned up pod" | | "node1" | 2 | "CrashLoop" | "false" | "noexec" | "CreateEvent" | "Updated" | "true" | "false" | "Successfully cleaned up pod" | | "node1" | 2 | "Initialized" | "false" | "noexec" | "CreateEvent" | "Updated" | "true" | "false" | "Successfully cleaned up pod" | - | "node1" | 2 | "NotReady" | "false" | "nosched" | "NoAnnotation" | "Updated" | "false" | "false" | "Aborting pod cleanup because array still connected" | - | "node1" | 2 | "NotReady" | "false" | "nosched" | "BadCSINode" | "Updated" | "false" | "false" | "Aborting pod cleanup because array still connected" | + | "node1" | 2 | "NotReady" | "false" | "nosched" | "NoAnnotation" | "Updated" | "false" | "false" | "Aborting pod cleanup due to error" | + | "node1" | 2 | "NotReady" | "false" | "nosched" | "BadCSINode" | "Updated" | "false" | "false" | "Aborting pod cleanup due to error" | @controller-mode Scenario Outline: test controllerModePodHandler skipping validate volume with a CSIExtensionNotPresent error