Skip to content
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

configmap & utime sync: provide via hive cell #24830

Merged

Conversation

mhofstetter
Copy link
Member

@mhofstetter mhofstetter commented Apr 12, 2023

Currently, the interaction with the BPF map configmap and the corresponding utime sync is mainly via global accessors.

This commit refactors this, by introducing hive cells for the configmap and the utime sync.

@mhofstetter mhofstetter added the release-note/misc This PR makes changes that have no direct user impact. label Apr 12, 2023
@mhofstetter mhofstetter marked this pull request as ready for review April 12, 2023 07:23
@mhofstetter mhofstetter requested a review from a team as a code owner April 12, 2023 07:23
)

func initUtimeSync(lifecycle hive.Lifecycle, configMap configmap.Map) {
controllerManager := controller.NewManager()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joamaki would it be worth to have a provider for the controller manager?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of #24558?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting - will take a look.

i think something like this could help in this case - and could be refactored in the future (once its merged)

)

func initUtimeSync(lifecycle hive.Lifecycle, configMap configmap.Map) {
controllerManager := controller.NewManager()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of #24558?

pkg/maps/configmap/cell.go Outdated Show resolved Hide resolved
return fmt.Errorf("failed to init config map: %w", err)
}

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop hook missing that closes it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks - added!

Copy link
Member

@jrajahalme jrajahalme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhofstetter mhofstetter force-pushed the pr/mhofstetter/hive-config-map branch from 2a69f22 to 02a8a33 Compare April 20, 2023 07:27
@mhofstetter
Copy link
Member Author

rebased and resolved conflicts

pkg/maps/mapregistry/cell.go Outdated Show resolved Hide resolved
pkg/maps/configmap/cell.go Outdated Show resolved Hide resolved
pkg/maps/mapregistry/cell.go Outdated Show resolved Hide resolved
}
}

type MapOut struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually try to avoid writing cell.Outs with group values for the fear of typoing the group name. You can get around this with a helper, e.g. func NewMapOut[Map any](m Map) MapOut[Map], but perhaps not worth adding it just yet.

@mhofstetter
Copy link
Member Author

/test

@mhofstetter
Copy link
Member Author

/test-1.27-net-next

)

// Cell contains all cells which are providing BPF Maps.
var Cell = cell.Module(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When should I add something here vs. to the datapath cell as done for the configmap?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nvm utime.Cell is not a map.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly - utime just syncs the utime and uses the configmap to write from user- to kernelspace.

the cell of the configmap itself is part of the maps cell.

Currently, the interaction with the BPF map configmap and the
corresponding utime sync is mainly via global accessors.

This commit refactors this, by providing hive cells for the configmap
and the utime sync.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit lets the datapath depend on all BPF maps which are managed
by a hive cell. BPF Map cells can register their map to the registry via
hive value group `bpf-maps` and the new BpfMap marker interface.

This way, we ensure that BPF maps are initialized via their cell
before the loader.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
Currently, the initialization of the auth map is mainly driven by the
usage in the auth manager.

To always guarantee the initialization before the bpf loader, with this
commit, the auth map gets registered in the map registry.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
To always guarantee the initialization of the config bpf map
before the bpf loader, with this commit, the auth map gets
registered in the map registry.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
@mhofstetter mhofstetter force-pushed the pr/mhofstetter/hive-config-map branch from 4de20d8 to b796c01 Compare April 24, 2023 11:34
@mhofstetter
Copy link
Member Author

rebased to main

@mhofstetter
Copy link
Member Author

mhofstetter commented Apr 24, 2023

/test

Job 'Cilium-PR-K8s-1.25-kernel-5.4' failed:

Click to show.

Test Name

K8sDatapathConfig Host firewall With VXLAN and endpoint routes

Failure Output

FAIL: Failed to reach 10.0.0.229:80 from testclient-host-2jfhj

Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.25-kernel-5.4/107/

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.25-kernel-5.4 so I can create one.

Job 'Cilium-PR-K8s-1.16-kernel-4.19' hit: #25068 (85.93% similarity)

@mhofstetter
Copy link
Member Author

mhofstetter commented Apr 24, 2023

vagrant issues
/test-1.27-net-next

@mhofstetter
Copy link
Member Author

mhofstetter commented Apr 24, 2023

@mhofstetter
Copy link
Member Author

mhofstetter commented Apr 24, 2023

referenced ci-flake issues & code owners covered -> marking as ready-to-merge

@mhofstetter mhofstetter added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 24, 2023
@michi-covalent
Copy link
Contributor

why is this ready to merge? it's not approved by cilium/sig-datapath yet right?

@michi-covalent michi-covalent added the dont-merge/waiting-for-user-feedback Waiting for feedback from user before the PR should be merged. label Apr 25, 2023
@mhofstetter
Copy link
Member Author

why is this ready to merge? it's not approved by cilium/sig-datapath yet right?

@michi-covalent jussi is part of sig-datapath and looks like the perfect reviewer for this :)

@michi-covalent
Copy link
Contributor

@michi-covalent jussi is part of sig-datapath and looks like the perfect reviewer for this :)

oh yeah he is. sorry i got confused because yutaro is still listed as the code owner from sig-dapath.

@michi-covalent michi-covalent removed the dont-merge/waiting-for-user-feedback Waiting for feedback from user before the PR should be merged. label Apr 25, 2023
@michi-covalent michi-covalent merged commit a194628 into cilium:main Apr 25, 2023
54 of 56 checks passed
@mhofstetter mhofstetter deleted the pr/mhofstetter/hive-config-map branch April 25, 2023 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants