-
Notifications
You must be signed in to change notification settings - Fork 6
Avoid panics on not owner errors because they should go away #169
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
Conversation
| if err != nil && err != registry.ErrNotOwner { | ||
| panic(fmt.Errorf("%w: unable to deregister mailbox: %v, error: %v", errDeregisteredFailed, nsName, err)) | ||
| } |
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.
[Q] How do we know these will go away?
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.
They are owned by an expired lease
Co-authored-by: Eric Sniff <[email protected]>
| return err != nil | ||
| }) | ||
| if err != nil { | ||
| // Ingnore ErrNotOwner because most likely the previous owner panic'ed or exited badly. | ||
| // So we'll ignore the error and let the mailbox creator retry later. We don't want to panic | ||
| // in that case because it will take down more mailboxes and make it worse. | ||
| if err != nil && err != registry.ErrNotOwner { |
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.
We should check this earlier, otherwise we're doing unnecessary retries:
switch {
case err == nil:
return false
// Ignore ErrNotOwner because most likely the previous owner panic'ed or exited badly.
// So we'll ignore the error and let the mailbox creator retry later. We don't want to panic
// in that case because it will take down more mailboxes and make it worse.
case errors.Is(err, registry.ErrNotOwner):
err = nil
return false
default:
return true
}
})
if err != nil {
panic(fmt.Errorf("%w: unable to deregister mailbox: %v, error: %v", errDeregisteredFailed, nsName, err))
}| return err != nil | ||
| }) | ||
| if err != nil { | ||
| // Ingnore ErrNotOwner because most likely the previous owner panic'ed or exited badly. | ||
| // So we'll ignore the error and let the mailbox creator retry later. We don't want to panic | ||
| // in that case because it will take down more mailboxes and make it worse. | ||
| if err != nil && err != registry.ErrNotOwner { | ||
| panic(fmt.Sprintf("unable to deregister actor: %v, error: %v", nsName, err)) | ||
| } |
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.
Same here:
switch {
case err == nil:
return false
case errors.Is(err, registry.ErrNotOwner):
err = nil
return false
default:
return true
}
})
if err != nil {
panic(fmt.Errorf("%w: unable to deregister mailbox: %v, error: %v", errDeregisteredFailed, nsName, err))
}
No description provided.