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

Add optional timeout #1081

Open
wants to merge 2 commits into
base: master
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
21 changes: 21 additions & 0 deletions docker-gcloud-pubsub-emulator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ If you want to define more projects, you'd simply add a ``PUBSUB_PROJECT2``,
As with configuring this script via config file, you must have at least one
configured ``topic``.

Timeout
^^^^^^^
There are times when the Google Cloud PubSub system takes more than the default 15s
to be ready to accept requests to create the project/topic/subscription. If you
are getting the message:
```
Operation timed out
```
you may want to increase the timeout, by setting the environment variable
`PUBSUB_EMULATOR_WAIT_TIMEOUT` (in seconds) to some value larger than 15.
For example, the command below will set the timeout to be 60 seconds.

.. code-block:: console

$ docker run --rm -it \
-p 8681:8681 \
-e PUBSUB_EMULATOR_WAIT_TIMEOUT=60 \
-e PUBSUB_PROJECT1=company-dev,invoices:invoice-calculator,chats:slack-out:irc-out,notifications \
thekevjames/gcloud-pubsub-emulator:latest


Liveness Probes
~~~~~~~~~~~~~~~

Expand Down
7 changes: 5 additions & 2 deletions docker-gcloud-pubsub-emulator/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# After it's done, port 8682 will be open to facilitate the wait-for and
# wait-for-it scripts.
(
set -eu
Copy link
Author

@shintasmith shintasmith Oct 29, 2024

Choose a reason for hiding this comment

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

I have to get rid of this setting because the script will terminate if PUBSUB_EMULATOR_WAIT_TIMEOUT is not defined. I would get the following error:

/run.sh: 11: PUBSUB_EMULATOR_WAIT_TIMEOUT: parameter not set

I was trying to make this new env variable optional so that the behavior is the same as before (it waits only 15s), if the variable is not specified

echo "Waiting for emulator..."
/usr/bin/wait-for localhost:8681 -- env PUBSUB_EMULATOR_HOST=localhost:8681 /usr/bin/pubsubc
TIMEOUT_OPTION=""
if [ ! -z "$PUBSUB_EMULATOR_WAIT_TIMEOUT" ]; then
TIMEOUT_OPTION="-t $PUBSUB_EMULATOR_WAIT_TIMEOUT"
fi
/usr/bin/wait-for localhost:8681 $TIMEOUT_OPTION -- env PUBSUB_EMULATOR_HOST=localhost:8681 /usr/bin/pubsubc
echo "[run.sh] Done building projects/topics/subscriptions! Opening readiness port..."
nc -lkp 8682
) &
Expand Down