Skip to content

feat(cmd): Add '--follow' flag for start/restart#328

Draft
craciunoiuc wants to merge 1 commit into
stagingfrom
craciunoiuc/follow-logs-start-restart-create
Draft

feat(cmd): Add '--follow' flag for start/restart#328
craciunoiuc wants to merge 1 commit into
stagingfrom
craciunoiuc/follow-logs-start-restart-create

Conversation

@craciunoiuc
Copy link
Copy Markdown
Member

@craciunoiuc craciunoiuc commented May 15, 2026

I wanted to do this for instance create --set autostart=true also, but I was unsure about that (was a bit controversial in a way), and it was also messing up the creation code, so I took it out.

For the tests I added a timeout field so we can force-quit out of following logs after some time.

Depends on: unikraft-cloud/go-sdk#187

Closes: TOOL-680

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds --follow support to instance start and restart flows so users can stream instance logs immediately after lifecycle operations.

Changes:

  • Adds Follow flags and examples for instance start and instance restart.
  • Streams logs after successful start/restart operations.
  • Adds timeout support to golden-test command execution and coverage for start/restart follow flows.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

File Description
internal/cmd/instances.go Adds follow flags and invokes log streaming after start/restart.
cmd/unikraft/testdata/TestGolden/instances/help Updates CLI help golden output for new flags/examples.
cmd/unikraft/main_test.go Adds per-command timeout handling in golden tests.
cmd/unikraft/instances_test.go Adds integration-style golden tests for start/restart follow behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/unikraft/main_test.go
Comment thread cmd/unikraft/main_test.go Outdated
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/follow-logs-start-restart-create branch 2 times, most recently from bc67b4b to 73bfafa Compare May 18, 2026 08:20
@craciunoiuc craciunoiuc requested a review from Copilot May 18, 2026 08:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

internal/cmd/instances.go:1467

  • Using tail=0 when following after restart replays the instance's full previous log history before the new boot logs. This means restart --follow can show stale logs from before the restart and may dump a large backlog instead of following only the restarted instance's output.
	return streamInstanceLogs(ctx, stdio, started, 0, true)

cmd/unikraft/instances_test.go:227

  • This test records live restart logs into the golden output. The amount and content of data collected before the 5-second timeout depends on platform/image timing and can change between runs, making the golden file nondeterministic; the test should avoid snapshotting the raw followed log stream or normalize it more aggressively.
				{
					args: []string{
						unikraftCmd, "instance", "restart",
						"--follow",
						"test-$UNIQ_INST",
					},
					timeout: 5 * time.Second,
				},

Comment thread internal/cmd/instances.go Outdated
Comment thread cmd/unikraft/instances_test.go
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/follow-logs-start-restart-create branch from ab5c60e to b140223 Compare May 18, 2026 10:09
@craciunoiuc craciunoiuc requested a review from Copilot May 18, 2026 10:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread cmd/unikraft/instances_test.go
Comment thread cmd/unikraft/instances_test.go
Comment thread internal/cmd/run.go Outdated
Comment thread internal/cmd/run.go Outdated
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/follow-logs-start-restart-create branch from b140223 to 78f52bf Compare May 18, 2026 10:54
@craciunoiuc craciunoiuc requested a review from Copilot May 18, 2026 10:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread internal/cmd/run.go
Comment thread internal/cmd/run.go
This allows for following logs on re/starting instances.
This is not implemented for creation with autostart.

Following logs prints everything from when the instance stopped.

Signed-off-by: Cezar Craciunoiu <cezar@unikraft.io>
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/follow-logs-start-restart-create branch from 78f52bf to 712009f Compare May 18, 2026 11:45
@craciunoiuc
Copy link
Copy Markdown
Member Author

As good as it can get

@craciunoiuc craciunoiuc marked this pull request as ready for review May 18, 2026 11:46
Comment thread internal/cmd/run.go
@craciunoiuc craciunoiuc marked this pull request as draft May 22, 2026 12:07
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.

3 participants