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

In s390x publish centos9 and kubevirtci jobs, do GCS calls without auth where possible #3945

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ periodics:
CHECK_INTERVAL=30 &&
source /usr/local/bin/gcs_restapi.sh &&
while true; do
if stat_gcs_file kubevirt-prow "$GCS_FILE_PATH"; then
if stat_gcs_file kubevirt-prow "$GCS_FILE_PATH" "false"; then
echo "File $GCS_FILE_PATH is now available."
break
else
echo "File $GCS_FILE_PATH not found. Checking again in $CHECK_INTERVAL seconds."
sleep $CHECK_INTERVAL
fi
done
KUBEVIRTCI_TAG=$(cat_gcs_file kubevirt-prow "$GCS_FILE_PATH")
KUBEVIRTCI_TAG=$(cat_gcs_file kubevirt-prow "$GCS_FILE_PATH" "false")
if [ $? -ne 0 ]; then
echo "Failed to fetch KUBEVIRTCI_TAG"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ postsubmits:
source /usr/local/bin/gcs_restapi.sh &&
CHECK_INTERVAL=30 &&
while true; do
if stat_gcs_file kubevirt-prow "$GCS_FILE_PATH"; then
if stat_gcs_file kubevirt-prow "$GCS_FILE_PATH" "false"; then
echo "File $GCS_FILE_PATH is now available."
break
else
echo "File $GCS_FILE_PATH not found. Checking again in $CHECK_INTERVAL seconds."
sleep $CHECK_INTERVAL
fi
done &&
KUBEVIRTCI_TAG=$(cat_gcs_file kubevirt-prow "$GCS_FILE_PATH")
KUBEVIRTCI_TAG=$(cat_gcs_file kubevirt-prow "$GCS_FILE_PATH" "false")
if [ $? -ne 0 ]; then
echo "Failed to fetch KUBEVIRTCI_TAG"
exit 1
Expand Down
25 changes: 19 additions & 6 deletions images/bootstrap/gcs_restapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ upload_to_gcs() {
stat_gcs_file() {
local bucket_name="$1"
local gcs_file_path=$(urlencode_path "$2")
local auth="$3"

get_access_token
if [ "$auth" == "false" ]; then
auth_header=""
else
get_access_token
auth_header="-H \"Authorization: Bearer $access_token\""
fi

stat_response=$(curl -s -X GET \
-H "Authorization: Bearer $access_token" \
$auth_header \
"${BASE_URL}/storage/v1/b/$bucket_name/o/$gcs_file_path")

if echo "$stat_response" | jq -e '.error' > /dev/null; then
Expand All @@ -99,12 +105,19 @@ stat_gcs_file() {
cat_gcs_file() {
local bucket_name="$1"
local gcs_file_path=$(urlencode_path "$2")
local auth="$3"

get_access_token
if [ "$auth" == "false" ]; then
auth_header=""
else
get_access_token
auth_header="-H \"Authorization: Bearer $access_token\""
fi

file_content=$(curl -s -X GET \
-H "Authorization: Bearer $access_token" \
"${BASE_URL}/storage/v1/b/$bucket_name/o/$gcs_file_path?alt=media")
file_content=$(curl --silent --fail -X GET \
$auth_header \
-H "Cache-Control: no-cache" \
"${BASE_URL}/storage/v1/b/$bucket_name/o/$gcs_file_path?alt=media&ignoreCache=1")

if [ -z "$file_content" ]; then
echo "Error: No content received"
Expand Down