Skip to content

feat(deploy): tail build logs from CloudWatch while waiting - #31

Merged
mashiike merged 2 commits into
mainfrom
feat/build-log-tail
Jul 9, 2026
Merged

feat(deploy): tail build logs from CloudWatch while waiting#31
mashiike merged 2 commits into
mainfrom
feat/build-log-tail

Conversation

@mashiike

@mashiike mashiike commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 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 (<version>/)
  • 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

Test plan

  • go build ./..., go vet ./..., golangci-lint run all clean
  • go test ./... -race passes, including new unit tests for startBuildLogTail (aws CLI missing → no-op, command construction via fake aws binary, stop() does not hang) and an integration test asserting Deploy succeeds end-to-end when the aws CLI is absent
  • Unverified — needs a real deploy: the build log stream name is assumed to be <imageVersion>/<uuid> (confirmed only for runtime logs, which use a different <date>[<version>]microvm-<uuid> format). Please run lamvms deploy once for a brand-new image (create) and once for an existing one (update) and confirm (a) build logs actually appear on update, and (b) no ResourceNotFoundException noise on stderr for a first-time create (the log group may not exist yet when the tail starts)

概要

  • deploywait--build-logs/--no-build-logs フラグ(デフォルト true)を追加し、バージョンの準備完了をポーリングする間、MicroVM イメージビルドの CloudWatch Logs ストリームを aws logs tail --follow(ログストリーム prefix <version>/)に委譲して tail する
  • aws CLI が見つからない、または起動に失敗した場合は警告ログを出して継続する(ビルドログ表示はベストエフォートであり、wait 自体を失敗させない)

テスト計画

  • go build ./... / go vet ./... / golangci-lint run は全てクリーン
  • go test ./... -race は全パス。startBuildLogTail の新規ユニットテスト(aws CLI 不在時の no-op、fake aws バイナリでのコマンド構築検証、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

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 (default true) to deploy and wait, and pass the setting down to waitForVersion.
  • 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 startBuildLogTail behavior and an integration-style test ensuring deploy succeeds when aws CLI 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 thread deploy_test.go Outdated
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>
@mashiike
mashiike merged commit 17c9604 into main Jul 9, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants