Merge 554a1f9b09
into f82fe5691a
This commit is contained in:
commit
1bee65aa08
6 changed files with 50 additions and 70 deletions
|
@ -469,10 +469,7 @@ func ContainerStatus(client pb.RuntimeServiceClient, ID string) error {
|
||||||
if r.Status.Image != nil {
|
if r.Status.Image != nil {
|
||||||
fmt.Printf("Image: %v\n", r.Status.Image.Image)
|
fmt.Printf("Image: %v\n", r.Status.Image.Image)
|
||||||
}
|
}
|
||||||
//
|
fmt.Printf("ImageRef: %v\n", r.Status.ImageRef)
|
||||||
// TODO: https://github.com/kubernetes-incubator/cri-o/issues/531
|
|
||||||
//
|
|
||||||
//fmt.Printf("ImageRef: %v\n", r.Status.ImageRef)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,16 @@ import (
|
||||||
"github.com/containers/image/transports/alltransports"
|
"github.com/containers/image/transports/alltransports"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
|
digest "github.com/opencontainers/go-digest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImageResult wraps a subset of information about an image: its ID, its names,
|
// ImageResult wraps a subset of information about an image: its ID, its names,
|
||||||
// and the size, if known, or nil if it isn't.
|
// and the size, if known, or nil if it isn't.
|
||||||
type ImageResult struct {
|
type ImageResult struct {
|
||||||
ID string
|
ID string
|
||||||
Names []string
|
Names []string
|
||||||
Size *uint64
|
Digest string
|
||||||
|
Size *uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type indexInfo struct {
|
type indexInfo struct {
|
||||||
|
@ -118,13 +120,21 @@ func (svc *imageService) ImageStatus(systemContext *types.SystemContext, nameOrI
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
size := imageSize(img)
|
size := imageSize(img)
|
||||||
|
manifest, _, _ := img.Manifest()
|
||||||
img.Close()
|
img.Close()
|
||||||
|
|
||||||
return &ImageResult{
|
manifestDigest := ""
|
||||||
ID: image.ID,
|
if len(manifest) > 0 {
|
||||||
Names: image.Names,
|
manifestDigest = digest.Canonical.FromBytes(manifest).String()
|
||||||
Size: size,
|
}
|
||||||
}, nil
|
|
||||||
|
result := ImageResult{
|
||||||
|
ID: image.ID,
|
||||||
|
Names: image.Names,
|
||||||
|
Digest: manifestDigest,
|
||||||
|
Size: size,
|
||||||
|
}
|
||||||
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func imageSize(img types.Image) *uint64 {
|
func imageSize(img types.Image) *uint64 {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
digest "github.com/opencontainers/go-digest"
|
||||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
@ -53,32 +54,29 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
imageRef := status.ID
|
imageRef := ""
|
||||||
//
|
|
||||||
// TODO: https://github.com/kubernetes-incubator/cri-o/issues/531
|
|
||||||
//
|
|
||||||
//for _, n := range status.Names {
|
|
||||||
//r, err := reference.ParseNormalizedNamed(n)
|
|
||||||
//if err != nil {
|
|
||||||
//return nil, fmt.Errorf("failed to normalize image name for ImageRef: %v", err)
|
|
||||||
//}
|
|
||||||
//if digested, isDigested := r.(reference.Canonical); isDigested {
|
|
||||||
//imageRef = reference.FamiliarString(digested)
|
|
||||||
//break
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
resp.Status.ImageRef = imageRef
|
|
||||||
|
|
||||||
for _, n := range status.Names {
|
for _, n := range status.Names {
|
||||||
r, err := reference.ParseNormalizedNamed(n)
|
r, err := reference.ParseNormalizedNamed(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to normalize image name for Image: %v", err)
|
return nil, fmt.Errorf("failed to normalize image name for Image: %v", err)
|
||||||
}
|
}
|
||||||
if tagged, isTagged := r.(reference.Tagged); isTagged {
|
if namedtagged, isNamedTagged := r.(reference.NamedTagged); isNamedTagged {
|
||||||
imageName = reference.FamiliarString(tagged)
|
imageName = reference.FamiliarString(namedtagged)
|
||||||
|
if status.Digest != "" {
|
||||||
|
if canonical, err2 := reference.WithDigest(reference.TrimNamed(r), digest.Digest(status.Digest)); err2 == nil {
|
||||||
|
imageRef = reference.FamiliarString(canonical)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if canonical, isCanonical := r.(reference.Canonical); isCanonical {
|
||||||
|
imageName = reference.FamiliarString(canonical)
|
||||||
|
imageRef = reference.FamiliarString(canonical)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
resp.Status.ImageRef = imageRef
|
||||||
resp.Status.Image = &pb.ImageSpec{Image: imageName}
|
resp.Status.Image = &pb.ImageSpec{Image: imageName}
|
||||||
|
|
||||||
cState := s.Runtime().ContainerStatus(c)
|
cState := s.Runtime().ContainerStatus(c)
|
||||||
|
|
|
@ -42,10 +42,10 @@ func (s *Server) ImageStatus(ctx context.Context, req *pb.ImageStatusRequest) (*
|
||||||
}
|
}
|
||||||
resp := &pb.ImageStatusResponse{
|
resp := &pb.ImageStatusResponse{
|
||||||
Image: &pb.Image{
|
Image: &pb.Image{
|
||||||
Id: status.ID,
|
Id: status.ID,
|
||||||
RepoTags: status.Names,
|
RepoTags: status.Names,
|
||||||
Size_: *status.Size,
|
RepoDigests: []string{status.Digest},
|
||||||
// TODO: https://github.com/kubernetes-incubator/cri-o/issues/531
|
Size_: *status.Size,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
logrus.Debugf("ImageStatusResponse: %+v", resp)
|
logrus.Debugf("ImageStatusResponse: %+v", resp)
|
||||||
|
|
|
@ -83,7 +83,7 @@ cp "$CONMON_BINARY" "$TESTDIR/conmon"
|
||||||
|
|
||||||
PATH=$PATH:$TESTDIR
|
PATH=$PATH:$TESTDIR
|
||||||
|
|
||||||
# Make sure we have a copy of the redis:latest image.
|
# Make sure we have a copy of the redis:alpine image.
|
||||||
if ! [ -d "$ARTIFACTS_PATH"/redis-image ]; then
|
if ! [ -d "$ARTIFACTS_PATH"/redis-image ]; then
|
||||||
mkdir -p "$ARTIFACTS_PATH"/redis-image
|
mkdir -p "$ARTIFACTS_PATH"/redis-image
|
||||||
if ! "$COPYIMG_BINARY" --import-from=docker://redis:alpine --export-to=dir:"$ARTIFACTS_PATH"/redis-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then
|
if ! "$COPYIMG_BINARY" --import-from=docker://redis:alpine --export-to=dir:"$ARTIFACTS_PATH"/redis-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then
|
||||||
|
@ -93,10 +93,7 @@ if ! [ -d "$ARTIFACTS_PATH"/redis-image ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: remove the code below for redis digested image id when
|
# Make sure we have a copy of the redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b image.
|
||||||
# https://github.com/kubernetes-incubator/cri-o/issues/531 is complete
|
|
||||||
# as the digested reference will be auto-stored when pulling the tag
|
|
||||||
# above
|
|
||||||
if ! [ -d "$ARTIFACTS_PATH"/redis-image-digest ]; then
|
if ! [ -d "$ARTIFACTS_PATH"/redis-image-digest ]; then
|
||||||
mkdir -p "$ARTIFACTS_PATH"/redis-image-digest
|
mkdir -p "$ARTIFACTS_PATH"/redis-image-digest
|
||||||
if ! "$COPYIMG_BINARY" --import-from=docker://redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --export-to=dir:"$ARTIFACTS_PATH"/redis-image-digest --signature-policy="$INTEGRATION_ROOT"/policy.json ; then
|
if ! "$COPYIMG_BINARY" --import-from=docker://redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --export-to=dir:"$ARTIFACTS_PATH"/redis-image-digest --signature-policy="$INTEGRATION_ROOT"/policy.json ; then
|
||||||
|
@ -206,11 +203,7 @@ function start_crio() {
|
||||||
"$BIN2IMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --source-binary "$PAUSE_BINARY"
|
"$BIN2IMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --source-binary "$PAUSE_BINARY"
|
||||||
fi
|
fi
|
||||||
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=redis:alpine --import-from=dir:"$ARTIFACTS_PATH"/redis-image --add-name=docker.io/library/redis:alpine --signature-policy="$INTEGRATION_ROOT"/policy.json
|
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=redis:alpine --import-from=dir:"$ARTIFACTS_PATH"/redis-image --add-name=docker.io/library/redis:alpine --signature-policy="$INTEGRATION_ROOT"/policy.json
|
||||||
# TODO: remove the code below for redis:alpine digested image id when
|
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --import-from=dir:"$ARTIFACTS_PATH"/redis-image-digest --signature-policy="$INTEGRATION_ROOT"/policy.json
|
||||||
# https://github.com/kubernetes-incubator/cri-o/issues/531 is complete
|
|
||||||
# as the digested reference will be auto-stored when pulling the tag
|
|
||||||
# above
|
|
||||||
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --import-from=dir:"$ARTIFACTS_PATH"/redis-image-digest --add-name=docker.io/library/redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --signature-policy="$INTEGRATION_ROOT"/policy.json
|
|
||||||
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=mrunalp/oom --import-from=dir:"$ARTIFACTS_PATH"/oom-image --add-name=docker.io/library/mrunalp/oom --signature-policy="$INTEGRATION_ROOT"/policy.json
|
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=mrunalp/oom --import-from=dir:"$ARTIFACTS_PATH"/oom-image --add-name=docker.io/library/mrunalp/oom --signature-policy="$INTEGRATION_ROOT"/policy.json
|
||||||
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=mrunalp/image-volume-test --import-from=dir:"$ARTIFACTS_PATH"/image-volume-test-image --add-name=docker.io/library/mrunalp/image-volume-test --signature-policy="$INTEGRATION_ROOT"/policy.json
|
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=mrunalp/image-volume-test --import-from=dir:"$ARTIFACTS_PATH"/image-volume-test-image --add-name=docker.io/library/mrunalp/image-volume-test --signature-policy="$INTEGRATION_ROOT"/policy.json
|
||||||
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=busybox:latest --import-from=dir:"$ARTIFACTS_PATH"/busybox-image --add-name=docker.io/library/busybox:latest --signature-policy="$INTEGRATION_ROOT"/policy.json
|
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTS --runroot "$TESTDIR/crio-run" --image-name=busybox:latest --import-from=dir:"$ARTIFACTS_PATH"/busybox-image --add-name=docker.io/library/busybox:latest --signature-policy="$INTEGRATION_ROOT"/policy.json
|
||||||
|
@ -233,28 +226,16 @@ function start_crio() {
|
||||||
crioctl image pull redis:alpine
|
crioctl image pull redis:alpine
|
||||||
fi
|
fi
|
||||||
REDIS_IMAGEID=$(crioctl image status --id=redis:alpine | head -1 | sed -e "s/ID: //g")
|
REDIS_IMAGEID=$(crioctl image status --id=redis:alpine | head -1 | sed -e "s/ID: //g")
|
||||||
|
run crioctl image status --id=redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b
|
||||||
|
if [ "$status" -ne 0 ] ; then
|
||||||
|
crioctl image pull redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b
|
||||||
|
fi
|
||||||
|
REDIS_IMAGEID_DIGESTED=$(crioctl image status --id=redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b | head -1 | sed -e "s/ID: //g")
|
||||||
run crioctl image status --id=mrunalp/oom
|
run crioctl image status --id=mrunalp/oom
|
||||||
if [ "$status" -ne 0 ] ; then
|
if [ "$status" -ne 0 ] ; then
|
||||||
crioctl image pull mrunalp/oom
|
crioctl image pull mrunalp/oom
|
||||||
fi
|
fi
|
||||||
#
|
OOM_IMAGEID=$(crioctl image status --id=mrunalp/oom | head -1 | sed -e "s/ID: //g")
|
||||||
#
|
|
||||||
#
|
|
||||||
# TODO: remove the code below for redis digested image id when
|
|
||||||
# https://github.com/kubernetes-incubator/cri-o/issues/531 is complete
|
|
||||||
# as the digested reference will be auto-stored when pulling the tag
|
|
||||||
# above
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
REDIS_IMAGEID_DIGESTED="redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b"
|
|
||||||
run crioctl image status --id $REDIS_IMAGEID_DIGESTED
|
|
||||||
if [ "$status" -ne 0 ]; then
|
|
||||||
crioctl image pull $REDIS_IMAGEID_DIGESTED
|
|
||||||
fi
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
run crioctl image status --id=runcom/stderr-test
|
run crioctl image status --id=runcom/stderr-test
|
||||||
if [ "$status" -ne 0 ] ; then
|
if [ "$status" -ne 0 ] ; then
|
||||||
crioctl image pull runcom/stderr-test:latest
|
crioctl image pull runcom/stderr-test:latest
|
||||||
|
|
|
@ -49,8 +49,6 @@ function teardown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "container status return image@digest if created by image ID and digest available" {
|
@test "container status return image@digest if created by image ID and digest available" {
|
||||||
skip "depends on https://github.com/kubernetes-incubator/cri-o/issues/531"
|
|
||||||
|
|
||||||
start_crio
|
start_crio
|
||||||
|
|
||||||
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
||||||
|
@ -94,18 +92,14 @@ function teardown() {
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
echo "$output"
|
echo "$output"
|
||||||
[ "$output" != "" ]
|
[ "$output" != "" ]
|
||||||
|
imageid="$output"
|
||||||
|
|
||||||
run crioctl image list --quiet nginx@33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
run crioctl image list --quiet @"$imageid"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
echo "$output"
|
echo "$output"
|
||||||
[ "$output" != "" ]
|
[ "$output" != "" ]
|
||||||
|
|
||||||
run crioctl image list --quiet @33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
run crioctl image list --quiet "$imageid"
|
||||||
[ "$status" -eq 0 ]
|
|
||||||
echo "$output"
|
|
||||||
[ "$output" != "" ]
|
|
||||||
|
|
||||||
run crioctl image list --quiet 33eb1ed1e802d4f71e52421f56af028cdf12bb3bfff5affeaf5bf0e328ffa1bc
|
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
echo "$output"
|
echo "$output"
|
||||||
[ "$output" != "" ]
|
[ "$output" != "" ]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue