GoogleCloudPlatform / GoogleCloudPlatform/esp-v2
`gcloud_build_image` script fails with "invalid image name" due to excessively long tag names exceeding 128 character limit
- Dominant language
- Go
- Stars
- 307
- Forks
- 185
- Avg merge
- 14h 45m
- Merged PRs (30d)
- 6
Description
The `gcloud_build_image` script provided by ESPv2 is failing when building custom serverless images because it generates Docker image tags that exceed the 128-character limit imposed by Google Cloud Build.
### Root Cause
The script uses this logic to select the ESP version:
```bash
# Find the tag with the longest length.
ESP_FULL_VERSION=""
for tag in "${TAGS_ARRAY[@]}"; do
if [ ${#tag} -gt ${#ESP_FULL_VERSION} ]; then
ESP_FULL_VERSION=${tag}
fi
done
```
Recently, ESPv2 images appear to include tags with significantly longer names (e.g., `no-new-use-public-image-068327caef9d06afbe01b6b5d882e64bf0fae7d76b705f04ef556ba380101f18`), and the script's logic of selecting the **longest** tag means it picks these extremely long identifiers.
### Problem
When the script constructs the final image tag:
```bash
NEW_IMAGE="${IMAGE_REPOSITORY}/endpoints-runtime-serverless:${ESP_FULL_VERSION}-${SERVICE}-${CONFIG_ID}"
```
The resulting tag becomes excessively long:
```
us-central1-docker.pkg.dev/project/repo/endpoints-runtime-serverless:no-new-use-public-image-068327caef9d06afbe01b6b5d882e64bf0fae7d76b705f04ef556ba380101f18-service.example.com-2026-03-18r0
```
This exceeds Docker's 128-character tag limit and causes Google Cloud Build to fail with:
```
ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: invalid image name "...": could not parse reference
```
### Expected Behavior
The script should select a reasonable ESP version tag that, when combined with service and config identifiers, produces a valid Docker tag under 128 characters.
**Script Location**: `docker/serverless/gcloud_build_image`
Contributor guide
Research direction
Start with docker/serverless/gcloud_build_image, focusing on the TAGS_ARRAY loop that chooses ESP_FULL_VERSION and the NEW_IMAGE construction. Reproduce the long-tag case described in the issue, then verify that the selected version combined with the service and config identifiers stays within Docker's 128-character tag limit and is accepted by Google Cloud Build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, google-cloud, shell
- Domain
- build-system, cloud, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100