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

Refactor error handling #303

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

obbardc
Copy link
Member

@obbardc obbardc commented Jan 7, 2022

Currently the debos error handling sets an exitcode
during running, then exits with that code. Since we
only ever exit with a 1, unless an error occurs while
running fakemachine, let's switch around the error
handling to use the context.State and check the state
after running.

Signed-off-by: Christopher Obbard chris.obbard@collabora.com

See-also the Fakemachine improvements: go-debos/fakemachine#74

@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch 2 times, most recently from 4d0f172 to 9d2b107 Compare January 7, 2022 11:26
@obbardc obbardc marked this pull request as draft January 7, 2022 11:49
@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch from 9d2b107 to 6687aa2 Compare March 9, 2022 11:26
@obbardc obbardc changed the title RFC: Refactor the error handling Refactor the error handling Mar 9, 2022
@obbardc obbardc marked this pull request as ready for review March 9, 2022 11:28
@obbardc obbardc marked this pull request as draft April 7, 2022 13:46
@obbardc obbardc added this to the v1.1.0 milestone Apr 14, 2022
@obbardc obbardc removed this from the v1.1.0 milestone Apr 27, 2022
@obbardc obbardc added this to the v1.1.2 milestone Oct 12, 2022
@obbardc obbardc self-assigned this Nov 2, 2022
@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch from 6687aa2 to de7d9b2 Compare November 2, 2022 18:30
cmd/debos/debos.go Outdated Show resolved Hide resolved
cmd/debos/debos.go Outdated Show resolved Hide resolved
cmd/debos/debos.go Outdated Show resolved Hide resolved
cmd/debos/debos.go Outdated Show resolved Hide resolved
cmd/debos/debos.go Outdated Show resolved Hide resolved
@obbardc obbardc marked this pull request as ready for review November 2, 2022 18:32
@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch from de7d9b2 to b75eafc Compare November 2, 2022 18:33
cmd/debos/debos.go Outdated Show resolved Hide resolved
commands.go Outdated Show resolved Hide resolved
@evelikov
Copy link

evelikov commented Nov 2, 2022

The newQemuHelper() suggestion for s/q/nil/ is the only tangible one. Take the rest with with a healthy pinch of salt.

@evelikov
Copy link

evelikov commented Jan 9, 2023

Any updates on this? As mentioned above - the newQemuHelper suggestion is the only one of value, where the rest are a matter of taste so don't read too much into them.

@obbardc
Copy link
Member Author

obbardc commented Jan 9, 2023

Any updates on this? As mentioned above - the newQemuHelper suggestion is the only one of value, where the rest are a matter of taste so don't read too much into them.

It's on my TODO list for Jan.

@evelikov
Copy link

If you can add some tests, that would be great. The MR from Ed had a recent amount IMHO.

@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch from b75eafc to 0516571 Compare July 17, 2023 12:15
@obbardc obbardc changed the title Refactor the error handling Refactor error handling Jul 17, 2023
@sjoerdsimons
Copy link
Member

@obbardc please fix the CI errors

@obbardc obbardc marked this pull request as draft July 22, 2023 10:18
@obbardc
Copy link
Member Author

obbardc commented Jul 22, 2023

@obbardc please fix the CI errors

Sure, this also needs further rework so I have marked it as a draft.

@sjoerdsimons sjoerdsimons force-pushed the wip/obbardc/cleanup-error-handling branch from 0516571 to a25cb9a Compare July 24, 2023 14:53
@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch 3 times, most recently from 3f91bbe to 32e7464 Compare July 26, 2023 13:58
@obbardc obbardc marked this pull request as ready for review July 26, 2023 14:00
@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch from 32e7464 to 2810962 Compare July 26, 2023 14:06
@evelikov
Copy link

evelikov commented Oct 3, 2023

Humble poke?

@obbardc obbardc modified the milestones: v1.1.2, v1.1.4 Jan 10, 2024
Rather than panicing on error, bubble up an error so that the execution
may recover correctly and the error shown to the user.

Fixes: go-debos#413
Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
Currently the debos error handling sets an exitcode during the run, then
exits with that code once execution has finished. This paradigm is quite
fragile, so let's switch around the error handling to use context.State
to track errors and check the state of this variable after the run has
completed.

While we are here, rename the checkError function to handleError to better
describe the function's intent and make it return a boolean to show that
an error has been handled. Rework the do_run function to also return a
boolean to show that an error occurred during the run.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
Rework the error handling to show where an error occured during the run.
Also print all error messages to the log rather than stdout.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
@obbardc obbardc force-pushed the wip/obbardc/cleanup-error-handling branch from 2810962 to aa1e5a0 Compare January 10, 2024 17:35
Copy link
Member

Choose a reason for hiding this comment

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

You mention "this paradigm is quite fragile" but all this change seems to do is rather then having a local variable track the error state (in the form of error code) you moved it to marking it in the context. I'm not really sure why that's less fragile ;)

it does make the code a big more clear though so seems reasonable

strings.Contains(value, "127.0.0.1") ||
strings.Contains(value, "::1") {
strings.Contains(value, "127.0.0.1") ||
strings.Contains(value, "::1") {
Copy link
Member

Choose a reason for hiding this comment

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

these don't look like typo fixes

PrintRecipe bool `long:"print-recipe" description:"Print final recipe"`
DryRun bool `long:"dry-run" description:"Compose final recipe to build but without any real work started"`
DisableFakeMachine bool `long:"disable-fakemachine" description:"Do not use fakemachine."`
Backend string `short:"b" long:"fakemachine-backend" description:"Fakemachine backend to use" default:"auto"`
Copy link
Member

Choose a reason for hiding this comment

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

more spurious changes that aren't typo fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review required
Development

Successfully merging this pull request may close these issues.

None yet

3 participants