Skip to content

trust-tunnel-agent exits successfully even when server startup fails #5

Description

@peasewan

Describe the bug

trust-tunnel-agent swallows errors returned by runServer in the Cobra command handler. If the server fails to start, the error is printed to stderr, but RunE still returns nil, so the process exits successfully.

This can make container runtimes, scripts, CI jobs, or supervisors treat a failed agent startup as healthy.

Code path

In cmd/trust-tunnel-agent/app/cmd.go:

if err := runServer(&options); err != nil {
    fmt.Fprintf(os.Stderr, "%v\n", err)
}
return nil

runServer returns server.Start(opt), and server.Start returns errors from ListenAndServe, ListenAndServeTLS, or TLS/config setup. Those errors should propagate back to Cobra instead of being ignored.

Expected behavior

If the agent cannot start, the command should return a non-nil error and exit with a non-zero status.

For example:

if err := runServer(&options); err != nil {
    return err
}
return nil

Impact

Startup failures such as an invalid listen address, port already in use, or TLS file/config errors can be reported as successful process exits. This is especially problematic when the agent is launched by Kubernetes, Docker, systemd, or automation scripts that rely on exit status.

Environment

  • Repository: current main
  • File: cmd/trust-tunnel-agent/app/cmd.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions