From 00ddf5566330cae85bf1b3e5f0a4662cb7ad813d Mon Sep 17 00:00:00 2001 From: Thomas Jungblut Date: Thu, 5 Oct 2023 14:59:43 +0200 Subject: [PATCH] OCPBUGS-19052: prioritize podman pull in etcdctl dl --- bindata/etcd/etcd-common-tools | 34 +++++++++++++++++------------ pkg/operator/etcd_assets/bindata.go | 34 +++++++++++++++++------------ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/bindata/etcd/etcd-common-tools b/bindata/etcd/etcd-common-tools index 9f1a739bc..8d501756b 100644 --- a/bindata/etcd/etcd-common-tools +++ b/bindata/etcd/etcd-common-tools @@ -15,7 +15,24 @@ export ETCD_ETCDCTL_BIN="etcdctl" function dl_etcdctl { # Avoid caching the binary when podman exists, the etcd image is always available locally and we need a way to update etcdctl. # When we're running from an etcd image there's no podman and we can continue without a download. - if ([ ! -x "$(command -v podman)" ] || [ -x "$(command -v etcdctl)" ]); then + if ([ -n "$(command -v podman)" ]); then + local etcdimg=${ETCD_IMAGE} + local etcdctr=$(podman create --authfile=/var/lib/kubelet/config.json ${etcdimg}) + local etcdmnt=$(podman mount "${etcdctr}") + [ ! -d ${ETCDCTL_BIN_DIR} ] && mkdir -p ${ETCDCTL_BIN_DIR} + cp ${etcdmnt}/bin/etcdctl ${ETCDCTL_BIN_DIR}/ + if [ -f "${etcdmnt}/bin/etcdutl" ]; then + cp ${etcdmnt}/bin/etcdutl ${ETCDCTL_BIN_DIR}/ + export ETCD_ETCDUTL_BIN=etcdutl + fi + + umount "${etcdmnt}" + podman rm "${etcdctr}" + etcdctl version + return + fi + + if ([ -x "$(command -v etcdctl)" ]); then echo "etcdctl is already installed" if [ -x "$(command -v etcdutl)" ]; then echo "etcdutl is already installed" @@ -25,19 +42,8 @@ function dl_etcdctl { return fi - local etcdimg=${ETCD_IMAGE} - local etcdctr=$(podman create --authfile=/var/lib/kubelet/config.json ${etcdimg}) - local etcdmnt=$(podman mount "${etcdctr}") - [ ! -d ${ETCDCTL_BIN_DIR} ] && mkdir -p ${ETCDCTL_BIN_DIR} - cp ${etcdmnt}/bin/etcdctl ${ETCDCTL_BIN_DIR}/ - if [ -f "${etcdmnt}/bin/etcdutl" ]; then - cp ${etcdmnt}/bin/etcdutl ${ETCDCTL_BIN_DIR}/ - export ETCD_ETCDUTL_BIN=etcdutl - fi - - umount "${etcdmnt}" - podman rm "${etcdctr}" - etcdctl version + echo "Could neither pull etcdctl nor find it locally in cache. Aborting!" + exit 1 } function check_snapshot_status() { diff --git a/pkg/operator/etcd_assets/bindata.go b/pkg/operator/etcd_assets/bindata.go index 667cd12d8..19e0cc215 100644 --- a/pkg/operator/etcd_assets/bindata.go +++ b/pkg/operator/etcd_assets/bindata.go @@ -838,7 +838,24 @@ export ETCD_ETCDCTL_BIN="etcdctl" function dl_etcdctl { # Avoid caching the binary when podman exists, the etcd image is always available locally and we need a way to update etcdctl. # When we're running from an etcd image there's no podman and we can continue without a download. - if ([ ! -x "$(command -v podman)" ] || [ -x "$(command -v etcdctl)" ]); then + if ([ -n "$(command -v podman)" ]); then + local etcdimg=${ETCD_IMAGE} + local etcdctr=$(podman create --authfile=/var/lib/kubelet/config.json ${etcdimg}) + local etcdmnt=$(podman mount "${etcdctr}") + [ ! -d ${ETCDCTL_BIN_DIR} ] && mkdir -p ${ETCDCTL_BIN_DIR} + cp ${etcdmnt}/bin/etcdctl ${ETCDCTL_BIN_DIR}/ + if [ -f "${etcdmnt}/bin/etcdutl" ]; then + cp ${etcdmnt}/bin/etcdutl ${ETCDCTL_BIN_DIR}/ + export ETCD_ETCDUTL_BIN=etcdutl + fi + + umount "${etcdmnt}" + podman rm "${etcdctr}" + etcdctl version + return + fi + + if ([ -x "$(command -v etcdctl)" ]); then echo "etcdctl is already installed" if [ -x "$(command -v etcdutl)" ]; then echo "etcdutl is already installed" @@ -848,19 +865,8 @@ function dl_etcdctl { return fi - local etcdimg=${ETCD_IMAGE} - local etcdctr=$(podman create --authfile=/var/lib/kubelet/config.json ${etcdimg}) - local etcdmnt=$(podman mount "${etcdctr}") - [ ! -d ${ETCDCTL_BIN_DIR} ] && mkdir -p ${ETCDCTL_BIN_DIR} - cp ${etcdmnt}/bin/etcdctl ${ETCDCTL_BIN_DIR}/ - if [ -f "${etcdmnt}/bin/etcdutl" ]; then - cp ${etcdmnt}/bin/etcdutl ${ETCDCTL_BIN_DIR}/ - export ETCD_ETCDUTL_BIN=etcdutl - fi - - umount "${etcdmnt}" - podman rm "${etcdctr}" - etcdctl version + echo "Could neither pull etcdctl nor find it locally in cache. Aborting!" + exit 1 } function check_snapshot_status() {