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
Modularize eventsmap and monitor.Agent #25197
Modularize eventsmap and monitor.Agent #25197
Conversation
4cca0b3
to
ae82183
Compare
Huh, the integration test failure is an ipcache/identity cache panic, seemingly unrelated to my PR:
Adressed in #25353, rerunning. |
/test |
ae82183
to
ae9a453
Compare
That link unfortunately doesn't show commit contents anymore. Presumably because you've updated/rebased the commits on the branch? |
ae9a453
to
afa6252
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.
Some nits only, take them as coming from from a complete novice in hive/cell :-)
pkg/monitor/agent/cell.go
Outdated
flags.Int("monitor-queue-size", 0, "Size of the event queue when reading monitor events") | ||
} | ||
|
||
func new(lc hive.Lifecycle, log logrus.FieldLogger, cfg AgentConfig, _ eventsmap.Map) Agent { |
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'd prefer naming this to newMonitorAgent
for the sake of "greppability".
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.
Since it's not exported the naming doesn't matter much. For exported constructors I'd still recommend just using New
as per usual Go guidelines. You can always grep for foo.New
.
test/controlplane/suite/agent.go
Outdated
@@ -20,6 +20,8 @@ import ( | |||
"github.com/cilium/cilium/pkg/maps/authmap" | |||
fakeauthmap "github.com/cilium/cilium/pkg/maps/authmap/fake" | |||
"github.com/cilium/cilium/pkg/maps/egressmap" | |||
"github.com/cilium/cilium/pkg/monitor/agent" | |||
fakeagent "github.com/cilium/cilium/pkg/monitor/agent/fake" |
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'd call this fakemonitoragent
to disambiguate with any other (future) "agents"
eventsmap.Cell, | ||
|
||
// The monitor agent, which multicasts cilium and agent events to its subscribers. | ||
monitorAgent.Cell, |
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.
Maybe monitorAgent
would be better placed in daemon/cmd/cells.go
?
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 thinking was that anything which interacts with bpf Maps directly is datapath; but I agree that this is sort of on the fence. Let's leave it here for now
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'd argue it belongs to pkg/datapath
since it provides a datapath-specific service.
Addressed most comments, as well as made the dependency on the eventsmap optional as suggested by Jussi out of band - this way, no config overrides are necessary. I haven't removed |
CI triage:
|
/ci-e2e |
/test-runtime |
b2ff005
to
dab15a4
Compare
rebased to address conflicts |
/test |
dab15a4
to
a92188d
Compare
Rebased to get #25681 |
/test |
needs rebase :-( |
The cilium events map is used by the monitor.Agent. In preparation of modularization of the agent, move the initialization of the eventsmap into the hive. Signed-off-by: David Bimmler <david.bimmler@isovalent.com>
The monitor agent consumes the eventsmap to multicast its events, as well as other agent events, to subscribers. Pull it's initialization logic into a cell, to reduce the amount of logic needed in the daemon startup sequence. If there's no eventsmap in the hive graph, the agent functions solely for passing along agent events. Dropping RunMonitor flag: Except for testing, there isn't really a use case for not attaching to the eventsmap (The attachment alone doesn't cause performance overhead yet, only once there is a consumer/listener we start reading.) Putting RunMonitor into AgentConfig would mean exposing it as a flag, which is not desirable. Instead, make the eventsmap dependency optional so that non-privileged tests/benchmarks can still use the monitor agent for its userspace capabilities. Proxy Logger changes: To improve on the isolation of components, make NewAgent private. The only consumer other than the cell is the proxy logger benchmark, which can create a hive instead. Unfortunately, this makes the benchmarks require privileges. Dropping Context() from the API: There isn't a good reason to export the context, and it doesn't belong in the monitor's public API. Rework the coordination between the monitor API server and the agent slightly to make the Context() method unnecessary. Signed-off-by: David Bimmler <david.bimmler@isovalent.com>
a92188d
to
f594833
Compare
/test |
/ci-eks |
CI triage:
|
Modularizes both the eventsmap and the monitor agent in the simplest way possible.
Would be happy to get some input on:
pkg/monitor
, though.Ref: #24192