Skip to content

Commit

Permalink
OCPBUGS-19052: prioritize podman pull in etcdctl dl
Browse files Browse the repository at this point in the history
  • Loading branch information
tjungblu authored and openshift-cherrypick-robot committed Oct 5, 2023
1 parent 67b5247 commit 00ddf55
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
34 changes: 20 additions & 14 deletions bindata/etcd/etcd-common-tools
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand Down
34 changes: 20 additions & 14 deletions pkg/operator/etcd_assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00ddf55

Please sign in to comment.