Skip to content

Commit

Permalink
one project share one default bucket (kubeflow#3478)
Browse files Browse the repository at this point in the history
  • Loading branch information
Renmin authored and Jeffwan committed Dec 9, 2020
1 parent b2f0f2b commit 4371eea
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions manifests/gcp_marketplace/deployer/init_action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ function set_bucket_and_configmap() {
# config map.
#
# Usage:
# set_bucket_and_configmap NUM_RETRIES
NUM_RETRIES=$1
# set_bucket_and_configmap
CONFIG_NAME="gcp-default-config"

# Detect GCP project
Expand All @@ -33,15 +32,13 @@ function set_bucket_and_configmap() {
return 0
fi

for i in $(seq 1 ${NUM_RETRIES})
do
bucket_name="${GCP_PROJECT_ID}-kubeflowpipelines-default"
bucket_is_set=true
gsutil ls ${bucket_name} || bucket_is_set=false
if [ "$bucket_is_set" = false ]; then
bucket_is_set=true
bucket_name="hostedkfp-default-$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 10 | head -n 1)"
gsutil mb -p ${GCP_PROJECT_ID} "gs://${bucket_name}/" || bucket_is_set=false
if [ "$bucket_is_set" = true ]; then
break
fi
done
gsutil mb -p ${GCP_PROJECT_ID} "gs://${bucket_name}/" || bucket_is_set=false
fi

# Populate configmap, with name gcp-default-config
if [ "${bucket_is_set}" = true ]; then
Expand All @@ -50,7 +47,7 @@ function set_bucket_and_configmap() {
--from-literal has_default_bucket="true" \
--from-literal project_id="${GCP_PROJECT_ID}"
else
echo "Cannot successfully create bucket after ${NUM_RETRIES} attempts. Fall back to not specifying default bucket."
echo "Cannot successfully create bucket. Fall back to not specifying default bucket."
kubectl create configmap -n "${NAMESPACE}" "${CONFIG_NAME}" \
--from-literal bucket_name="<your-bucket>" \
--from-literal has_default_bucket="false" \
Expand All @@ -68,6 +65,6 @@ NAMESPACE="$(/bin/print_config.py \
export NAME
export NAMESPACE

set_bucket_and_configmap 10
set_bucket_and_configmap

echo "init_action done"

0 comments on commit 4371eea

Please sign in to comment.