这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@edigaryev
Copy link
Collaborator

Also handle decrease the connection timeout to 1 second and provide a hint to the user.

Also handle decrease the connection timeout to 1 second
and provide a hint to the user.
@edigaryev edigaryev requested a review from fkorotkov as a code owner May 26, 2025 18:03
@edigaryev edigaryev requested a review from Copilot May 26, 2025 18:04
Copy link
Contributor

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

This PR clarifies the requirement for the Tart Guest Agent, tightens the gRPC connection timeout to 1 second, and surfaces a hint when the agent isn’t running.

  • Adds a discussion section to the Exec command configuration about the Tart Guest Agent.
  • Refactors execution into a separate execute method with a 1-second CallOptions timeout.
  • Catches GRPCConnectionPoolError and throws a more user-friendly hint.
Comments suppressed due to low confidence (1)

Sources/tart/Commands/Exec.swift:82

  • Add tests to cover the new timeout behavior, such as verifying that a timeout error is raised when the VM agent is unresponsive.
let callOptions = CallOptions(timeLimit: .timeout(.seconds(1)))

Comment on lines +13 to +15
Requires Tart Guest Agent running in a guest VM.
Note that all non-vanilla Cirrus Labs VM images already have the Tart Guest Agent installed.
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] Rephrase the discussion for clarity and consistency, e.g., "Requires the Tart Guest Agent to be running inside the VM." Also remove the leading blank line to avoid unintended formatting.

Suggested change
Requires Tart Guest Agent running in a guest VM.
Note that all non-vanilla Cirrus Labs VM images already have the Tart Guest Agent installed.
Requires the Tart Guest Agent to be running inside the VM.
Note that all non-vanilla Cirrus Labs VM images already have the Tart Guest Agent installed.

Copilot uses AI. Check for mistakes.
Comment on lines 80 to 82
func execute(_ channel: GRPCChannel) async throws {
let agentAsyncClient = AgentAsyncClient(channel: channel)
let execCall = agentAsyncClient.makeExecCall()
let callOptions = CallOptions(timeLimit: .timeout(.seconds(1)))
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

Extract the hardcoded timeout (1 second) into a named constant or configuration parameter to avoid magic numbers and simplify future adjustments.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks fine to me.

do {
try await execute(channel)
} catch let error as GRPCConnectionPoolError {
throw RuntimeError.Generic("Failed to connect to the VM using its control socket, is Tart Guest Agent running?")
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

Include the original error details (e.g., error.localizedDescription) in this message to help users diagnose the underlying cause.

Suggested change
throw RuntimeError.Generic("Failed to connect to the VM using its control socket, is Tart Guest Agent running?")
throw RuntimeError.Generic("Failed to connect to the VM using its control socket, is Tart Guest Agent running? Error details: \(error.localizedDescription)")

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added in 53dff1d.

@edigaryev edigaryev merged commit 0187834 into main May 27, 2025
6 checks passed
@edigaryev edigaryev deleted the tart-exec-explanations branch May 27, 2025 08:57
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