implement Stringer for podActions

klog prints an internal error when trying to log the podActions struct.

> I0505 14:12:12.827065  190662 kuberuntime_manager.go:1014] "computePodActions got for pod" podActions="<internal error: json: unsupported type: map[container.ContainerID]kuberuntime.containerToKillInfo>" pod="kube-system/coredns-8f5847b64-mzw46"

Implement the stringer interface on the struct to avoid the json error.

Change-Id: I22444524a78a0ecec9490b9240def371a4129434
This commit is contained in:
Antonio Ojea 2023-08-07 08:53:51 +00:00
parent 2c6c4566ef
commit f355b22f5f

View File

@ -514,6 +514,11 @@ type podActions struct {
UpdatePodResources bool
}
func (p podActions) String() string {
return fmt.Sprintf("KillPod: %t, CreateSandbox: %t, UpdatePodResources: %t, Attempt: %d, InitContainersToStart: %v, ContainersToStart: %v, EphemeralContainersToStart: %v,ContainersToUpdate: %v, ContainersToKill: %v",
p.KillPod, p.CreateSandbox, p.UpdatePodResources, p.Attempt, p.InitContainersToStart, p.ContainersToStart, p.EphemeralContainersToStart, p.ContainersToUpdate, p.ContainersToKill)
}
func containerChanged(container *v1.Container, containerStatus *kubecontainer.Status) (uint64, uint64, bool) {
expectedHash := kubecontainer.HashContainer(container)
return expectedHash, containerStatus.Hash, containerStatus.Hash != expectedHash