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
pkg/maps/egressmap: refactor into a cell #24865
Conversation
/test-runtime |
/test-runtime |
/test-runtime |
/test |
@@ -213,7 +213,7 @@ struct { | |||
__type(key, struct egress_gw_policy_key); | |||
__type(value, struct egress_gw_policy_entry); | |||
__uint(pinning, LIBBPF_PIN_BY_NAME); | |||
__uint(max_entries, EGRESS_POLICY_MAP_SIZE); | |||
__uint(max_entries, 16384); |
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 is to keep the BPF unit tests happy.
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.
So, value must be hardcoded and constant is not allowed?
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 removed the define for EGRESS_POLICY_MAP_SIZE
so that I can get rid of the entry in node_config.h
which is written out at runtime. It's difficult to plumb the size requested via config / command line into node_config.h
without relying on option.Config
global which I wanted to avoid.
So: we could keep the define
but move it to maps.h
. That runs the risk of some C code relying on that define with the assumption that it reflects the configured value. So I opted to remove the define 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.
Thanks!
The current state of the PR is not good to merge, since it doesn't enforce a dependency between the loader component and the map. |
c3ab40e
to
180db68
Compare
/test-runtime |
return err | ||
} | ||
func createPolicyMapFromDaemonConfig(daemonConfig *option.DaemonConfig, lc hive.Lifecycle, cfg PolicyConfig) bpf.MapOut[PolicyMap] { | ||
if !daemonConfig.EnableIPv4EgressGateway { |
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 we can get away without this? Ties into the whole "optional hive feature".
c74889d
to
7174e0e
Compare
/test Job 'Cilium-PR-K8s-1.26-kernel-net-next' failed: Click to show.Test Name
Failure Output
Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.26-kernel-net-next/1953/ If it is a flake and a GitHub issue doesn't already exist to track it, comment Then please upload the Jenkins artifacts to that issue. |
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.
Looks good, thanks! Just one nit and a question
@@ -101,6 +101,7 @@ type datapathParams struct { | |||
LC hive.Lifecycle | |||
WgAgent *wg.Agent | |||
|
|||
// Force map initialisation before loader | |||
// Force map initialisation before loader. You should not use these otherwise. |
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.
nit: extra dot at the end
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.
Hmm I don't understand, sorry.
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 - thanks for introducing the generic MapOut
type
/test |
Travis error is probably a stuck test #23509 |
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.
hivetest package looks good to me
runtime test is #25178 |
Please make the tests green and get all codeowner groups' review. |
hive requires splitting up object lifecycle into New, Start, Stop. It does this by injecting a hive.Lifecycle into constructors. This in turn means that we need a lifecycle to create objects during testing. Implement a minimal hive.Lifecycle for use in testing, which doesn't distinguish between New and Start phases and instead immediately executes any start hooks. Stop hooks are invoked at test cleanup time. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Rework the egressmap from a global variable into a Cell. The map still has singleton behaviour due to map pinning, but at least for unit tests we can opt out of pinning and isolate the map from global changes. Stop writing out EGRESS_POLICY_MAP_SIZE into node_config.h since the map definition in C is never actually used. The map size is configured via a command line parameter instead. Hardcode the previously used default value to avoid errors when running BPF unit tests. This is simpler than wiring the new PolicyConfig into HeaderfileWriter. Reuse the MapOut strategy from configmap and authmap to ensure that the egressmap is initialized by the agent before the loader is invoked. Otherwise map creation might use the (incorrect) MaxElems from the compiled C code. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@viktor-kurchenko could you take another look and approve? |
/test |
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 was a nice lil intro to hive for me 😎 nice work
I added |
pkg/maps/egressmap: refactor policy map into a cell
hivetest: add Lifecycle to make testing easier
Updates: #23782