Skip to content

fix(cloudrun): tail logs from all services concurrently#10058

Merged
Darien-Lin merged 1 commit intoGoogleContainerTools:mainfrom
unburdenedio:fix/cloudrun-multi-service-log-tailing
Apr 22, 2026
Merged

fix(cloudrun): tail logs from all services concurrently#10058
Darien-Lin merged 1 commit intoGoogleContainerTools:mainfrom
unburdenedio:fix/cloudrun-multi-service-log-tailing

Conversation

@bogdannazarenko
Copy link
Copy Markdown
Contributor

@bogdannazarenko bogdannazarenko commented Apr 21, 2026

Summary

Fix Cloud Run --tail log streaming to show logs from all deployed services concurrently, instead of only one randomly selected service.

Fixes #10057

Problem

When running skaffold run --tail with multiple Cloud Run services, only one service's logs were displayed. The service appeared to be chosen randomly on each run.

Root cause: streamLog() was called inline (blocking) inside the for-loop that iterates over resources. Since streamLog() runs an infinite read loop, the loop never advanced past the first resource. Go's randomized map iteration order made it appear random.

Kubernetes deployments are not affected — the K8s LogAggregator already uses go a.streamContainerLogs(...) per container.

Changes

  • pkg/skaffold/deploy/cloudrun/log.go: Move streamLog() into its own goroutine per resource so the for-loop continues immediately to start all services. Also renamed r, w := io.Pipe() to pr, pw to fix variable shadowing of the method receiver.
  • pkg/skaffold/deploy/cloudrun/log_test.go: Added TestStreamLogMultipleServicesConcurrently regression test that verifies multiple concurrent streamLog calls both produce output.

Testing

  • All existing cloudrun package tests pass
  • Manually tested with two cloud run services
Starting deploy...
Deploying Cloud Run service:
         goodbye-func-main
Deploying Cloud Run service:
         hello-func-main
goodbye-func-main: Service starting: Provisioning revision instances to receive traffic.
hello-func-main: Service starting: Provisioning revision instances to receive traffic.
Cloud Run Service goodbye-func-main finished: Service started. 1/2 deployment(s) still pending
Cloud Run Service hello-func-main finished: Service started. 0/2 deployment(s) still pending
Forwarding service projects/REDACTED/locations/us-east1/services/goodbye-func-main to local port 8080
Forwarding service projects/REDACTED/locations/us-east1/services/hello-func-main to local port 8081
Press Ctrl+C to exit
Proxying to Cloud Run service [hello-func-main] in project [REDACTED] region [us-east1]
http://127.0.0.1:8081/ proxies to https://hello-func-main-REDACTED-ue.a.run.app/
Proxying to Cloud Run service [goodbye-func-main] in project [REDACTED] region [us-east1]
http://127.0.0.1:8080/ proxies to https://goodbye-func-main-REDACTED-ue.a.run.app/
[hello-func-main] streaming logs from REDACTED
[goodbye-func-main] streaming logs from REDACTED
[hello-func-main] 2026-04-21 22:39:59 GET 200 https://hello-func-main-REDACTED-ue.a.run.app/
[goodbye-func-main] 2026-04-21 22:40:08 GET 200 https://goodbye-func-main-REDACTED-ue.a.run.app/

@bogdannazarenko bogdannazarenko requested a review from a team as a code owner April 21, 2026 22:06
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 21, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the --set flag to the skaffold delete command and updates Cloud Run log tailing to operate concurrently, enabling simultaneous streaming for multiple services. The review identifies critical issues where the pipe writer must be closed during command failure or termination to prevent goroutine leaks. Additionally, it is recommended to implement a synchronized writer to prevent log line interleaving from concurrent output.

Comment thread pkg/skaffold/deploy/cloudrun/log.go
Comment thread pkg/skaffold/deploy/cloudrun/log.go
Comment thread pkg/skaffold/deploy/cloudrun/log.go Outdated
@bogdannazarenko bogdannazarenko force-pushed the fix/cloudrun-multi-service-log-tailing branch from e66533f to 90aa39c Compare April 21, 2026 22:11
@pull-request-size pull-request-size Bot added size/M and removed size/L labels Apr 21, 2026
@bogdannazarenko bogdannazarenko force-pushed the fix/cloudrun-multi-service-log-tailing branch from 90aa39c to 951325d Compare April 21, 2026 22:18
streamLog() was called inline (blocking) inside the for-loop iterating
over Cloud Run resources, so only the first service yielded by Go's
randomized map iteration would get its logs tailed. Move streamLog()
into its own goroutine per resource so the loop continues immediately.

Also fixes variable shadowing where r, w := io.Pipe() shadowed the
method receiver r *runLogTailer (renamed to pr, pw).

Fixes GoogleContainerTools#10057

Signed-off-by: Bogdan Nazarenko <bogdan.nazarenko@outlook.com>
@bogdannazarenko bogdannazarenko force-pushed the fix/cloudrun-multi-service-log-tailing branch from 951325d to c966c16 Compare April 21, 2026 22:21
@Darien-Lin
Copy link
Copy Markdown
Contributor

generally lgtm. waiting for workflows to finish.

@Darien-Lin
Copy link
Copy Markdown
Contributor

Can you take a look @ the integration tests failures? I ran it twice now and it seems to have failed with the same error.

@bogdannazarenko
Copy link
Copy Markdown
Contributor Author

@Darien-Lin Darien-Lin merged commit 843d52d into GoogleContainerTools:main Apr 22, 2026
8 of 15 checks passed
@bogdannazarenko bogdannazarenko deleted the fix/cloudrun-multi-service-log-tailing branch April 22, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Cloud Run log tailing with --tail only shows logs from one service when multiple services are deployed

2 participants