cli: Add explicit daemon lifecycle commands#376
Open
timflannagan wants to merge 3 commits intoagentregistry-dev:mainfrom
Open
cli: Add explicit daemon lifecycle commands#376timflannagan wants to merge 3 commits intoagentregistry-dev:mainfrom
timflannagan wants to merge 3 commits intoagentregistry-dev:mainfrom
Conversation
The root command's PersistentPreRunE hook previously auto-started Docker containers (postgres + registry server) whenever the registry URL targeted localhost:12121. This was a footgun for users with existing registries, e.g. port-forwarding a Kubernetes registry to localhost:12121 would risk silently spinning up a separate local instance if the port-forward dropped. We now follow the Docker CLI/daemon model where the CLI never auto-starts infrastructure and fails fast if the registry is unreachable. Daemon lifecycle is managed explicitly through arctl daemon start, stop, and status subcommands. The stop command accepts a --purge flag to also remove data volumes. The client connectivity check is also simplified from 3 retries with exponential backoff to a single ping, since the retries only existed to compensate for the race between auto-starting containers and the client connecting.
Follows Go naming conventions where the package name already provides context, so daemon.New reads better than daemon.NewDaemonCmd.
Extract a composeCmd helper in the docker compose manager to eliminate duplicated exec.Cmd construction across Start, down, and isContainerRunning. This also fixes a subtle inconsistency where down and isContainerRunning were using the raw ComposeYAML instead of the patched output from getComposeYAML. Remove the IsRunning guards from the start and stop subcommands since docker compose up and down are idempotent operations. The guards introduced a TOCTOU race without adding value.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the CLI’s implicit “auto-start local docker-compose daemon when targeting localhost” behavior and replaces it with explicit daemon lifecycle commands (arctl daemon start|stop|status), so the CLI fails fast when the registry is unreachable rather than silently spinning up local infrastructure.
Changes:
- Add explicit
daemoncommand group withstart,stop(with--purge), andstatus. - Extend the docker-compose daemon manager with
Stop()/Purge()and refactor compose command construction. - Simplify client connectivity verification from retry/backoff to a single
Ping().
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/types/types.go | Extends DaemonManager interface with stop/purge lifecycle methods. |
| pkg/daemon/dockercompose/manager.go | Implements Stop()/Purge() via docker compose down, refactors command construction. |
| pkg/cli/root.go | Removes daemon auto-start logic; adds daemon command to root; simplifies client creation and error message. |
| pkg/cli/root_test.go | Updates tests to reflect new pre-run behavior and error messaging. |
| pkg/cli/commands_test.go | Updates command tree expectations to include daemon. |
| internal/client/client.go | Removes retry-based ping logic; uses single Ping() for connectivity check. |
| internal/cli/daemon/daemon.go | Introduces daemon command tree wiring to the daemon manager. |
| internal/cli/daemon/daemon_test.go | Adds unit tests for daemon start/stop/status commands. |
Comments suppressed due to low confidence (1)
pkg/cli/root.go:41
- Removing
CLIOptions.DaemonManageris a compile-time breaking change for any external code configuring the CLI viacli.Configure(). Ifpkg/cliis intended to be used as a library, consider keeping the field (even if unused by default) or introducing a new options struct/versioned API to avoid breaking downstream builds.
// CLIOptions configures the CLI behavior.
// Can be extended for more options (e.g. client factory).
type CLIOptions struct {
// AuthnProviderFactory provides CLI-specific authentication.
AuthnProviderFactory types.CLIAuthnProviderFactory
// OnTokenResolved is called when a token is resolved.
// This allows extensions to perform additional actions when a token is resolved (e.g. storing locally).
OnTokenResolved func(token string) error
// ClientFactory creates the API client. If nil, uses client.NewClientWithConfig (requires network).
ClientFactory ClientFactory
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
Need to figure out the e2e failures a bit. We were relying on the implicit behavior before. Have a couple of options here, but need to explore a bit more locally the right approach here. |
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.
Description
The root command's PersistentPreRunE hook previously auto-started
Docker containers (postgres + registry server) whenever the
registry URL targeted localhost:12121. This was a footgun for
users with existing registries, e.g. port-forwarding a Kubernetes
registry to localhost:12121 would risk silently spinning up a
separate local instance if the port-forward dropped.
We now follow the Docker CLI/daemon model where the CLI never
auto-starts infrastructure and fails fast if the registry is
unreachable. Daemon lifecycle is managed explicitly through
arctl daemon start, stop, and status subcommands. The stop
command accepts a --purge flag to also remove data volumes.
The client connectivity check is also simplified from 3 retries
with exponential backoff to a single ping, since the retries
only existed to compensate for the race between auto-starting
containers and the client connecting.
Fixes #307.
Change Type
/kind fix
Changelog
Additional Notes