Skip to content

Commit a0a6ebc

Browse files
committed
anago: Skip ACL check on production container registry
Signed-off-by: Stephen Augustus <saugustus@vmware.com>
1 parent 7e2a7ef commit a0a6ebc

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

anago

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

261261
###############################################################################
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
262+
# Ensures we have write access to a specified registry
263+
# @param registry - A registry to check the ACLs for
265264
#
266265
ensure_registry_acls () {
267-
local registries=($1)
266+
local registry="$1"
268267
local emptyfile="$TMPDIR/empty-file.$$"
269268
local gs_path
270269
local r
@@ -276,27 +275,29 @@ ensure_registry_acls () {
276275

277276
# Short of creating a hardcoded map of project-id to registry, translating
278277
# _ to - seems to be a simple rule to keep this, well, simple.
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
278+
r=${registry//_/-}
286279

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
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 "Skipping registry ACL check on $GCRIO_PATH_PROD in no-mock mode"
284+
return 0
285+
else
286+
artifact_namespace="${r/gcr.io\//}"
287+
fi
296288

297-
# Always reset back to $USER
298-
((FLAGS_gcb)) || logrun $GCLOUD config set account $GCP_USER
299-
done
289+
gs_path="gs://artifacts.$artifact_namespace.appspot.com/containers"
290+
logecho -n "Checking write access to registry $r: "
291+
if logrun $GSUTIL -q cp $emptyfile $gs_path && \
292+
logrun $GSUTIL -q rm $gs_path/${emptyfile##*/}; then
293+
logecho $OK
294+
else
295+
logecho $FAILED
296+
((retcode++))
297+
fi
298+
299+
# Always reset back to $USER
300+
((FLAGS_gcb)) || logrun $GCLOUD config set account $GCP_USER
300301

301302
logrun rm -f $emptyfile
302303

@@ -378,7 +379,7 @@ check_prerequisites () {
378379

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

383384
logecho -n "Checking cloud project state: "
384385
GCLOUD_PROJECT=$($GCLOUD config get-value project 2>/dev/null)

lib/releaselib.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,6 @@ release::send_announcement () {
12771277
# READ_RELEASE_BUCKETS - array of readable buckets for multiple sourcing of
12781278
# mock staged builds
12791279
# GCRIO_PATH - GCR path based on mock or --nomock
1280-
# ALL_CONTAINER_REGISTRIES - when running mock (via GCB) this array also
1281-
# contains k8s.gcr.io so we can check access in mock
1282-
# mode before an actual release occurs
12831280
release::set_globals () {
12841281
logecho -n "Setting global variables: "
12851282

@@ -1306,7 +1303,6 @@ release::set_globals () {
13061303
fi
13071304

13081305
GCRIO_PATH="${FLAGS_gcrio_path:-$GCRIO_PATH_TEST}"
1309-
ALL_CONTAINER_REGISTRIES=("$GCRIO_PATH")
13101306

13111307
if ((FLAGS_nomock)); then
13121308
RELEASE_BUCKET="$PROD_BUCKET"
@@ -1339,8 +1335,6 @@ release::set_globals () {
13391335
WRITE_RELEASE_BUCKETS=("$RELEASE_BUCKET")
13401336
READ_RELEASE_BUCKETS+=("$RELEASE_BUCKET")
13411337

1342-
ALL_CONTAINER_REGISTRIES=("$GCRIO_PATH")
1343-
13441338
# TODO:
13451339
# These KUBE_ globals extend beyond the scope of the new release refactored
13461340
# tooling so to pass these through as flags will require fixes across

0 commit comments

Comments
 (0)