Skip to content

gcp: adding image check before creating image #589

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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

beraldoleal
Copy link
Member

@beraldoleal beraldoleal commented Mar 25, 2025

As following other providers logic. A follow up to #584.

@openshift-ci openshift-ci bot requested review from gkurz and jensfr March 25, 2025 14:36
@beraldoleal
Copy link
Member Author

@bpradipt @littlejawa, yesterday I force pushed this commit to the PR branch, I remember seeing that commit on that PR, for some reason, it looks like it got lost, maybe with another force-push. So my bad.

As following other providers logic.

Signed-off-by: Beraldo Leal <[email protected]>
Copy link

openshift-ci bot commented Mar 26, 2025

@beraldoleal: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Contributor

@bpradipt bpradipt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm


# This command returns something like this:
# https://www.googleapis.com/compute/v1/projects/my-project/global/images/my-image
# Use `cut` to the image name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is obvious that cut is used below, it is less obvious what we want to drop.

Suggested change
# Use `cut` to the image name
# we want to drop the leading "https://www.googleapis.com/compute/v1/"

--project="${GCP_PROJECT_ID}" \
--format='get(selfLink)' 2>/dev/null | cut -d/ -f6-)

if [[ $? -ne 0 ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this branch is dead code.

greg@bahia:~$ image_path=$(false | cut -d/ -f6-)
greg@bahia:~$ echo $?
0

else
echo "Image mismatch: GCP image (${image_path}) different from ConfigMap (${latest_image_id})."
return 2
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image_exists function turns out to have non-trivial semantics, not just returning true or false. IMO it would be clearer to open-code it in its unique caller. This would spare the need for the exit status values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcp: adding image check before creating image
As following other providers logic.

Signed-off-by: Beraldo Leal [email protected]

The commit message would be a good place to describe the various cases that need to be handled BTW.

In the meantime, I went to #584 and I realized that you borrowed the convoluted image_exists pattern from there and it is already merged 😞 ... well, I guess I won't fight if everyone is apparently happy with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants