Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull oci-images through proxy on the lxd #1476

Merged
merged 8 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions jobs/sync-oci-images/sync-oci-images.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ pipeline {

# All CK CI images live under ./cdk in our registry
TAG_PREFIX=$REGISTRY_URL/cdk
PUSH_CREDS="-u $REGISTRY_CREDS_USR:$REGISTRY_CREDS_PSW"

pull_ctr () {
PULL_PROXY="http://squid.internal:3128"
sudo lxc exec $LXC_NAME \
--env HTTP_PROXY="${PULL_PROXY}" \
--env HTTPS_PROXY="${PULL_PROXY}" \
-- ctr content fetch ${PULL_CREDS} ${1} --all-platforms >/dev/null;
}

push_ctr () {
sudo lxc exec $LXC_NAME \
-- ctr image push ${PUSH_CREDS} ${1} >/dev/null;
}

for i in ${CI_IMAGES}
do
Expand All @@ -198,15 +212,15 @@ pipeline {
fi

# Pull upstream image
if [ "$IS_DRY_RUN" = true ] ; then
if [ "$IS_DRY_RUN" = true ]
then
echo "Dry run; would have pulled: ${i}"
else
# simple retry if initial pull fails
if ! sudo lxc exec $LXC_NAME -- ctr content fetch ${PULL_CREDS} ${i} --all-platforms >/dev/null
then
echo "Retrying pull"
if ! pull_ctr ${i} ; then
echo "Retrying pull ${i}"
sleep 5
sudo lxc exec $LXC_NAME -- ctr content fetch ${PULL_CREDS} ${i} --all-platforms >/dev/null
pull_ctr ${i}
fi
fi

Expand All @@ -228,11 +242,11 @@ pipeline {
else
sudo lxc exec $LXC_NAME -- ctr image tag ${i} ${TAG_PREFIX}/${RAW_IMAGE}
# simple retry if initial push fails
if ! sudo lxc exec $LXC_NAME -- ctr image push ${TAG_PREFIX}/${RAW_IMAGE} --user "$REGISTRY_CREDS_USR:$REGISTRY_CREDS_PSW" >/dev/null
if ! push_ctr ${TAG_PREFIX}/${RAW_IMAGE}
then
echo "Retrying push"
sleep 5
sudo lxc exec $LXC_NAME -- ctr image push ${TAG_PREFIX}/${RAW_IMAGE} --user "$REGISTRY_CREDS_USR:$REGISTRY_CREDS_PSW" >/dev/null
push_ctr ${TAG_PREFIX}/${RAW_IMAGE}
fi
fi

Expand Down Expand Up @@ -267,6 +281,20 @@ pipeline {

# All CK images are staged under ./staging/cdk in our registry
TAG_PREFIX=$REGISTRY_URL/staging/cdk
PUSH_CREDS="-u $REGISTRY_CREDS_USR:$REGISTRY_CREDS_PSW"

pull_ctr () {
PULL_PROXY="http://squid.internal:3128"
sudo lxc exec $LXC_NAME \
--env HTTP_PROXY="${PULL_PROXY}" \
--env HTTPS_PROXY="${PULL_PROXY}" \
-- ctr content fetch ${PULL_CREDS} ${1} --all-platforms >/dev/null;
}

push_ctr () {
sudo lxc exec $LXC_NAME \
-- ctr image push ${PUSH_CREDS} ${1} >/dev/null;
}

for i in ${ALL_IMAGES}
do
Expand All @@ -289,11 +317,11 @@ pipeline {
echo "Dry run; would have pulled: ${i}"
else
# simple retry if initial pull fails
if ! sudo lxc exec $LXC_NAME -- ctr content fetch ${PULL_CREDS} ${i} --all-platforms >/dev/null
if ! pull_ctr ${i}
then
echo "Retrying pull"
sleep 5
sudo lxc exec $LXC_NAME -- ctr content fetch ${PULL_CREDS} ${i} --all-platforms >/dev/null
pull_ctr ${i}
fi
fi

Expand All @@ -315,11 +343,11 @@ pipeline {
else
sudo lxc exec $LXC_NAME -- ctr image tag ${i} ${TAG_PREFIX}/${RAW_IMAGE}
# simple retry if initial push fails
if ! sudo lxc exec $LXC_NAME -- ctr image push ${TAG_PREFIX}/${RAW_IMAGE} --user "$REGISTRY_CREDS_USR:$REGISTRY_CREDS_PSW" >/dev/null
if ! push_ctr ${TAG_PREFIX}/${RAW_IMAGE}
then
echo "Retrying push"
sleep 5
sudo lxc exec $LXC_NAME -- ctr image push ${TAG_PREFIX}/${RAW_IMAGE} --user "$REGISTRY_CREDS_USR:$REGISTRY_CREDS_PSW" >/dev/null
push_ctr ${TAG_PREFIX}/${RAW_IMAGE}
fi
fi

Expand Down
Loading