From ae45c176e41c7d7acf51cf26078a37408b5202e1 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 30 May 2017 15:39:56 +0200 Subject: [PATCH] *: initial wire in of crictl from cri-tools Signed-off-by: Antonio Murdaca --- Dockerfile | 11 ++++ contrib/test/crio-integration-playbook.yaml | 14 +++++ test/helpers.bash | 57 ++++++++++++--------- 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b5cb796..c625a594 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,6 +67,17 @@ RUN set -x \ && cp bin/* /opt/cni/bin/ \ && rm -rf "$GOPATH" +# Install crictl +ENV CRICTL_COMMIT c8786e315514a021c53888d874b1fb33e967a23c +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 e5e4f06e..15662e26 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,14 @@ 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/ + async: 600 + poll: 10 - name: make runc make: params: BUILDTAGS="seccomp selinux" diff --git a/test/helpers.bash b/test/helpers.bash index a52f63f3..601ad1a0 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 of the conmon binary. CONMON_BINARY=${CONMON_BINARY:-${CRIO_ROOT}/cri-o/conmon/conmon} # Path of the pause binary. @@ -126,11 +127,17 @@ function crio() { "$CRIO_BINARY" --listen "$CRIO_SOCKET" "$@" } -# Run crioctl using the binary specified by $OCIC_BINARY. +# DEPRECATED +OCIC_BINARY=${OCIC_BINARY:-${CRIO_ROOT}/cri-o/crioctl} 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() { @@ -159,7 +166,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. @@ -202,14 +209,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 # # @@ -222,58 +229,58 @@ 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") + BUSYBOX_IMAGEID=$(crictl image status busybox | 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" || true - crioctl ctr remove --id "$line" + crictl ctr stop "$line" || true + 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" || true - crioctl pod remove --id "$line" + crictl sandbox stop "$line" || true + crictl sandbox rm "$line" done fi fi