(pod corev1.Pod)
| 177 | } |
| 178 | |
| 179 | func (d *Helper) daemonSetFilter(pod corev1.Pod) PodDeleteStatus { |
| 180 | // Note that we return false in cases where the pod is DaemonSet managed, |
| 181 | // regardless of flags. |
| 182 | // |
| 183 | // The exception is for pods that are orphaned (the referencing |
| 184 | // management resource - including DaemonSet - is not found). |
| 185 | // Such pods will be deleted if --force is used. |
| 186 | controllerRef := metav1.GetControllerOf(&pod) |
| 187 | if controllerRef == nil || !isControllerRefDaemonSet(controllerRef) { |
| 188 | return MakePodDeleteStatusOkay() |
| 189 | } |
| 190 | // Any finished pod can be removed. |
| 191 | if pod.Status.Phase == corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed { |
| 192 | return MakePodDeleteStatusOkay() |
| 193 | } |
| 194 | |
| 195 | if _, err := d.Client.AppsV1().DaemonSets(pod.Namespace).Get(d.getContext(), controllerRef.Name, metav1.GetOptions{}); err != nil { |
| 196 | // remove orphaned pods with a warning if --force is used |
| 197 | if apierrors.IsNotFound(err) && d.Force { |
| 198 | return MakePodDeleteStatusWithWarning(true, err.Error()) |
| 199 | } |
| 200 | |
| 201 | return MakePodDeleteStatusWithError(err.Error()) |
| 202 | } |
| 203 | |
| 204 | if !d.IgnoreAllDaemonSets { |
| 205 | return MakePodDeleteStatusWithError(daemonSetFatal) |
| 206 | } |
| 207 | |
| 208 | return MakePodDeleteStatusWithWarning(false, daemonSetWarning) |
| 209 | } |
| 210 | |
| 211 | func (d *Helper) mirrorPodFilter(pod corev1.Pod) PodDeleteStatus { |
| 212 | if _, found := pod.ObjectMeta.Annotations[corev1.MirrorPodAnnotationKey]; found { |
nothing calls this directly
no test coverage detected