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

Move location of quit channel closing in exp manager #3638

Merged
merged 3 commits into from
Dec 1, 2017

Conversation

jefferai
Copy link
Member

@jefferai jefferai commented Dec 1, 2017

If it happens after stopping timers any timers firing before all timers
are stopped will still run the revocation function. With plugin
auto-crash-recovery this could end up instantiating a plugin that could
then try to unwrap a token from a nil token store.

This also plumbs in core so that we can grab a read lock during the
operation and check standby/sealed status before running it (after
grabbing the lock).

If it happens after stopping timers any timers firing before all timers
are stopped will still run the revocation function. With plugin
auto-crash-recovery this could end up instantiating a plugin that could
then try to unwrap a token from a nil token store.

This also plumbs in core so that we can grab a read lock during the
operation and check standby/sealed status before running it (after
grabbing the lock).
@jefferai jefferai added this to the 0.9.1 milestone Dec 1, 2017
tokenView *BarrierView
tokenStore *TokenStore
logger log.Logger
coreStateLock *sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are storing core, we don't need to also store the state lock

Copy link
Member Author

Choose a reason for hiding this comment

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

It's true, the main reason I kept it like this is I would really rather not plumb through core, I just also figured we should check standby and sealed while we were at it and didn't feel like storing two pointers to bools. So I left it the easiest way to plumb back out.

briankassouf
briankassouf previously approved these changes Dec 1, 2017
Copy link
Contributor

@briankassouf briankassouf left a comment

Choose a reason for hiding this comment

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

One small comment, otherwise LGTM

@@ -969,13 +980,24 @@ func (m *ExpirationManager) expireID(leaseID string) {
return
default:
}

m.coreStateLock.RLock()
if m.quitContext.Err() == context.Canceled {
Copy link
Contributor

@briankassouf briankassouf Dec 1, 2017

Choose a reason for hiding this comment

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

Small nit, but this might be a better way of handling this case:

select {
case <- m.quitContext.Done():
	m.logger.Error("expiration: core context canceled, not attempting further revocation of lease", "lease_id", leaseID)
	m.coreStateLock.RUnlock()
	return
default:
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be safe; see https://golang.org/pkg/context/#pkg-variables

Canceled is the error returned by Context.Err when the context is canceled.

It's defined behavior so should be reliable.

@jefferai jefferai merged commit 276a230 into master Dec 1, 2017
@jefferai jefferai deleted the exp-shutdown-revocation branch December 1, 2017 22:08
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