Skip to content

Commit 27df832

Browse files
graysidefhinkel
andauthored
run: use shorter suffix in service names (#1835)
Co-authored-by: F. Hinkelmann <[email protected]>
1 parent 64949d4 commit 27df832

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

.kokoro/build-with-run.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
set -eo pipefail
1818

19+
_run_error_log() {
20+
echo "error: line $(caller)"
21+
}
22+
23+
trap '_run_error_log' ERR
24+
1925
# Activate mocha config
2026
export MOCHA_REPORTER_OUTPUT=${PROJECT}_sponge_log.xml
2127
export MOCHA_REPORTER=xunit
@@ -37,12 +43,14 @@ gcloud config set project $GOOGLE_CLOUD_PROJECT
3743

3844
# Version is in the format <PR#>-<GIT COMMIT SHA>.
3945
# Ensures PR-based triggers of the same branch don't collide if Kokoro attempts
40-
# to run them concurrently.
46+
# to run them concurrently. Defaults to 'latest'.
4147
export SAMPLE_VERSION="${KOKORO_GIT_COMMIT:-latest}"
4248
export SAMPLE_NAME="$(basename $(pwd))"
4349

44-
# Builds not triggered by a PR will fall back to the commit hash then "latest".
45-
SUFFIX=${KOKORO_BUILD_ID}
50+
# Cloud Run has a max service name length, $KOKORO_BUILD_ID is too long to guarantee no conflict deploys.
51+
set -x
52+
export SUFFIX="$(cat /dev/urandom | LC_CTYPE=C tr -dc 'a-z0-9' | head -c 15)"
53+
set +x
4654
export SERVICE_NAME="${SAMPLE_NAME}-${SUFFIX}"
4755
export CONTAINER_IMAGE="gcr.io/${GOOGLE_CLOUD_PROJECT}/run-${SAMPLE_NAME}:${SAMPLE_VERSION}"
4856

run/hello-broken/s.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
find . -name '*.sh' -not -path "./testing/*" -exec shellcheck -f gcc {} \;

run/hello-broken/test/cloudrun-ci.js

Whitespace-only changes.

run/hello-broken/test/system.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
const assert = require('assert');
1616
const request = require('got');
17+
const {resolve} = require('url');
1718

1819
const get = (route, base_url) => {
1920
const {ID_TOKEN} = process.env;
2021
if (!ID_TOKEN) {
2122
throw Error('"ID_TOKEN" environment variable is required.');
2223
}
2324

24-
return request(route, {
25-
baseUrl: base_url.trim(),
25+
return request(resolve(base_url.trim(), route), {
2626
headers: {
2727
Authorization: `Bearer ${ID_TOKEN.trim()}`,
2828
},

0 commit comments

Comments
 (0)