diff --git a/Dockerfile b/Dockerfile index aea332e8..f4f58bcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,17 @@ RUN set -x \ && cp bin/* /opt/cni/bin/ \ && rm -rf "$GOPATH" +# Install crictl +ENV CRICTL_COMMIT a2d0e8f7bc7e80111a7d79052ab9aca3469609aa +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/kubernetes-incubator/cri-tools.git "$GOPATH/src/github.com/kubernetes-incubator/cri-tools" \ + && cd "$GOPATH/src/github.com/kubernetes-incubator/cri-tools" \ + && git checkout -q "$CRICTL_COMMIT" \ + && go install github.com/kubernetes-incubator/cri-tools/cmd/crictl \ + && cp "$GOPATH"/bin/crictl /usr/bin/ \ + && rm -rf "$GOPATH" + COPY test/plugin_test_args.bash /opt/cni/bin/plugin_test_args.bash # Make sure we have some policy for pulling images diff --git a/contrib/test/crio-integration-playbook.yaml b/contrib/test/crio-integration-playbook.yaml index 999b8ab0..014be819 100644 --- a/contrib/test/crio-integration-playbook.yaml +++ b/contrib/test/crio-integration-playbook.yaml @@ -127,6 +127,12 @@ async: 600 poll: 10 when: xunit + - name: git clone crictl repo + git: + repo: https://github.com/kubernetes-incubator/cri-tools + dest: /root/src/github.com/kubernetes-incubator/cri-tools + async: 600 + poll: 10 - name: git clone runc repo git: repo: https://github.com/opencontainers/runc @@ -193,6 +199,12 @@ chdir: /root/src/github.com/opencontainers/runc async: 600 poll: 10 + - name: make crictl + shell: | + go install github.com/kubernetes-incubator/cri-tools/cmd/crictl && \ + cp $GOPATH/bin/crictl /usr/bin/crictl + args: + chdir: /root/src/github.com/kubernetes-incubator/cri-o/ - name: make runc make: params: BUILDTAGS="seccomp selinux" diff --git a/test/helpers.bash b/test/helpers.bash index d7f56837..2c1929cc 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -11,8 +11,9 @@ CRIO_ROOT=${CRIO_ROOT:-$(cd "$INTEGRATION_ROOT/../.."; pwd -P)} # Path of the crio binary. CRIO_BINARY=${CRIO_BINARY:-${CRIO_ROOT}/cri-o/crio} -# Path of the crioctl binary. -OCIC_BINARY=${OCIC_BINARY:-${CRIO_ROOT}/cri-o/crioctl} +# Path of the crictl binary. +CRICTL_PATH=$(command -v crictl || true) +CRICTL_BINARY=${CRICTL_PATH:-/usr/bin/crictl} # Path to kpod binary. KPOD_BINARY=${KPOD_BINARY:-${CRIO_ROOT}/cri-o/kpod} # Path of the conmon binary. @@ -151,11 +152,18 @@ function crio() { "$CRIO_BINARY" --listen "$CRIO_SOCKET" "$@" } +# DEPRECATED +OCIC_BINARY=${OCIC_BINARY:-${CRIO_ROOT}/cri-o/crioctl} # Run crioctl using the binary specified by $OCIC_BINARY. function crioctl() { "$OCIC_BINARY" --connect "$CRIO_SOCKET" "$@" } +# Run crictl using the binary specified by $CRICTL_BINARY. +function crictl() { + "$CRICTL_BINARY" -r "$CRIO_SOCKET" -i "$CRIO_SOCKET" "$@" +} + # Communicate with Docker on the host machine. # Should rarely use this. function docker_host() { @@ -184,7 +192,7 @@ function retry() { # Waits until the given crio becomes reachable. function wait_until_reachable() { - retry 15 1 crioctl runtimeversion + retry 15 1 crictl status } # Start crio. @@ -228,14 +236,14 @@ function start_crio() { "$CRIO_BINARY" --debug --config "$CRIO_CONFIG" & CRIO_PID=$! wait_until_reachable - run crioctl image status --id=redis:alpine + run crictl image status redis:alpine if [ "$status" -ne 0 ] ; then - crioctl image pull redis:alpine + crictl image pull redis:alpine fi - REDIS_IMAGEID=$(crioctl image status --id=redis:alpine | head -1 | sed -e "s/ID: //g") - run crioctl image status --id=mrunalp/oom + REDIS_IMAGEID=$(crictl image status redis:alpine | head -1 | sed -e "s/ID: //g") + run crictl image status mrunalp/oom if [ "$status" -ne 0 ] ; then - crioctl image pull mrunalp/oom + crictl image pull mrunalp/oom fi # # @@ -248,63 +256,63 @@ function start_crio() { # # REDIS_IMAGEID_DIGESTED="redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b" - run crioctl image status --id $REDIS_IMAGEID_DIGESTED + run crictl image status $REDIS_IMAGEID_DIGESTED if [ "$status" -ne 0 ]; then - crioctl image pull $REDIS_IMAGEID_DIGESTED + crictl image pull $REDIS_IMAGEID_DIGESTED fi # # # - run crioctl image status --id=runcom/stderr-test + run crictl image status runcom/stderr-test if [ "$status" -ne 0 ] ; then - crioctl image pull runcom/stderr-test:latest + crictl image pull runcom/stderr-test:latest fi - STDERR_IMAGEID=$(crioctl image status --id=runcom/stderr-test | head -1 | sed -e "s/ID: //g") - run crioctl image status --id=busybox + STDERR_IMAGEID=$(crictl image status runcom/stderr-test | head -1 | sed -e "s/ID: //g") + run crictl image status busybox if [ "$status" -ne 0 ] ; then - crioctl image pull busybox:latest + crictl image pull busybox:latest fi - BUSYBOX_IMAGEID=$(crioctl image status --id=busybox | head -1 | sed -e "s/ID: //g") - run crioctl image status --id=mrunalp/image-volume-test + BUSYBOX_IMAGEID=$(crictl image status busybox | head -1 | sed -e "s/ID: //g") + run crictl image status mrunalp/image-volume-test if [ "$status" -ne 0 ] ; then - crioctl image pull mrunalp/image-volume-test:latest + crictl image pull mrunalp/image-volume-test:latest fi - VOLUME_IMAGEID=$(crioctl image status --id=mrunalp/image-volume-test | head -1 | sed -e "s/ID: //g") + VOLUME_IMAGEID=$(crictl image status mrunalp/image-volume-test | head -1 | sed -e "s/ID: //g") } function cleanup_ctrs() { - run crioctl ctr list --quiet + run crictl ctr ls --quiet if [ "$status" -eq 0 ]; then if [ "$output" != "" ]; then printf '%s\n' "$output" | while IFS= read -r line do - crioctl ctr stop --id "$line" - crioctl ctr remove --id "$line" + crictl ctr stop "$line" + crictl ctr rm "$line" done fi fi } function cleanup_images() { - run crioctl image list --quiet + run crictl image ls --quiet if [ "$status" -eq 0 ]; then if [ "$output" != "" ]; then printf '%s\n' "$output" | while IFS= read -r line do - crioctl image remove --id "$line" + crictl image rm "$line" done fi fi } function cleanup_pods() { - run crioctl pod list --quiet + run crictl sandbox ls --quiet if [ "$status" -eq 0 ]; then if [ "$output" != "" ]; then printf '%s\n' "$output" | while IFS= read -r line do - crioctl pod stop --id "$line" - crioctl pod remove --id "$line" + crictl sandbox stop "$line" + crictl sandbox rm "$line" done fi fi