Skip to content

Commit b60c168

Browse files
authored
Merge pull request #1229 from justaugustus/vdf
[VDF] Partial revert of k8s.gcr.io cutover
2 parents 2614864 + 36eb1e7 commit b60c168

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

anago

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,12 @@ copy_logs_to_workdir () {
259259
}
260260

261261
###############################################################################
262-
# Ensures we have write access to a specified registry
263-
# @param registry - A registry to check the ACLs for
262+
# Ensures all registries that will be used during both mock and --nomock
263+
# runs allow write access so we don't fall over later
264+
# @param registries - A space separated list of registries
264265
#
265266
ensure_registry_acls () {
266-
local registry="$1"
267+
local registries=($1)
267268
local emptyfile="$TMPDIR/empty-file.$$"
268269
local gs_path
269270
local r
@@ -275,30 +276,27 @@ ensure_registry_acls () {
275276

276277
# Short of creating a hardcoded map of project-id to registry, translating
277278
# _ to - seems to be a simple rule to keep this, well, simple.
278-
r=${registry//_/-}
279-
280-
# When we are no-mock mode we need to perform an image promotion, so it's
281-
# unnecessary to check for write access to the production container registry.
282-
if ((FLAGS_nomock)); then
283-
logecho -n "Skipping container registry ACL check on $GCRIO_PATH_PROD in no-mock mode: "
284-
logecho $OK
285-
return 0
286-
else
287-
artifact_namespace="${r/gcr.io\//}"
288-
fi
279+
for r in ${registries[*]//_/-}; do
280+
# In this context, "google-containers" is still used
281+
if [[ "$r" == "$GCRIO_PATH_PROD" ]]; then
282+
artifact_namespace="google-containers"
283+
else
284+
artifact_namespace="${r/gcr.io\//}"
285+
fi
289286

290-
gs_path="gs://artifacts.$artifact_namespace.appspot.com/containers"
291-
logecho -n "Checking write access to registry $r: "
292-
if logrun $GSUTIL -q cp $emptyfile $gs_path && \
293-
logrun $GSUTIL -q rm $gs_path/${emptyfile##*/}; then
294-
logecho $OK
295-
else
296-
logecho $FAILED
297-
((retcode++))
298-
fi
287+
gs_path="gs://artifacts.$artifact_namespace.appspot.com/containers"
288+
logecho -n "Checking write access to registry $r: "
289+
if logrun $GSUTIL -q cp $emptyfile $gs_path && \
290+
logrun $GSUTIL -q rm $gs_path/${emptyfile##*/}; then
291+
logecho $OK
292+
else
293+
logecho $FAILED
294+
((retcode++))
295+
fi
299296

300-
# Always reset back to $USER
301-
((FLAGS_gcb)) || logrun $GCLOUD config set account $GCP_USER
297+
# Always reset back to $USER
298+
((FLAGS_gcb)) || logrun $GCLOUD config set account $GCP_USER
299+
done
302300

303301
logrun rm -f $emptyfile
304302

@@ -380,7 +378,7 @@ check_prerequisites () {
380378

381379
# Verify write access to all container registries that might be used
382380
# to ensure both mock and --nomock runs will work.
383-
ensure_registry_acls "$GCRIO_PATH" || return 1
381+
ensure_registry_acls "${ALL_CONTAINER_REGISTRIES[*]}" || return 1
384382

385383
logecho -n "Checking cloud project state: "
386384
GCLOUD_PROJECT=$($GCLOUD config get-value project 2>/dev/null)
@@ -1446,13 +1444,8 @@ push_all_artifacts () {
14461444
gs://$RELEASE_BUCKET/$BUCKET_TYPE/$version || return 1
14471445
fi
14481446

1449-
# When we are no-mock mode we need to perform an image promotion, so
1450-
# instead of pushing to the production container registry, we validate
1451-
# that the manifest is populated on the remote registry.
1452-
if ! ((FLAGS_nomock)); then
1453-
common::runstep release::docker::release \
1447+
common::runstep release::docker::release \
14541448
$KUBE_DOCKER_REGISTRY $version $BUILD_OUTPUT-$version || return 1
1455-
fi
14561449

14571450
common::runstep release::docker::validate_remote_manifests \
14581451
$KUBE_DOCKER_REGISTRY $version $BUILD_OUTPUT-$version || return 1

lib/releaselib.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ readonly GCRIO_PATH_PROD="k8s.gcr.io"
3434
# TODO(vdf): Remove all GCRIO_PATH_PROD_PUSH logic once the k8s.gcr.io vanity
3535
# domain flip (VDF) is successful
3636
readonly GCRIO_PATH_PROD_PUSH="gcr.io/google-containers"
37-
readonly GCRIO_PATH_TEST="gcr.io/k8s-staging-kubernetes"
37+
readonly GCRIO_PATH_TEST="gcr.io/$TEST_PROJECT"
3838

3939
readonly KUBE_CROSS_REGISTRY="us.gcr.io/k8s-artifacts-prod/build-image"
4040
readonly KUBE_CROSS_IMAGE="${KUBE_CROSS_REGISTRY}/kube-cross"
@@ -1362,6 +1362,9 @@ release::send_announcement () {
13621362
# READ_RELEASE_BUCKETS - array of readable buckets for multiple sourcing of
13631363
# mock staged builds
13641364
# GCRIO_PATH - GCR path based on mock or --nomock
1365+
# ALL_CONTAINER_REGISTRIES - when running mock (via GCB) this array also
1366+
# contains k8s.gcr.io so we can check access in mock
1367+
# mode before an actual release occurs
13651368
release::set_globals () {
13661369
logecho -n "Setting global variables: "
13671370

@@ -1388,6 +1391,7 @@ release::set_globals () {
13881391
fi
13891392

13901393
GCRIO_PATH="${FLAGS_gcrio_path:-$GCRIO_PATH_TEST}"
1394+
ALL_CONTAINER_REGISTRIES=("$GCRIO_PATH")
13911395

13921396
if ((FLAGS_nomock)); then
13931397
RELEASE_BUCKET="$PROD_BUCKET"
@@ -1420,6 +1424,8 @@ release::set_globals () {
14201424
WRITE_RELEASE_BUCKETS=("$RELEASE_BUCKET")
14211425
READ_RELEASE_BUCKETS+=("$RELEASE_BUCKET")
14221426

1427+
ALL_CONTAINER_REGISTRIES=("$GCRIO_PATH")
1428+
14231429
# TODO:
14241430
# These KUBE_ globals extend beyond the scope of the new release refactored
14251431
# tooling so to pass these through as flags will require fixes across

0 commit comments

Comments
 (0)