bazelbuild / rules_docker

Rules for building and handling Docker images with Bazel
Apache License 2.0
1.07k stars 692 forks source link

Error running `container_push` in Google Cloud Build step #2059

Closed damian-codematic closed 1 year ago

damian-codematic commented 2 years ago

🐞 bug report

Affected Rule

The issue is caused by the rule: container_push

Is this a regression?

no

Description

In Cloud Build, we run the container_push rule to push to image to artifact registry. This rule works on my computer but doesn't in the cloud build step.

🔬 Minimal Reproduction

This can be tested like this


# App level cloud build
timeout: 600s

steps:
...
  - id: Test
    name: gcr.io/cloud-builders/bazel
    entrypoint: "bazel"
    args:
      [
        "test",
        "--config=cloudbuild",
        "--remote_upload_local_results=true",
        "--test_env=FIRESTORE_EMULATOR_HOST=firestore:8200",
        "--test_env=PUBSUB_EMULATOR_HOST=pubsub:8601",
        "...",
      ]

  - id: Push
    name: gcr.io/cloud-builders/bazel
    entrypoint: "bash"
    args:
      - "-c"
      - |-
        bazel run --config=cloudbuild //apps/event-discovery/cmd/pubsub:push \
        && bazel run --config=cloudbuild //apps/event-discovery/cmd/grpc:push

  - id: Deploy
    name: hashicorp/terraform
    entrypoint: "terraform"
    args: ["apply", "-auto-approve"]
    env:
      - "TF_VAR_git-sha=$COMMIT_SHA"

🔥 Exception or Error

Starting Step #0 - "Version"
Step #0 - "Version": Already have image (with digest): gcr.io/cloud-builders/bazel
Step #0 - "Version": Extracting Bazel installation...
Step #0 - "Version":
Step #0 - "Version": Starting local Bazel server and connecting to it...
Step #0 - "Version": Build label: 5.1.1
Step #0 - "Version": Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Step #0 - "Version": Build time: Fri Apr 8 15:49:48 2022 (1649432988)
Step #0 - "Version": Build timestamp: 1649432988
Step #0 - "Version": Build timestamp as int: 1649432988
Finished Step #0 - "Version"
2022/04/13 11:08:49 Step Step #0 - "Version" finished
...
Starting Step #4 - "Push"
Step #4 - "Push": Already have image (with digest): gcr.io/cloud-builders/bazel
Step #4 - "Push": Starting local Bazel server and connecting to it...
Step #4 - "Push": INFO: Invocation ID: 19fb55df-b804-48b4-a2f5-a2c899c6cda2
Step #4 - "Push": INFO: Streaming build results to: https://app.buildbuddy.io/invocation/19fb55df-b804-48b4-a2f5-a2c899c6cda2
Step #4 - "Push": Loading:
Step #4 - "Push": Loading: 0 packages loaded
Step #4 - "Push": Loading: 0 packages loaded
Step #4 - "Push": Loading: 0 packages loaded
Step #4 - "Push":     currently loading: apps/event-discovery/cmd/pubsub
Step #4 - "Push": Analyzing: target //apps/event-discovery/cmd/pubsub:push (1 packages loaded, 0 targets configured)
Step #4 - "Push": Analyzing: target //apps/event-discovery/cmd/pubsub:push (36 packages loaded, 9 targets configured)
Step #4 - "Push": Analyzing: target //apps/event-discovery/cmd/pubsub:push (74 packages loaded, 755 targets configured)
Step #4 - "Push": Analyzing: target //apps/event-discovery/cmd/pubsub:push (77 packages loaded, 9800 targets configured)
Step #4 - "Push": Analyzing: target //apps/event-discovery/cmd/pubsub:push (182 packages loaded, 13038 targets configured)
Step #4 - "Push": INFO: Analyzed target //apps/event-discovery/cmd/pubsub:push (323 packages loaded, 15349 targets configured).
Step #4 - "Push":
Step #4 - "Push": INFO: Found 1 target...
Step #4 - "Push": [2 / 18] [Prepa] BazelWorkspaceStatusAction stable-status.txt
Step #4 - "Push": [14 / 59] GoCompilePkg external/com_github_google_go_containerregistry/pkg/name/name.a [for host]; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": [67 / 310] GoCompilePkg external/io_bazel_rules_docker/container/go/cmd/digester/digester.a [for host]; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": [100 / 310] Compiling src/google/protobuf/compiler/java/java_file.cc; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": [133 / 310] Compiling src/google/protobuf/util/json_util.cc; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": [169 / 310] Compiling src/google/protobuf/io/tokenizer.cc; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": [211 / 310] Compiling src/google/protobuf/map.cc; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": [262 / 345] GoCompilePkg external/org_golang_google_protobuf/internal/flags/flags.a; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": INFO: From Generating Descriptor Set proto_library @go_googleapis//google/iam/v1:iam_proto:
Step #4 - "Push": google/iam/v1/options.proto:20:1: warning: Import google/api/annotations.proto is unused.
Step #4 - "Push": google/iam/v1/policy.proto:21:1: warning: Import google/api/annotations.proto is unused.
Step #4 - "Push": [380 / 447] GoCompilePkg external/org_golang_google_grpc/internal/grpcsync/grpcsync.a; 0s remote-cache ... (4 actions, 0 running)
Step #4 - "Push": INFO: From Generating Descriptor Set proto_library @go_googleapis//google/firestore/v1:firestore_proto:
Step #4 - "Push": google/firestore/v1/query.proto:19:1: warning: Import google/api/field_behavior.proto is unused.
Step #4 - "Push": [512 / 534] GoCompilePkg external/com_github_google_go_containerregistry/internal/retry/retry.a [for host]; 0s remote-cache ... (3 actions, 0 running)
Step #4 - "Push": Target //apps/event-discovery/cmd/pubsub:push up-to-date:
Step #4 - "Push":   bazel-bin/apps/event-discovery/cmd/pubsub/push.digest
Step #4 - "Push":   bazel-bin/apps/event-discovery/cmd/pubsub/push
Step #4 - "Push": INFO: Elapsed time: 36.975s, Critical Path: 5.45s
Step #4 - "Push": INFO: 501 processes: 500 remote cache hit, 1 internal.
Step #4 - "Push": INFO: Build completed successfully, 501 total actions
Step #4 - "Push": INFO: Running command line: bazel-bin/apps/event-discovery/cmd/pubsub/push
Step #4 - "Push": INFO: Build completed successfully, 501 total actions
Step #4 - "Push": INFO: Streaming build results to: https://app.buildbuddy.io/invocation/19fb55df-b804-48b4-a2f5-a2c899c6cda2
Step #4 - "Push": INFO: Build completed successfully, 501 total actions
Step #4 - "Push": /workspace/0b502cf25d074c0253821d023c1a4596/execroot/closera/bazel-out/k8-fastbuild/bin/apps/event-discovery/cmd/pubsub/push: line 31: /workspace/0b502cf25d074c0253821d023c1a4596/execroot/closera/bazel-out/k8-fastbuild/bin/apps/event-discovery/cmd/pubsub/push.runfiles/closera/../io_bazel_rules_docker/container/go/cmd/pusher/pusher_/pusher: No such file or directory
Finished Step #4 - "Push"
2022/04/13 11:03:22 Step Step #4 - "Push" finished
2022/04/13 11:03:22 status changed to "ERROR"
ERROR
ERROR: build step 4 "gcr.io/cloud-builders/bazel" failed: exit status 127

🌍 Your Environment

Operating System: Linux

Output of bazel version:

Build label: 5.1.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Apr 8 15:49:48 2022 (1649432988)
Build timestamp: 1649432988
Build timestamp as int: 1649432988

Rules_docker version: rules_docker-0.20.0

Anything else relevant?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

github-actions[bot] commented 1 year ago

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"