Skip to content

Make invalid states (more) representable #10

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

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Oct 23, 2024

Currently, the AntagonistError type has some errors that wrap other
values, but don't format those values when displayed. This is kind of
unfortunate. For example:

2024-10-23T21:01:34.795972Z ERROR omicron_stress: 202: invalid actor state
2024-10-23T21:01:34.796049Z  INFO omicron_stress: 218: Halting actors

Seeing this in my logs felt kind of painful, because it's like, "okay,
what was the invalid state?" and there's no way to find out what it was.
It turns out that there's a string that's in there which says what the
invalid state was, but it didn't get formatted in the Display impl,
and now the process has exited, so which invalid state occurred has been
permanently lost to the sands of time.

After this change, it now looks like this:

2024-10-23T21:25:17.983062Z ERROR omicron_stress: 202: invalid actor state: instance inst1 unexpectedly in state Failed
2024-10-23T21:25:17.983160Z  INFO omicron_stress: 218: Halting actors

If you compare this with the output from before, you will notice that I
have made invalid states representable. In this case, that's actually a
good thing.

Currently, the `AntagonistError` type has some errors that wrap other
values, but don't format those values when displayed. This is kind of
unfortunate. For example:

```
2024-10-23T21:01:34.795972Z ERROR omicron_stress: 202: invalid actor state
2024-10-23T21:01:34.796049Z  INFO omicron_stress: 218: Halting actors
```

Seeing this in my logs felt kind of painful, because it's like, "okay,
what was the invalid state?" and there's no way to find out what it was.
It turns out that there's a string that's in there which says what the
invalid state was, but it didn't get formatted in the `Display` impl,
and now the process has exited, so which invalid state occurred has been
permanently lost to the sands of time.

After this change, it now looks like this:

```
2024-10-23T21:25:17.983062Z ERROR omicron_stress: 202: invalid actor state: instance inst1 unexpectedly in state Failed
2024-10-23T21:25:17.983160Z  INFO omicron_stress: 218: Halting actors
```

If you compare this with the output from before, you will notice that I
have made invalid states representable. In this case, that's actually a
good thing.
@hawkw hawkw requested review from jmpesp and gjcolombo October 23, 2024 22:12
@hawkw
Copy link
Member Author

hawkw commented Oct 23, 2024

See also oxidecomputer/omicron#6913 (comment) for a record of my mental anguish upon discovering this.

@hawkw hawkw merged commit 0c91b24 into main Oct 24, 2024
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