-
Notifications
You must be signed in to change notification settings - Fork 805
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
Temporary patch: ensure errors lead to exit(1) in main funcs #6318
Conversation
The main docker-compose.yml is currently erroring silently without printing anything due to... either the urfave/cli/v2 migration (i.e. changes in urfave), or simply a long-standing bug that should be squashed. So this changes all our `func main`s to check for error returns, and print and exit them. We're going to be doing some rewriting of error handling in these CLIs very soon, so for now I'm just doing the simplest patch possible, to ease troubleshooting.
@@ -547,6 +547,7 @@ github.com/shirou/gopsutil/v3 v3.22.4 h1:srAQaiX6jX/cYL6q29aE0m8lOskT9CurZ9N61YR | |||
github.com/shirou/gopsutil/v3 v3.22.4/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM= | |||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM= | |||
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041 h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc= | |||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it came in because I made other dependency changes lately... but make tidy
(and thus go mod tidy
) doesn't get rid of it, so I think yes? or at least it's harmless, unless CI takes issue with it.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted filessee 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
…where (#6322) Clean-up and follow-up from #6285 and #6318, but only part 1 of [probably 2]. The next part will change our ErrorAndExit calls into error returns, so we get chains of causes rather than just one message when a fatal error is hit. If there's a part 3, maybe it'll use https://github.com/bracesdev/errtrace or a https://github.com/pkg/errors-like wrapper to collect useful stack traces along with the error returns, to bring back `CADENCE_CLI_SHOW_STACKS` for all errors. --- Contains three major changes: 1. creates some standard "literally all CLIs" tooling in common/commoncli (to avoid conflicts with "common" and "cli") 2. moves `cli.NewApp()` and `PrintableError` into commoncli (as `New` and `Problem`) 3. fancy shmancy wrapped error printing with indentation, nested-error cleanup, and colors (we had colors before) 1 and 2 are pretty straightforward, and I've added a simple lint to block using urfave directly to make CLIs (to prevent accidentally using it in the future). 3 is an attempt at "what if our error messages were similar but less bad". And it also serves as an example of what you can do with enough force with wrapped errors. --- Ultimately, this gives us (the ability to) have errors print like this: ``` Error: the most-recent cause of the problem Error details: wrapped error details if they exist Error: another commoncli.Problem from further down the stack Error details: and other wrapped errors that it may contain ``` Rather than like this: ``` Error: the most-recent cause of the problem Error details: wrapped error: details if they exist: another commoncli.Problem from further down the stack: and other wrapped errors: that it may contain ``` Because it looks "in the same spirit" as the printing before, but is hopefully more readable. And hopefully it also helps show enough error-spelunking details that someone can figure out much fancier and more structured errors later, if desired. This also ends up changing the main server binary to use this same fancy error printing, where before it did not: ``` ❯ ./cadence-server start 2024/10/02 22:26:06 Loading config; env=development,zone=,configDir=./config 2024/10/02 22:26:06 Loading configFiles=[./config/base.yaml ./config/development.yaml] 2024/10/02 22:26:06 [WARN] dcRedirectionPolicy config is deprecated. Please replace it with clusterRedirectionPolicy. 2024/10/02 22:26:06 gocql: unable to dial control conn 127.0.0.1:9042: dial tcp 127.0.0.1:9042: connect: connection refused Error: cassandra schema version compatibility check failed Error details: creating CQL client gocql: unable to create session: control: unable to connect to initial hosts: dial tcp 127.0.0.1:9042: connect: connection refused ``` vs before: ``` ❯ ./cadence-server start 2024/10/02 22:27:58 Loading config; env=development,zone=,configDir=./config 2024/10/02 22:27:58 Loading configFiles=[./config/base.yaml ./config/development.yaml] 2024/10/02 22:27:58 [WARN] dcRedirectionPolicy config is deprecated. Please replace it with clusterRedirectionPolicy. 2024/10/02 22:27:58 gocql: unable to dial control conn 127.0.0.1:9042: dial tcp 127.0.0.1:9042: connect: connection refused cassandra schema version compatibility check failed: creating CQL client: gocql: unable to create session: control: unable to connect to initial hosts: dial tcp 127.0.0.1:9042: connect: connection refused ``` which seems like probably a positive change. It is colorized, but fatih is smart enough to remove it when piped, and removing color from this binary all the time is fairly easy if we want.
The main docker-compose.yml is currently erroring silently without printing anything due to... either the urfave/cli/v2 migration (i.e. changes in urfave), or simply a long-standing silent-failure bug that should be squashed.
So this changes all our
func main
s to check for error returns, and print and exit them.We're going to be doing some rewriting of error handling in these CLIs very soon, so for now I'm just doing the simplest patch possible, to ease troubleshooting.