mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fix structured logging for kuberuntime_manger.go
This commit is contained in:
parent
854c2cc79f
commit
461c0c1656
@ -205,7 +205,7 @@ func NewKubeGenericRuntimeManager(
|
||||
|
||||
typedVersion, err := kubeRuntimeManager.getTypedVersion()
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "Get runtime version failed: %v")
|
||||
klog.ErrorS(err, "Get runtime version failed")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ func containerSucceeded(c *v1.Container, podStatus *kubecontainer.PodStatus) boo
|
||||
|
||||
// computePodActions checks whether the pod spec has changed and returns the changes if true.
|
||||
func (m *kubeGenericRuntimeManager) computePodActions(pod *v1.Pod, podStatus *kubecontainer.PodStatus) podActions {
|
||||
klog.V(5).InfoS("Syncing Pod", klog.KObj(pod))
|
||||
klog.V(5).InfoS("Syncing Pod", "pod", klog.KObj(pod))
|
||||
|
||||
createPodSandbox, attempt, sandboxID := m.podSandboxChanged(pod, podStatus)
|
||||
changes := podActions{
|
||||
@ -711,16 +711,16 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
||||
if podContainerChanges.SandboxID != "" {
|
||||
m.recorder.Eventf(ref, v1.EventTypeNormal, events.SandboxChanged, "Pod sandbox changed, it will be killed and re-created.")
|
||||
} else {
|
||||
klog.V(4).InfoS("SyncPod received new pod, will create a sandbox for it", klog.KObj(pod))
|
||||
klog.V(4).InfoS("SyncPod received new pod, will create a sandbox for it", "pod", klog.KObj(pod))
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Kill the pod if the sandbox has changed.
|
||||
if podContainerChanges.KillPod {
|
||||
if podContainerChanges.CreateSandbox {
|
||||
klog.V(4).InfoS("Stopping PodSandbox for pod, will start new one", klog.KObj(pod))
|
||||
klog.V(4).InfoS("Stopping PodSandbox for pod, will start new one", "pod", klog.KObj(pod))
|
||||
} else {
|
||||
klog.V(4).InfoS("Stopping PodSandbox for pod, because all other containers are dead", klog.KObj(pod))
|
||||
klog.V(4).InfoS("Stopping PodSandbox for pod, because all other containers are dead", "pod", klog.KObj(pod))
|
||||
}
|
||||
|
||||
killResult := m.killPodWithSyncResult(pod, kubecontainer.ConvertPodStatusToRunningPod(m.runtimeName, podStatus), nil)
|
||||
@ -787,10 +787,10 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
||||
return
|
||||
}
|
||||
createSandboxResult.Fail(kubecontainer.ErrCreatePodSandbox, msg)
|
||||
klog.ErrorS(err, "CreatePodSandbox for pod failed", klog.KObj(pod))
|
||||
klog.ErrorS(err, "CreatePodSandbox for pod failed", "pod", klog.KObj(pod))
|
||||
ref, referr := ref.GetReference(legacyscheme.Scheme, pod)
|
||||
if referr != nil {
|
||||
klog.ErrorS(referr, "Couldn't make a ref to pod %q: '%v'", klog.KObj(pod))
|
||||
klog.ErrorS(referr, "Couldn't make a ref to pod", "pod", klog.KObj(pod))
|
||||
}
|
||||
m.recorder.Eventf(ref, v1.EventTypeWarning, events.FailedCreatePodSandBox, "Failed to create pod sandbox: %v", err)
|
||||
return
|
||||
@ -851,7 +851,7 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
||||
return err
|
||||
}
|
||||
|
||||
klog.V(4).InfoS("Creating container in pod %v", "containerType", typeName, "container", spec.container, "pod", klog.KObj(pod))
|
||||
klog.V(4).InfoS("Creating container in pod", "containerType", typeName, "container", spec.container, "pod", klog.KObj(pod))
|
||||
// NOTE (aramase) podIPs are populated for single stack and dual stack clusters. Send only podIPs.
|
||||
if msg, err := m.startContainer(podSandboxID, podSandboxConfig, spec, pod, podStatus, pullSecrets, podIP, podIPs); err != nil {
|
||||
startContainerResult.Fail(err, msg)
|
||||
@ -859,7 +859,7 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
||||
// repetitive log spam
|
||||
switch {
|
||||
case err == images.ErrImagePullBackOff:
|
||||
klog.V(3).InfoS("Container start failed in pod", "containerType", typeName, "container", spec.container, klog.KObj(pod), "containerMessage", msg, "err", err)
|
||||
klog.V(3).InfoS("Container start failed in pod", "containerType", typeName, "container", spec.container, "pod", klog.KObj(pod), "containerMessage", msg, "err", err)
|
||||
default:
|
||||
utilruntime.HandleError(fmt.Errorf("%v %+v start failed in pod %v: %v: %s", typeName, spec.container, format.Pod(pod), err, msg))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user