Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream release command app logs #4020

Merged
merged 3 commits into from
Nov 1, 2024
Merged

Conversation

wjordan
Copy link
Contributor

@wjordan wjordan commented Oct 21, 2024

This PR changes the release command logic to stream release command machine logs during execution, instead of only fetching them afterwards. This should help improve the log-fetching experience in release commands as a response the recently increased ingestion delay in the app logs endpoint.

Logs will be printed to standard error in real-time when using the --verbose flag, or otherwise the last 100 lines will be buffered and displayed on a command failure. (We can adjust this to display more lines, or all of them if that would be better!)

The stream will use NATS logs by default, with a fallback to polling the logs API if the wireguard connection is unavailable. By setting up the stream before starting the machine, NATS won't miss any of the release command logs.

NATS logs should provide a better experience than the app logs API for longer commands, since streaming logs can be printed in real-time to the console. It also doesn't depend on the availability of a centralized log-ingestion server, so it may be more reliable.

This PR also improves the fallback API polling, by waiting until the release command finishes fetching all of the logs (in verbose mode or if there is a command failure) by matching the "Main child exited normally" string at the end of the app logs when a command exits.

Finally, this fixes a bug where a log-fetching failure would exit the release command with an error, preventing the deploy from continuing. This would block deploys after successful release commands with the --verbose flag when the logs cluster was unavailable.

Documentation

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

stream logs to the console with the `--verbose` flag,
or display the last 100 lines after a command failure.
fmt.Fprintln(md.io.ErrOut, "Starting machine")

if err = releaseCmdMachine.Start(ctx); err != nil {
fmt.Fprintf(md.io.ErrOut, "error updating release_command machine: %v\n", err)
Copy link
Member

Choose a reason for hiding this comment

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

is it error starting release_command machine?

@wjordan wjordan merged commit 37a4189 into master Nov 1, 2024
21 of 30 checks passed
@wjordan wjordan deleted the stream-release-command-logs branch November 1, 2024 16: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.

2 participants