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

Upstream processed exec implementation #20

Merged
merged 11 commits into from
Jun 15, 2023
Merged

Upstream processed exec implementation #20

merged 11 commits into from
Jun 15, 2023

Conversation

ZacSweers
Copy link
Collaborator

@ZacSweers ZacSweers commented Jun 12, 2023

This introduces a new ProcessedExecCli program that can be used to execute commands with a layer of added tracing. This CLI does the following

  • Executes a given command
  • If the command fails
    • Notifies an issue to Bugsnag
    • Checks if the command should be retried (possibly with a delay). If it can be, it's retried once.
  • If the command is successful, it's just a passthrough layer
  • Can read a config JSON file like so
     {
       "version": 1,
       "known_issues": [
         {
           "message": "Message shown in bugsnag",
           "log_message": "Message logged in CI, more detailed.",
           "matching_text": "The CI log text to match",
           "grouping_hash": "a-unique-string-for-bugsnag-grouping",
           "retry_signal": {
             "type": "delayed",
             "delay": 60000
           }
         }
       ]
     }

Usage

Use this in a local CI kts script and then pass it args

processed-exec.main.kts

#!/usr/bin/env kotlin
@file:DependsOn("com.slack.cli:kotlin-cli-util:x.y.z")

fun main(args: Array<String>) = ProcessedExecCli().main(args)
$ ./processed-exec.main.kts ./your-real-ci-script.sh

Future work

  • Add issues that can fail a passing build (we've had cases in the past where the presence of certain logs are things we want to treat as an error).
  • Configurability of how many retries.

@ZacSweers ZacSweers requested a review from valeraz June 12, 2023 19:44
when (val retrySignal = resultProcessor.process(logFile, false)) {
is RetrySignal.Ack,
RetrySignal.Unknown -> {
echo("Processor exited with 0, exiting with original exit code...")
Copy link

Choose a reason for hiding this comment

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

This output is wrong, if it exited with 0 we wouldn't be here. We also exit this process with 0 always (line 111), do we want to reflect the actual result of the command or do we always want to succeed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch e8c3d17

break
}
is RetrySignal.RetryDelayed -> {
echo("Processor script exited with 2, rerunning the command after 1 minute...")
Copy link

Choose a reason for hiding this comment

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

1 minute may not be correct, since we pull the delay from the retry signal

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

branch.startsWith("mq-") || branch.startsWith("gh-readonly-queue") -> "merge-queue"
else -> "pull-request"
}
setReleaseStage(releaseStage)
Copy link

Choose a reason for hiding this comment

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

This is nice

@ZacSweers ZacSweers merged commit e39d674 into main Jun 15, 2023
1 check passed
@ZacSweers ZacSweers deleted the z/processedExec branch June 15, 2023 20:36
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.

None yet

2 participants