This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix permission issue in k8s-dataflow (close #140)
- Loading branch information
1 parent
75bc2fd
commit af945d5
Showing
3 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM snowplow-docker-registry.bintray.io/snowplow/base-debian:0.1.0 | ||
LABEL MAINTAINER="Snowplow Analytics Ltd. <[email protected]>" | ||
|
||
RUN \ | ||
mkdir -p /var/lib/apt/lists/partial &&\ | ||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list &&\ | ||
apt-get update &&\ | ||
apt-get install -y apt-transport-https ca-certificates wget gnupg &&\ | ||
wget -O - http://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - &&\ | ||
apt-get update &&\ | ||
apt-get install -y python google-cloud-sdk=302.0.0-0 &&\ | ||
apt-get purge -y --auto-remove gnupg | ||
|
||
USER snowplow | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
ENTRYPOINT [ "docker-entrypoint.sh" ] | ||
|
||
CMD [ "" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
|
||
DELAY=3 | ||
THRESHOLD=5 | ||
BUCKET="" | ||
|
||
ITER=0 | ||
PARAMS="" | ||
|
||
# extract params | ||
for opt in "$@"; do | ||
case "$opt" in | ||
--tempLocation=*) | ||
BUCKET="${opt#*=}" | ||
PARAMS="$PARAMS $opt" | ||
shift | ||
;; | ||
--gcpTempLocation=*) | ||
BUCKET="${opt#*=}" | ||
PARAMS="$PARAMS $opt" | ||
shift | ||
;; | ||
--gcsThreshold=*) | ||
THRESHOLD="${opt#*=}" | ||
shift | ||
;; | ||
--gcsDelay=*) | ||
DELAY="${opt#*=}" | ||
shift | ||
;; | ||
*) # preserve positional arguments | ||
PARAMS="$PARAMS $opt" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$BUCKET" ]; then | ||
echo "Missing --tempLocation flag. Exiting." | ||
exit 1 | ||
fi | ||
|
||
echo "params: ${PARAMS} threshold: ${THRESHOLD} delay: ${DELAY} GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS:-Not Available}" | ||
|
||
# enable service account if credentials are available | ||
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then | ||
echo "GOOGLE_APPLICATION_CREDENTIALS is not defined, gcloud isn't authenticated!" | ||
exit 1 | ||
else | ||
gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS" | ||
fi | ||
|
||
# wait for GCS bucket to be available | ||
while [ "$ITER" -le "$THRESHOLD" ]; do | ||
if gsutil ls -b "${BUCKET}"; | ||
then | ||
echo "Bucket ${BUCKET} exists! Proceeding." | ||
break | ||
else | ||
echo "Bucket ${BUCKET} does not exist. Retry: ${ITER}/${THRESHOLD}" | ||
sleep "${DELAY}" | ||
ITER=$(( ITER+1 )) | ||
fi | ||
done | ||
|
||
# check if retry limit was reached or not | ||
if [ "$ITER" -le "$THRESHOLD" ]; then | ||
$PARAMS | ||
else | ||
echo "Bucket ${BUCKET} does not exist. Not retrying anymore." | ||
exit 1 | ||
fi |