feat(deploy): tail build logs from CloudWatch while waiting - #31
Merged
Conversation
Add a --build-logs/--no-build-logs flag (default true) to deploy and wait that tails the MicroVM image build's CloudWatch Logs stream while polling for version readiness, shelling out to `aws logs tail --follow` scoped to the build's log stream prefix. If the aws CLI is missing or fails to start, it logs a warning and continues without it — build log visibility is best-effort and never fails the wait itself. deploy と wait に --build-logs/--no-build-logs フラグ(デフォルト true)を 追加し、バージョンの準備完了をポーリングする間、MicroVM イメージビルドの CloudWatch Logs ストリームを aws logs tail --follow に委譲して tail する。 aws CLI が見つからない、または起動に失敗した場合は警告ログを出して継続する (ビルドログ表示はベストエフォートであり、wait 自体を失敗させない)。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds best-effort tailing of MicroVM image build logs from CloudWatch while deploy --wait / wait polls for version readiness, by shelling out to aws logs tail --follow scoped to the version’s log-stream prefix.
Changes:
- Add
--build-logs/--no-build-logs(defaulttrue) todeployandwait, and pass the setting down towaitForVersion. - Start/stop an
aws logs tail --follow --log-stream-name-prefix <version>/subprocess while waiting for the image version to become ready. - Add tests covering
startBuildLogTailbehavior and an integration-style test ensuring deploy succeeds whenawsCLI is missing.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wait.go | Passes BuildLogs through to the version-wait loop. |
| deploy.go | Implements build-log tailing during version wait; improves failure hint to include the computed log group name. |
| logs.go | Deduplicates log-group name formatting via microvmLogGroupName. |
| cli.go | Adds --build-logs/--no-build-logs flags to deploy and wait. |
| deploy_test.go | Adds tests for best-effort behavior and tail process lifecycle/command construction. |
| README.md | Documents the new --build-logs/--no-build-logs flags. |
| README.ja.md | Japanese documentation update for the new flags. |
Comment on lines
+327
to
+331
| name := "aws" | ||
| if runtime.GOOS == "windows" { | ||
| name = "aws.bat" | ||
| } | ||
| script := "#!/bin/sh\nprintf '%s\\n' \"$@\" > \"$FAKE_AWS_ARGS_FILE\"\nsleep 5\n" |
Copilot review pointed out that newFakeAWS wrote a POSIX shell script even when naming the file aws.bat for Windows, which would never execute there. Skip the test on Windows instead of pretending to support it (CI only runs on ubuntu-latest, so this has no coverage impact today). Copilot のレビューで、newFakeAWS が Windows 向けに aws.bat という名前を 付けていても内容は常に POSIX シェルスクリプトで、実際には実行できないと 指摘された。サポートしているふりをするのではなく、Windows では明示的に テストを skip する(CI は ubuntu-latest のみなので、カバレッジへの影響はない)。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--build-logs/--no-build-logsflag (defaulttrue) todeployandwaitthat tails the MicroVM image build's CloudWatch Logs stream while polling for version readiness, shelling out toaws logs tail --followscoped to the build's log stream prefix (<version>/)awsCLI is missing or fails to start, it logs a warning and continues without it — build log visibility is best-effort and never fails the wait itselfTest plan
go build ./...,go vet ./...,golangci-lint runall cleango test ./... -racepasses, including new unit tests forstartBuildLogTail(aws CLI missing → no-op, command construction via fakeawsbinary,stop()does not hang) and an integration test assertingDeploysucceeds end-to-end when theawsCLI is absent<imageVersion>/<uuid>(confirmed only for runtime logs, which use a different<date>[<version>]microvm-<uuid>format). Please runlamvms deployonce for a brand-new image (create) and once for an existing one (update) and confirm (a) build logs actually appear on update, and (b) noResourceNotFoundExceptionnoise on stderr for a first-time create (the log group may not exist yet when the tail starts)概要
deployとwaitに--build-logs/--no-build-logsフラグ(デフォルトtrue)を追加し、バージョンの準備完了をポーリングする間、MicroVM イメージビルドの CloudWatch Logs ストリームをaws logs tail --follow(ログストリーム prefix<version>/)に委譲して tail するawsCLI が見つからない、または起動に失敗した場合は警告ログを出して継続する(ビルドログ表示はベストエフォートであり、wait 自体を失敗させない)テスト計画
go build ./.../go vet ./.../golangci-lint runは全てクリーンgo test ./... -raceは全パス。startBuildLogTailの新規ユニットテスト(aws CLI 不在時の no-op、fakeawsバイナリでのコマンド構築検証、stop()がハングしないこと)と、aws CLI 不在でもDeployが最後まで成功する統合テストを追加<imageVersion>/<uuid>形式であるという前提は仮説です(確認済みなのはランタイムログの<date>[<version>]microvm-<uuid>形式のみ)。新規イメージ(create)と既存イメージ更新(update)でそれぞれ1回lamvms deployを実行し、(a) update でビルドログが実際に流れるか、(b) create でロググループ未作成によるResourceNotFoundException等が stderr に出ないかを確認してください🤖 Generated with Claude Code