mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #99999 from adisky/s-log3
Fix structured logging for kuberuntime_manger.go
This commit is contained in:
commit
6e0e64c992
@ -205,7 +205,7 @@ func NewKubeGenericRuntimeManager(
|
|||||||
|
|
||||||
typedVersion, err := kubeRuntimeManager.getTypedVersion()
|
typedVersion, err := kubeRuntimeManager.getTypedVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "Get runtime version failed: %v")
|
klog.ErrorS(err, "Get runtime version failed")
|
||||||
return nil, err
|
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.
|
// 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 {
|
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)
|
createPodSandbox, attempt, sandboxID := m.podSandboxChanged(pod, podStatus)
|
||||||
changes := podActions{
|
changes := podActions{
|
||||||
@ -711,16 +711,16 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
|||||||
if podContainerChanges.SandboxID != "" {
|
if podContainerChanges.SandboxID != "" {
|
||||||
m.recorder.Eventf(ref, v1.EventTypeNormal, events.SandboxChanged, "Pod sandbox changed, it will be killed and re-created.")
|
m.recorder.Eventf(ref, v1.EventTypeNormal, events.SandboxChanged, "Pod sandbox changed, it will be killed and re-created.")
|
||||||
} else {
|
} 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.
|
// Step 2: Kill the pod if the sandbox has changed.
|
||||||
if podContainerChanges.KillPod {
|
if podContainerChanges.KillPod {
|
||||||
if podContainerChanges.CreateSandbox {
|
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 {
|
} 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)
|
killResult := m.killPodWithSyncResult(pod, kubecontainer.ConvertPodStatusToRunningPod(m.runtimeName, podStatus), nil)
|
||||||
@ -787,10 +787,10 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
createSandboxResult.Fail(kubecontainer.ErrCreatePodSandbox, msg)
|
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)
|
ref, referr := ref.GetReference(legacyscheme.Scheme, pod)
|
||||||
if referr != nil {
|
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)
|
m.recorder.Eventf(ref, v1.EventTypeWarning, events.FailedCreatePodSandBox, "Failed to create pod sandbox: %v", err)
|
||||||
return
|
return
|
||||||
@ -851,7 +851,7 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
|||||||
return err
|
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.
|
// 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 {
|
if msg, err := m.startContainer(podSandboxID, podSandboxConfig, spec, pod, podStatus, pullSecrets, podIP, podIPs); err != nil {
|
||||||
startContainerResult.Fail(err, msg)
|
startContainerResult.Fail(err, msg)
|
||||||
@ -859,7 +859,7 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, podStatus *kubecontaine
|
|||||||
// repetitive log spam
|
// repetitive log spam
|
||||||
switch {
|
switch {
|
||||||
case err == images.ErrImagePullBackOff:
|
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:
|
default:
|
||||||
utilruntime.HandleError(fmt.Errorf("%v %+v start failed in pod %v: %v: %s", typeName, spec.container, format.Pod(pod), err, msg))
|
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