Skip to content

Commit

Permalink
Merge pull request #1133 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1132-to-release-4.14

[release-4.14] OCPBUGS-19499: prioritize podman pull in etcdctl dl
  • Loading branch information
openshift-ci[bot] committed Oct 12, 2023
2 parents ccb1763 + 00ddf55 commit a30b074
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
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 a30b074

Please sign in to comment.