Migrate pkg/kubelet/pod to structured logging

This commit is contained in:
Geonju Kim 2021-02-11 18:36:11 +09:00
parent 20b03f6365
commit 504cc5b1e4

View File

@ -119,17 +119,17 @@ func (mc *basicMirrorClient) DeleteMirrorPod(podFullName string, uid *types.UID)
}
name, namespace, err := kubecontainer.ParsePodFullName(podFullName)
if err != nil {
klog.Errorf("Failed to parse a pod full name %q", podFullName)
klog.ErrorS(err, "Failed to parse a pod full name", "podFullName", podFullName)
return false, err
}
klog.V(2).Infof("Deleting a mirror pod %q (uid %#v)", podFullName, uid)
klog.V(2).InfoS("Deleting a mirror pod", "pod", klog.KRef(namespace, name), "podUID", uid)
var GracePeriodSeconds int64
if err := mc.apiserverClient.CoreV1().Pods(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{GracePeriodSeconds: &GracePeriodSeconds, Preconditions: &metav1.Preconditions{UID: uid}}); err != nil {
// Unfortunately, there's no generic error for failing a precondition
if !(apierrors.IsNotFound(err) || apierrors.IsConflict(err)) {
// We should return the error here, but historically this routine does
// not return an error unless it can't parse the pod name
klog.Errorf("Failed deleting a mirror pod %q: %v", podFullName, err)
klog.ErrorS(err, "Failed deleting a mirror pod", "pod", klog.KRef(namespace, name))
}
return false, nil
}