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

[JUJU-4012] Allow runners to stop based on an error #28

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Jun 21, 2023

The following allows a runner to be stopped based on an error message. This makes it much more flexible in the phase of workers stopping based on an error, yet we don't want them to restart for some reason.

In addition, returning nil from some workers in the expectation that will ensure a clean kill is also mistaken. If using a runner to ensure workers stay running, returning nil will just cause that worker to restart after the delay. This probably isn't what we want in all scenarios. Adding this check allows us to add logic based on returned error cases to control the lifecycle of the worker.

This shouldn't require a new version either. Although we're adding a new field to the RunnerParams. We're backward compatible by ensuring that IsStoppable returns false by default.

The following allows a runner to be stopped based on an error
message. This makes it much more flexible in the phase of workers
stopping based on an error, yet we don't want them to restart for
some reason.
@SimonRichardson SimonRichardson changed the title Allow runners to stop based on an error [JUJU-4012] Allow runners to stop based on an error Jun 21, 2023
@SimonRichardson SimonRichardson self-assigned this Jun 21, 2023
starter.die <- fmt.Errorf("non-fatal error")
starter.assertStarted(c, false)
starter.assertNeverStarted(c, delay)
c.Assert(worker.Stop(runner), gc.IsNil)
Copy link
Member

@manadart manadart Jun 26, 2023

Choose a reason for hiding this comment

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

Should we test that worker.Runner returns a NotFound after it gets the error?

Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

What do you think of inverting the bool and calling the function ShouldRestart?

I think I like this better, because automatically restarting non-fatal exits is a core consideration of the runner, and that's what this is addressing.

Happy to add the functionality in any case.

It's clearer than the previous name. By indicating what will happen
if you return false it prevents a restart happening.
@SimonRichardson
Copy link
Member Author

/merge

@jujubot jujubot merged commit e43ac12 into juju:master Jun 26, 2023
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.

3 participants