-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Adds recording encryption manager #55078
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
base: master
Are you sure you want to change the base?
Conversation
7c97b4f
to
1a198d9
Compare
c900a70
to
cee99e5
Compare
1a198d9
to
7713063
Compare
cee99e5
to
7afa9b6
Compare
e944d7d
to
848b135
Compare
7afa9b6
to
6fa728b
Compare
37bcbfe
to
06206eb
Compare
653f866
to
23d65c6
Compare
4950191
to
54c711f
Compare
54c711f
to
df2ca7c
Compare
7f1c265
to
5f9781b
Compare
2aff1c8
to
cff5c92
Compare
bc89945
to
3860f34
Compare
d3760ee
to
78d0a9c
Compare
// recording encryption key pairs) will be fulfilled using their public key encryption keys. | ||
// | ||
// If there are no unfulfilled keys present, then nothing should be done. | ||
func (m *Manager) ResolveRecordingEncryption(ctx context.Context, postProcessFn func(context.Context, *recordingencryptionv1.RecordingEncryption) error) (encryption *recordingencryptionv1.RecordingEncryption, err error) { |
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 the postProcessFn necessary? If this function returns the resolved recordingencryptionv1.RecordingEncryption
can't callers mutate the returned encryption directly instead of via the callback?
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.
The postProcessFn
really only exists to update the public encryption keys in the session_recording_config
in the same lock as resolving the recording_encryption
resource. I had originally avoided acquiring the lock within ResolveRecordingEncryption
so it wasn't necessary, but I think it makes more sense to make sure it's impossible to call concurrently.
Maybe postProcessFn
is a bit of a misnomer and it should be something like onResolvedFn
instead?
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'm wondering if there is any benefit to separating the Manager and the ClusterConfigService. The decoupling is what led to this callback in the first place, but I'm not sure it adds much given how simple the ClusterConfigService wrapper is. What do you think?
6f616df
to
c9cb026
Compare
…ops more complex than CRUD
7126b84
to
5feae17
Compare
…gurationInternal a interface for interacting with the session_recording_config within the same lock that recording encryption keys are resolved
5feae17
to
f956674
Compare
// If there are no unfulfilled keys present, then nothing should be done. | ||
func (m *Manager) ResolveRecordingEncryption(ctx context.Context) (encryption *recordingencryptionv1.RecordingEncryption, err error) { | ||
err = backend.RunWhileLocked(ctx, m.lockConfig, func(ctx context.Context) error { | ||
if m.sessionRecordingConfig == 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.
It feels slightly wrong that we seem to be relying on the backend lock to perform as a synchronization mechanism for sessionRecordingConfig. Who now has the responsibility of calling ResolveRecordingEncryption
? Is it still the the ClusterConfigService
implemented in https://github.com/gravitational/teleport/pull/54901/files?
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.
It was the ClusterConfigService
and the RecordingEncryption
watcher, but I'm increasingly having to jump through hoops in order to make that implementation work. At this point I think having a second watcher on the SessionRecordingConfig
is simpler and probably better performing since the Manager
can just cache it 99% of the time. The latest commit I pushed implements that and #54901 should no longer have ClusterConfigService
, which means the only caller of ResolveRecordingEncryption
is the watcher.
As far as synchronization goes, I'm not sure of another way to approach it 🤔 There is the possibility of a data race right now because manual edits to the session_recording_config
don't happen within a lock. That could be fixed by using the same lock in the ClusterConfigurationService
, but that's just using more of the same sync mechanism. Maybe there's something I could do with an AtomicWrite
instead?
d02c350
to
2ba2ca1
Compare
This PR adds a
Manager
struct responsible for higher levelRecordingEncryption
operations such as resolving state in order to facilitate cooperation between auth servers. It also includes the implementation for a watcher that will automatically attempt to resolveRecordingEncryption
state whenever the resource is modified.