diff --git a/Makefile b/Makefile index f11ae576..7c22e24d 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,13 @@ export PATH := $(GOBIN):$(PATH):$(BIN_DIR) GOPATH = $(CURDIR)/.gopath ORG_PATH = github.com/k8snetworkplumbingwg PACKAGE = ovs-cni +OCI_BIN ?= $(shell if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi) REPO_PATH = $(ORG_PATH)/$(PACKAGE) BASE = $(GOPATH)/src/$(REPO_PATH) PKGS = $(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "$(PACKAGE)/vendor/" | grep -v "$(PACKAGE)/tests/cluster" | grep -v "$(PACKAGE)/tests/node")) V = 0 Q = $(if $(filter 1,$V),,@) +TLS_SETTING := $(if $(filter $(OCI_BIN),podman),--tls-verify=false,) all: lint build @@ -78,14 +80,14 @@ functest: $(GO) docker-build: $(patsubst %, docker-build-%, $(COMPONENTS)) docker-build-%: build-% - docker build -t ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ./cmd/$(subst -,/,$*) + $(OCI_BIN) build -t ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ./cmd/$(subst -,/,$*) docker-push: $(patsubst %, docker-push-%, $(COMPONENTS)) docker-push-%: - docker push ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} - docker tag ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG} - docker push ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG} + $(OCI_BIN) push ${TLS_SETTING} ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} + $(OCI_BIN) tag ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG} + $(OCI_BIN) push ${TLS_SETTING} ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG} dep: $(GO) $(GO) mod tidy diff --git a/automation/check-patch.e2e.sh b/automation/check-patch.e2e.sh index cd6292b3..f36310dc 100755 --- a/automation/check-patch.e2e.sh +++ b/automation/check-patch.e2e.sh @@ -2,7 +2,7 @@ # This script should be able to execute functional tests against Kubernetes # cluster on any environment with basic dependencies listed in -# check-patch.packages installed and docker running. +# check-patch.packages installed and podman / docker running. # # yum -y install automation/check-patch.packages # automation/check-patch.e2e.sh diff --git a/cluster/cluster.sh b/cluster/cluster.sh index 1c4dd0b6..d098f392 100755 --- a/cluster/cluster.sh +++ b/cluster/cluster.sh @@ -13,7 +13,7 @@ # limitations under the License. export KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-'k8s-1.23'} -export KUBEVIRTCI_TAG='2202081102-e8daf721' +export KUBEVIRTCI_TAG=2205030954-99bd4d1 KUBEVIRTCI_REPO='https://github.com/kubevirt/kubevirtci.git' # The CLUSTER_PATH var is used in cluster folder and points to the _kubevirtci where the cluster is deployed from. diff --git a/hack/common.sh b/hack/common.sh index 4ee70e03..fa89d9d6 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -61,3 +61,13 @@ function kubevirt_version() { fi } KUBEVIRT_VERSION="$(kubevirt_version)" + +determine_cri_bin() { + if podman ps >/dev/null 2>&1; then + echo podman + elif docker ps >/dev/null 2>&1; then + echo docker + else + echo "" + fi +} diff --git a/hack/dockerized b/hack/dockerized index 42a3d74d..291cc288 100755 --- a/hack/dockerized +++ b/hack/dockerized @@ -4,6 +4,7 @@ set -e source $(dirname "$0")/common.sh DOCKER_DIR=${KUBEVIRT_DIR}/hack/docker-builder +OCI_BIN=${OCI_BIN:-$(determine_cri_bin)} SYNC_OUT=${SYNC_OUT:-true} @@ -20,26 +21,26 @@ if [ -n "$JOB_NAME" -o -n "$TRAVIS_BUILD_ID" ]; then fi # Build the build container -(cd ${DOCKER_DIR} && docker build . ${BUILD_QUIET} -t ${BUILDER}) +(cd ${DOCKER_DIR} && ${OCI_BIN} build . ${BUILD_QUIET} -t ${BUILDER}) # Create the persistent docker volume -if [ -z "$(docker volume list | grep ${BUILDER})" ]; then - docker volume create --name ${BUILDER} +if [ -z "$($OCI_BIN volume list | grep ${BUILDER})" ]; then + ${OCI_BIN} volume create ${BUILDER} fi # Make sure that the output directory exists -docker run -v "${BUILDER}:/root:rw,z" --security-opt label:disable --rm ${BUILDER} mkdir -p /root/go/src/github.com/k8snetworkplumbingwg/ovs-cni/_out +${OCI_BIN} run -v "${BUILDER}:/root:rw,z" --security-opt label=disable --rm ${BUILDER} mkdir -p /root/go/src/github.com/k8snetworkplumbingwg/ovs-cni/_out # Start an rsyncd instance and make sure it gets stopped after the script exits -RSYNC_CID=$(docker run -d -v "${BUILDER}:/root:rw,z" --security-opt label:disable --expose 873 -P ${BUILDER} /usr/bin/rsync --no-detach --daemon --verbose) +RSYNC_CID=$($OCI_BIN run -d -v "${BUILDER}:/root:rw,z" --security-opt label=disable --expose 873 -P ${BUILDER} /usr/bin/rsync --no-detach --daemon --verbose) function finish() { - docker stop ${RSYNC_CID} >/dev/null 2>&1 & - docker rm -f ${RSYNC_CID} >/dev/null 2>&1 & + ${OCI_BIN} stop ${RSYNC_CID} >/dev/null 2>&1 & + ${OCI_BIN} rm -f ${RSYNC_CID} >/dev/null 2>&1 & } trap finish EXIT -RSYNCD_PORT=$(docker port $RSYNC_CID 873 | cut -d':' -f2) +RSYNCD_PORT=$($OCI_BIN port $RSYNC_CID 873 | cut -d':' -f2) rsynch_fail_count=0 @@ -70,7 +71,7 @@ _rsync --delete --exclude 'cluster/**/.kubectl' --exclude 'cluster/**/.oc' --exc # Run the command test -t 1 && USE_TTY="-it" -docker run --rm -v "${BUILDER}:/root:rw,z" --security-opt label:disable ${USE_TTY} -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} "$@" +${OCI_BIN} run --rm -v "${BUILDER}:/root:rw,z" --security-opt label=disable ${USE_TTY} -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} "$@" # Copy the whole kubevirt data out to get generated sources and formatting changes _rsync --exclude 'cluster/**/.kubectl' --exclude 'cluster/**/.oc' --exclude 'cluster/**/.kubeconfig' --exclude "_out" --exclude "vendor" --exclude ".git" "rsync://root@127.0.0.1:${RSYNCD_PORT}/build" ${KUBEVIRT_DIR}/ diff --git a/hack/test-dockerized.sh b/hack/test-dockerized.sh index 1e1ac53f..e2c48872 100755 --- a/hack/test-dockerized.sh +++ b/hack/test-dockerized.sh @@ -21,6 +21,7 @@ set -e source $(dirname "$0")/common.sh DOCKER_DIR=${KUBEVIRT_DIR}/hack/docker-builder +OCI_BIN=${OCI_BIN:-$(determine_cri_bin)} SYNC_OUT=${SYNC_OUT:-true} @@ -37,6 +38,6 @@ if [ -n "$JOB_NAME" -o -n "$TRAVIS_BUILD_ID" ]; then fi # Build the build container -(cd ${DOCKER_DIR} && docker build . ${BUILD_QUIET} -t ${BUILDER}) +(cd ${DOCKER_DIR} && ${OCI_BIN} build . ${BUILD_QUIET} -t ${BUILDER}) -docker run --rm --privileged --network host --cap-add ALL -v /lib/modules:/lib/modules -v `pwd`:/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} make test +${OCI_BIN} run --rm --privileged --network host -v /lib/modules:/lib/modules -v `pwd`:/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} make test