-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add transaction-like behavior for Transit persists. #3959
Conversation
This ensures that in-memory policy matches the state of on-disk policy if a storage error occurs.
} | ||
lock.RUnlock() |
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.
Missing defer in here?
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.
This should be unlocked right away. In theory in the rest of the test we should be grabbing a write lock on the policy, but since it's test-scoped and not in parallel we don't.
helper/keysutil/policy.go
Outdated
// roll back keys, but better safe than sorry and this doesn't happen | ||
// enough to worry about the speed tradeoff. | ||
priorArchiveVersion := p.ArchiveVersion | ||
priorKeys := keyEntryMap(nil) |
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.
Could this use copystructure.Copy(p.Keys)
so that we can just do p.Keys = priorKeys.(keyEntryMap)
similar do what is being done in Upgrade()
?
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.
Discussed internally, removed copystructure instead.
helper/keysutil/policy.go
Outdated
// roll back keys, but better safe than sorry and this doesn't happen | ||
// enough to worry about the speed tradeoff. | ||
priorArchiveVersion := p.ArchiveVersion | ||
priorKeys := keyEntryMap(nil) |
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.
FMI, is there a difference between this and var priorKeys keyEntryMap
?
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.
Nope.
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.
I'll convert to the other way to be a bit more canonical.
helper/keysutil/policy.go
Outdated
priorLatestVersion := p.LatestVersion | ||
priorMinDecryptionVersion := p.MinDecryptionVersion | ||
priorConvergentVersion := p.ConvergentVersion | ||
priorKeys, err := copystructure.Copy(p.Keys) |
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.
Is there a reason for using copystructure here vs doing a manual copy like in the Persist() and Rotate() functions? The only difference I see is that of the nil
check on p.Keys
.
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.
LGTM!
This ensures that in-memory policy matches the state of on-disk policy
if a storage error occurs.
Ref: #2705