Skip to content

Commit

Permalink
Skip static pods during eviction loop (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriananeci authored Aug 29, 2022
1 parent 19830d6 commit 1c9a596
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ func (h *Handler) GetPodsForNode(node v1.Node) ([]v1.Pod, error) {
continue
}

// skip pods with DaemonSet controller object
if len(pod.OwnerReferences) > 0 && pod.ObjectMeta.OwnerReferences[0].Kind == "DaemonSet" {
h.logger.Debugf("Skipping %s as it is part of a DaemonSet", pod.Name)
// skip pods with DaemonSet controller object or static pods
if len(pod.OwnerReferences) > 0 && slices.Contains([]string{"DaemonSet", "Node"}, pod.ObjectMeta.OwnerReferences[0].Kind) {
h.logger.Debugf("Skipping %s as it is part of a DaemonSet or is a static pod", pod.Name)
continue
}

Expand Down Expand Up @@ -356,6 +356,10 @@ func (h *Handler) getControllerObject(pod v1.Pod) (*controllerObject, error) {
h.logger.Warnf("DaemonSets are not covered")
return newControllerObject("DaemonSet", "", "", nil), nil

case "Node":
h.logger.Warnf("Static pods are not covered")
return newControllerObject("StaticPod", "", "", nil), nil

case "StatefulSet":
sts, err := h.appContext.K8sClient.AppsV1().StatefulSets(pod.Namespace).Get(h.appContext.Context, pod.OwnerReferences[0].Name, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit 1c9a596

Please sign in to comment.