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

feat: add support for wait command #2041

Merged
merged 3 commits into from
Nov 27, 2023
Merged

feat: add support for wait command #2041

merged 3 commits into from
Nov 27, 2023

Conversation

enocom
Copy link
Member

@enocom enocom commented Nov 21, 2023

To help ensure the Proxy is up and ready, this commit adds a wait command with an optional --max flag to set the maximum time to wait.

By default when invoking this command:

./cloud-sql-proxy wait

The Proxy will wait up to the maximum time for the /startup endpoint to respond. This command requires that the Proxy be started in another process with the HTTP health check enabled. If an alternate health check port or address is used, as in:

./cloud-sql-proxy <INSTANCE_CONNECTION_NAME> \
  --http-address 0.0.0.0 \
  --http-port 9191

Then the wait command must also be told to use the same custom values:

./cloud-sql-proxy wait \
  --http-address 0.0.0.0 \
  --http-port 9191

By default the wait command will wait 30 seconds. To alter this value, use:

./cloud-sql-proxy wait --max 10s

Fixes #1117

To help ensure the Proxy is up and ready, this commit adds a wait
command with an optional `--max` flag to set the maximum time to wait.

By default when invoking this command:

./cloud-sql-proxy wait

The Proxy will wait up to the maximum time for the /startup endpoint to
respond. This command requires that the Proxy be started in another
process with the HTTP health check enabled. If an alternate health
check port or address is used, as in:

./cloud-sql-proxy <INSTANCE_CONNECTION_NAME> --http-address 0.0.0.0 \
  --http-port 9191

Then the wait command must also be told to use the same custom values:

./cloud-sql-proxy wait --http-address 0.0.0.0 \
  --http-port 9191

By default the wait command will wait 30 seconds. To alter this value,
use:

./cloud-sql-proxy wait --max 10s

Fixes #1117
cmd/root.go Outdated

Sometimes it is necessary to wait for the Proxy to start.

To help ensure the Proxy is up and ready, the Proxy includes adds a wait
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
To help ensure the Proxy is up and ready, the Proxy includes adds a wait
To help ensure the Proxy is up and ready, the Proxy includes a wait

cmd/root.go Outdated
To help ensure the Proxy is up and ready, the Proxy includes adds a wait
subcommand with an optional --max flag to set the maximum time to wait.

By default when invoking this command:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line is slightly confusing ... reads a little funny

Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@hessjcg hessjcg left a comment

Choose a reason for hiding this comment

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

LGTM

@vvxxvvxx
Copy link

Hi @enocom , is this feature also added in cloud-sql-proxy v1?

@jackwotherspoon
Copy link
Collaborator

Hi @enocom , is this feature also added in cloud-sql-proxy v1?

@vvxxvvxx The wait command is not supported in the v1 version of the Cloud SQL Proxy.

We highly recommend upgrading to v2 to take advantage of new features as v1 is mostly in maintenance mode (bug fixes and dep updates only).

You can check out the migration guide for more detailed steps to do so.

If there is anything holding you back from migrating, please let us know 😄

@mdering
Copy link

mdering commented Aug 6, 2024

hi @enocom could you update the examples or provide an example of how this would work with a poststart hook? I've been struggling to get it to work as described

@jackwotherspoon
Copy link
Collaborator

hi @enocom could you update the examples or provide an example of how this would work with a poststart hook? I've been struggling to get it to work as described

Hi @mdering!

Now that k8s supports sidecar configurations I would recommend taking a look at and using the Cloud SQL Proxy as an initContainers instead of a postStart hook: Please see #128 (comment)

@mdering
Copy link

mdering commented Aug 6, 2024

hi @jackwotherspoon, thanks for your help! I was interested in using it as a sidecar for jobs and services, is that no longer the pattern you recommend? It seems like the regular application won't start until the initcontainers all stop according to the docs, is there something im missing?

EDIT: It does indeed seem like I'm missing something!

@devauxbr
Copy link

devauxbr commented Aug 9, 2024

Hi @mdering, the new official "sidecar container" support in K8S is indeed a bit misleading, as it requires using initContainerbut with an additionnal restartPolicy: Always to make it a sidecar 😅

@enocom
Copy link
Member Author

enocom commented Aug 12, 2024

+1 to what @devauxbr said. @mdering if you're still getting stuck, feel free to open an issue and we can either document this better, or explore other options.

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.

Add command for use in "PostStart" hook that delays until proxy has started
6 participants