-
Notifications
You must be signed in to change notification settings - Fork 599
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
auditing: construct metrics probe during service construction #24108
auditing: construct metrics probe during service construction #24108
Conversation
Move the construction of the audit probe from service start to service construction. Previously, the audit probe was created as a unique pointer when the service was started and destroyed when the service stopped. Since the audit service has the same lifespan as the application, creating the probe during service construction reduces the risk of dereferencing a null pointer if the probe is accessed before the service has started. Signed-off-by: Michael Boquard <[email protected]>
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. Added Ben to the review because I'm never too sure about this stuff.
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 looks safe, but I have concerns that the service is being used before it is started.
For example, it's not clear without deep inspection of the code that calling drain is safe before the sink has been started.
It's also not clear that client_shard_id
has been constructed before events can be received on other shards.
I think it may make sense to set the drain timer in start()
, and move stuff from start to the constructor where possible.
Overall, it would be better to fix this by starting the service before it is used..
Yeah I was discussing exactly this with @oleiman yesterday. The problem is that I don't think we can kick off the sink until after the kafka API is available.
So the drain timer isn't armed until after the sink has been started so I believe this is safe.
It should be constructed when the service is constructed, no?
It is, in a somewhat round-about way based on the value of
So again, I don't think we can start the sink before the kafka service is up. One idea I had was to start the service very early and then enable the sink via another method once the kafka API is up and running. |
Agreed.
OK, I see it's ultimately called from
I think I fumbled that comment. I was talking about
Yeah, after digging around, I see that.
I get it now. |
/backport v24.2.x |
/backport v24.1.x |
// Probe is mutable so it can be modified in const methods when they need to | ||
// report auditing failures | ||
mutable audit_probe _probe; |
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.
afaik the contract isn't "so i can modify it in const methods" it's that the public api maintains logical constness. since the probe is exposed (e.g. probe()) it's not clear that this is technically correct.
Move the construction of the audit probe from service start to service construction. Previously, the audit probe was created as a unique pointer when the service was started and destroyed when the service stopped.
Since the audit service has the same lifespan as the application, creating the probe during service construction reduces the risk of dereferencing a null pointer if the probe is accessed before the service has started.
Backports Required
Release Notes
Bug Fixes