MCPcopy
hub / github.com/kubernetes/kubectl / daemonSetFilter

Method daemonSetFilter

pkg/drain/filters.go:179–209  ·  view source on GitHub ↗
(pod corev1.Pod)

Source from the content-addressed store, hash-verified

177}
178
179func (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
211func (d *Helper) mirrorPodFilter(pod corev1.Pod) PodDeleteStatus {
212 if _, found := pod.ObjectMeta.Annotations[corev1.MirrorPodAnnotationKey]; found {

Callers

nothing calls this directly

Calls 7

getContextMethod · 0.95
isControllerRefDaemonSetFunction · 0.85
MakePodDeleteStatusOkayFunction · 0.85
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected