Skip to content

Commit

Permalink
container_status: Use cached value of image name
Browse files Browse the repository at this point in the history
Use the name we stored in the container object in container status
rather than recalculating it.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
  • Loading branch information
mrunalp committed Jul 25, 2019
1 parent 7e5c016 commit 309c1d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
7 changes: 3 additions & 4 deletions server/container_status.go
Expand Up @@ -37,12 +37,11 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
Labels: c.Labels(),
Annotations: c.Annotations(),
ImageRef: c.ImageRef(),
Image: &pb.ImageSpec{
Image: c.ImageName(),
},
},
}
resp.Status.Image = &pb.ImageSpec{Image: c.Image()}
if status, err := s.StorageImageServer().ImageStatus(s.systemContext, c.ImageRef()); err == nil {
resp.Status.Image.Image = status.Name
}

mounts := []*pb.Mount{}
for _, cv := range c.Volumes() {
Expand Down
7 changes: 0 additions & 7 deletions server/container_status_test.go
Expand Up @@ -4,8 +4,6 @@ import (
"context"

"github.com/cri-o/cri-o/oci"
"github.com/cri-o/cri-o/pkg/storage"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -33,11 +31,6 @@ var _ = t.Describe("ContainerStatus", func() {
testContainer.AddVolume(oci.ContainerVolume{})
testContainer.SetState(givenState)

gomock.InOrder(
imageServerMock.EXPECT().ImageStatus(gomock.Any(),
gomock.Any()).Return(&storage.ImageResult{}, nil),
)

// When
response, err := sut.ContainerStatus(context.Background(),
&pb.ContainerStatusRequest{
Expand Down

0 comments on commit 309c1d9

Please sign in to comment.