diff --git a/internal/dao/container.go b/internal/dao/container.go index 7310d29329..5b8f6c0cc7 100644 --- a/internal/dao/container.go +++ b/internal/dao/container.go @@ -47,10 +47,14 @@ func (c *Container) List(ctx context.Context, _ string) ([]runtime.Object, error } res := make([]runtime.Object, 0, len(po.Spec.InitContainers)+len(po.Spec.Containers)) for i, co := range po.Spec.InitContainers { - res = append(res, render.MakeContainerRes(po, true, i, cmx[co.Name])) + cr := render.MakeContainerRes(po, true, i) + cr.MX = cmx[co.Name] + res = append(res, cr) } for i, co := range po.Spec.Containers { - res = append(res, render.MakeContainerRes(po, false, i, cmx[co.Name])) + cr := render.MakeContainerRes(po, false, i) + cr.MX = cmx[co.Name] + res = append(res, cr) } return res, nil diff --git a/internal/render/container.go b/internal/render/container.go index b90a192cc9..107f12e94c 100644 --- a/internal/render/container.go +++ b/internal/render/container.go @@ -236,12 +236,11 @@ func probe(p *v1.Probe) string { return on } -func MakeContainerRes(po *v1.Pod, isInit bool, index int, cmx *mv1beta1.ContainerMetrics) ContainerRes { +func MakeContainerRes(po *v1.Pod, isInit bool, index int) ContainerRes { return ContainerRes{ pod: po, IsInit: isInit, Index: index, - MX: cmx, Age: po.GetCreationTimestamp(), } } diff --git a/internal/render/container_test.go b/internal/render/container_test.go index 8881c670b6..9b48bfbe18 100644 --- a/internal/render/container_test.go +++ b/internal/render/container_test.go @@ -161,12 +161,13 @@ func makeContainerRes(container *v1.Container, status *v1.ContainerStatus, cmx * po.Status.ContainerStatuses = []v1.ContainerStatus{*status} } - return render.MakeContainerRes( + cr := render.MakeContainerRes( po, isInit, 0, - cmx, ) + cr.MX = cmx + return cr } func toQty(s string) resource.Quantity { diff --git a/internal/xray/container_test.go b/internal/xray/container_test.go index 030059ee5e..6154909720 100644 --- a/internal/xray/container_test.go +++ b/internal/xray/container_test.go @@ -261,5 +261,5 @@ func makeContainerRes(container *v1.Container) render.ContainerRes { }, } - return render.MakeContainerRes(po, false, 0, nil) + return render.MakeContainerRes(po, false, 0) } diff --git a/internal/xray/pod.go b/internal/xray/pod.go index b34dcca7d6..910330fa35 100644 --- a/internal/xray/pod.go +++ b/internal/xray/pod.go @@ -86,12 +86,12 @@ func (*Pod) containerRefs(ctx context.Context, parent *TreeNode, ns string, po * ctx = context.WithValue(ctx, KeyParent, parent) var cre Container for i := 0; i < len(po.Spec.InitContainers); i++ { - if err := cre.Render(ctx, ns, render.MakeContainerRes(po, true, i, nil)); err != nil { + if err := cre.Render(ctx, ns, render.MakeContainerRes(po, true, i)); err != nil { return err } } for i := 0; i < len(po.Spec.Containers); i++ { - if err := cre.Render(ctx, ns, render.MakeContainerRes(po, false, i, nil)); err != nil { + if err := cre.Render(ctx, ns, render.MakeContainerRes(po, false, i)); err != nil { return err } }