-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
maintenance window agent export logic #23062
Conversation
d9a79d4
to
bb98e4a
Compare
9b29ab6
to
c9704de
Compare
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.
These are largely nits. Feel free to push back on whatever!
// Exporter is a helper used to | ||
type Exporter[C contextLike] struct { | ||
cfg ExporterConfig[C] | ||
closeContext context.Context |
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 was pinged on a review recently and advised not to store context in structs. Seems like a reasonable idea. It'd be easy enough to adjust the call to Run
in service.go
to just say something like:
process.RegisterCriticalFunc("maintenancewindow.export", func() error {
return exporter.Run(process.ExitContext())
)
I don't know that Close
would be necessary if you did this, as the context would be canceled as part of process shutdown.
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 am going to push back on this one... storing a request scoped (or potentially request-scoped) context in a struct is bad, because it makes it too easy to accidentally introduce weird memory leaks. This is because request-scoped context frequently hold onto references to lots of request-scoped date (e.g. certs).
Using context.Background()
to create a cancellation helper for a component that does cancellable I/O is fine IMO. Rather than bake our own alternative closure mechanism, if I were to deviate from this pattern I'd probably deviate by creating a custom CloseContext
helper type that implements context.Context
and never contains any context values (i.e. a context type that statically promises that it does not hold references to request-scoped values).
We could use process.ExitContext()
, but IMO that's not a great pattern. I've found myself leaning toward the opinion that persistent components should be explicitly rather than implicitly closed where possible. Mostly because this allows control of the order of closure. Context cancellation cancels all layers simultaneously, which has caused confusing errors for us in the past. Mostly a moot point here, since no other components rely on exporter being healthy, but it's a pattern I'm trying to force myself to stick to.
return nil | ||
} | ||
|
||
func (e *Exporter[C]) event(event testEvent) { |
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 like this a lot!
2279020
to
8a328e1
Compare
@fspmarshall - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes. |
5cd6d5f
to
d31ba43
Compare
You have successfully added a new Trivy configuration |
717f489
to
6be6771
Compare
d31ba43
to
bd290e2
Compare
adds client-side logic for exporting maintenance windows for external updaters. export behavior is enabled via env var (`TELEPORT_EXT_UPGRADER=kube|unit`).
1534588
to
827af87
Compare
Implementation of the agent-side logic corresponding to #22850
This PR introduces maintenance window export logic for the kube controller and systemd unit based external upgraders. When enabled, the teleport agent periodically loads maintenance window info from auth and exports it to an appropriate location for the upgrader to consume it.
The behavior is toggled by setting an environment variable (
TELEPORT_EXT_UPGRADER=kube|unit
). This flag is not intended to be set by users. Upgrader packages will set the appropriate value automatically.Note: this PR is currently pointing toward fspmarshall/maintenance-window-auth-v2 and will be rebased to master once the changes it depends on get merged.