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

fix: emit CloudRunServiceReady event even if default url is disabled #9523

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

bskaplan
Copy link
Contributor

@bskaplan bskaplan commented Sep 10, 2024

Fixes: #9522

Description
Only emit CloudRunServiceReady event if the status is success, and emit it even if no URL is present which could be the case if default-url-disabled is set to true

User facing changes (remove if N/A)
Before:
A creation or update of a service with annotation run.googleapis.com/default-url-disabled: true would not emit a CloudRunServiceReady event.
If an update of an existing service failed, CloudRunServiceReady event would be emitted.

After:
A CloudRunServiceReady event is only populated if the Ready condition is successful, and is populated even if the default URL is disabled.

if r.url != "" {
eventV2.CloudRunServiceReady(r.path, r.url, r.latestRevision)
url := r.url
if url == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'll be better to check if the service definition contains the feature flags:

run.googleapis.com/launch-stage: 'BETA'
run.googleapis.com/default-url-disabled: 'true'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to hard-code this to that specific feature (I also definitely don't want to base it on the launch stage because that'll be removed when the feature goes GA). I think it makes more sense to trigger the event any time the service goes ready regardless of whether there's a URL or not, and as this feature shows a URL being present is not a requirement for a service going ready.

if url == "" {
// a URL may not be present if the default URL is disabled. Use - instead of empty in case anyone is parsing the
// event status
url = "-"
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not obvious that the URL can be not URL, but "dash". what if someone uses it like this:

if r.url != "" {
   ....
}

the condition will be true, because the URL is not empty, but contains "-"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, keeping it as empty

@idsulik
Copy link
Contributor

idsulik commented Sep 11, 2024

@bskaplan , thank you for the contribution, I'm not the maintainer, but I left a couple of comments

@renzodavid9 renzodavid9 added the kokoro:force-run forces a kokoro re-run on a PR label Sep 17, 2024
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Sep 17, 2024
if r.url != "" {
eventV2.CloudRunServiceReady(r.path, r.url, r.latestRevision)
}
url := r.url
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: looks like we don't need this url variable anymore

@renzodavid9
Copy link
Contributor

Hey @bskaplan, thanks for helping us with this one 😄. Just a small nit, but it looks good. Just waiting for the integration test to finish.

@renzodavid9 renzodavid9 enabled auto-merge (squash) September 18, 2024 20:01
@renzodavid9 renzodavid9 merged commit ae40f78 into GoogleContainerTools:main Sep 20, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support disabling Cloud Run URL - populate CloudRunServiceReady even if URL is not there
4 participants