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

Explicitly cover only specific plan status for cleanup plans #1358

Merged
merged 1 commit into from
Feb 25, 2020
Merged

Conversation

nfnt
Copy link
Member

@nfnt nfnt commented Feb 21, 2020

What this PR does / why we need it:
This ensure that cleanup plans aren't (re-)started after a fatal error.

Fixes #1357

This ensure that cleanup plans aren't (re-)started after a fatal error.

Signed-off-by: Jan Schlicht <jan@d2iq.com>
@nfnt nfnt added the kind/bug label Feb 21, 2020
@nfnt nfnt requested a review from zen-dog February 21, 2020 14:21
@nfnt nfnt self-assigned this Feb 21, 2020
return plan, nil
case kudov1beta1.ExecutionComplete:
Copy link
Member

Choose a reason for hiding this comment

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

What happens in the case of ExecutionFatalError?

We should probably check for planStatus.isTerminal, i guess?

Copy link
Member

Choose a reason for hiding this comment

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

I just looked at the surrounding code. I think the if i.isDeleting() { block should always return, at the moment it falls through to i.GetPlanInProgress() != nil { etc. This might lead to the correct result, but it's not really clear from the code what actually should happen

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the if i.isDeleting() { block should always return, at the moment it falls through to i.GetPlanInProgress() != nil {

the i.GetPlanInProgress is outside of the i.isDeleting block. The problem here is/was that if !planStatus.Status.IsRunning() on the left side also covers the ExecutionFatalError case, where the plan is returned here and then reseted/restarted in the caller (we obviously don't want to infinitely restart plans in FATAL_ERROR status).

I'm reworking this part of logic as part of my PR so I would go for a bigger refactoring here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the left side is certainly not correct. I'm just noted that the new code does not clearly states what happens in case of a ExecutionFatalError. If we add an additional

case kudov1beta1.ExecutionFatalError:
   // Don't restart in case of a fatal error
  return nil, nil

it would feel a lot more clear to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is implicitly covered by the subsequent i.GetPlanInProgress() check and thus redundant but I don't mind.

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to see it changed, but it's not really a requirement for me, so approving for now.

return nil, nil
}
switch planStatus.Status {
case kudov1beta1.ExecutionNeverRun:
Copy link
Member

Choose a reason for hiding this comment

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

I assume this would be ok, as the the cleanup plan is only ran on the deletion of the instance CR?

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

Lgtm

return plan, nil
case kudov1beta1.ExecutionComplete:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the if i.isDeleting() { block should always return, at the moment it falls through to i.GetPlanInProgress() != nil {

the i.GetPlanInProgress is outside of the i.isDeleting block. The problem here is/was that if !planStatus.Status.IsRunning() on the left side also covers the ExecutionFatalError case, where the plan is returned here and then reseted/restarted in the caller (we obviously don't want to infinitely restart plans in FATAL_ERROR status).

I'm reworking this part of logic as part of my PR so I would go for a bigger refactoring here.

@nfnt nfnt merged commit 262a562 into master Feb 25, 2020
@nfnt nfnt deleted the nfnt/1357 branch February 25, 2020 09:54
runyontr pushed a commit that referenced this pull request Mar 11, 2020
This ensure that cleanup plans aren't (re-)started after a fatal error.

Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Thomas Runyon <runyontr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KUDO cleanup plan will end in an infinite loop in case of a FATAL_ERROR
3 participants