-
Notifications
You must be signed in to change notification settings - Fork 6
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
add support to ignore volumeless pods by Resiliency #137
Changes from 7 commits
8c3d6df
b4f0909
0fa1d48
5b18a1d
0e84789
009a8ce
f488026
6414c50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,9 @@ type ControllerPodInfo struct { // information controller keeps on hand about a | |
|
||
const notFound = "not found" | ||
const hostNameTopologyKey = "kubernetes.io/hostname" | ||
const arrayIDVolumeAttribute = "arrayID" | ||
const storageSystemVolumeAttribute = "StorageSystem" | ||
const defaultArray = "default" | ||
|
||
// controllerModePodHandler handles controller mode functionality when a pod event happens | ||
func (cm *PodMonitorType) controllerModePodHandler(pod *v1.Pod, eventType watch.EventType) error { | ||
|
@@ -104,10 +107,19 @@ func (cm *PodMonitorType) controllerModePodHandler(pod *v1.Pod, eventType watch. | |
// If ready, we want to save the PodKeyToControllerPodInfo | ||
// It will use these items to clean up pods if the array reports no connectivity. | ||
if ready { | ||
arrayIDs, err := cm.podToArrayIDs(pod) | ||
arrayIDs, pvcCount, err := cm.podToArrayIDs(ctx, pod) | ||
log.Infof("IgnoreVolumelessPods %t pvcCount %d", IgnoreVolumelessPods, pvcCount) | ||
if err != nil { | ||
log.Errorf("Could not determine pod to arrayIDs: %s", err) | ||
} else { | ||
// Do not keep track of Volumeless pods | ||
if IgnoreVolumelessPods && pvcCount == 0 { | ||
log.Infof("podKey %s ignore because Volumeless", podKey) | ||
return nil | ||
} | ||
} | ||
log.Infof("podKey %s pvcCount %d arrayIDs %v", podKey, pvcCount, arrayIDs) | ||
|
||
podAffinityLabels := cm.getPodAffinityLabels(pod) | ||
if len(podAffinityLabels) > 0 { | ||
log.Infof("podKey %s podAffinityLabels %v", podKey, podAffinityLabels) | ||
|
@@ -192,6 +204,12 @@ func (cm *PodMonitorType) controllerCleanupPod(pod *v1.Pod, node *v1.Node, reaso | |
return false | ||
} | ||
|
||
// ignoreVolumeless pod | ||
if IgnoreVolumelessPods && len(pvlist) == 0 { | ||
log.WithFields(fields).Infof("Ignoring volumeless pod") | ||
return true | ||
} | ||
|
||
// Get the volume handles from the PVs | ||
volIDs := make([]string, 0) | ||
for _, pv := range pvlist { | ||
|
@@ -366,12 +384,12 @@ func (cm *PodMonitorType) callControllerUnpublishVolume(node *v1.Node, volumeID | |
return err | ||
} | ||
|
||
// podToArrayIDs returns the array IDs used by the pod) | ||
// TODO: multi-array | ||
func (cm *PodMonitorType) podToArrayIDs(pod *v1.Pod) ([]string, error) { | ||
arrayIDs := make([]string, 1) | ||
arrayIDs[0] = "default" | ||
return arrayIDs, nil | ||
// podToArrayIDs returns the array IDs used by the pod, along with pvCount, and error | ||
func (cm *PodMonitorType) podToArrayIDs(ctx context.Context, pod *v1.Pod) ([]string, int, error) { | ||
arrayIDs := make([]string, 0) | ||
pvlist, _ := K8sAPI.GetPersistentVolumesInPod(ctx, pod) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this return an error that is being discarded? Should it not be checked? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we don't need, error will result in empty pvlist. We check for error where we need to, here for now not needed. When we add multi-array support, then we will need to check error and accordingly return error. |
||
arrayIDs = append(arrayIDs, defaultArray) | ||
return arrayIDs, len(pvlist), nil | ||
} | ||
|
||
// ArrayConnectivityMonitor -- periodically checks array connectivity to all the nodes using it. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we take this opportunity to review this allowedList for CVEs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have ubi image upgrade story, we should check in that story. I will add in acceptance criteria