Skip to content

Conversation

@geropl
Copy link
Member

@geropl geropl commented Jan 12, 2026

Problem

When previewctl install-context fails, the error message only shows exit status 1 without any context about what went wrong:

+ previewctl install-context --branch workspace-637d043885 --log-level debug --timeout 10m
Error: exit status 1
...
time="2026-01-12 13:32:49" level=fatal msg="command failed." err="exit status 1"

Root Cause

The failure happens before any logging occurs, likely in PreRunE when generating the SSH key. The GenerateSSHPrivateKey() function:

  1. Doesn't create the parent directory if it doesn't exist (e.g., /github/home/.ssh/)
  2. Uses cmd.Run() which discards all output, so ssh-keygen failures are silent

Solution

1. Fix SSH key generation (preview.go)

  • Create the parent directory with os.MkdirAll() before running ssh-keygen
  • Capture and include ssh-keygen output in error messages

2. Add error logging in install function (install_context.go)

  • Log errors with context at each failure point:
    • failed to get preview name
    • failed to create preview config
    • failed to install context

This complements PR #21246 which added error logging in installVMSSHKeys().

Log errors with context at each failure point in the install() function
to help diagnose which step is failing during preview environment setup.

Co-authored-by: Ona <no-reply@ona.com>
@geropl geropl merged commit a434b92 into main Jan 12, 2026
14 checks passed
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