antrea icon indicating copy to clipboard operation
antrea copied to clipboard

LabelIdentity replication for MCS

Open Dyanngg opened this issue 3 years ago • 6 comments

This PR is the first part of the mutli-cluster stretched network policy implementation. In order to enforce policy globally based on label selections, Antrea MC Service needs to inform each member cluster of all Pod + Namespace label combinations in the ClusterSet. Each unique Pod + Namespace label combination is defined as labelidentity, which is a normalized string calculated base on Pod's own labels and its Namespace labels. A couple of new controllers and CRDs are added, namely:

  1. A label_identity_controller in each member cluster, which watches Pod and Namespace events, and updates the ResourceExport of type labelidentity for the cluster with all label identities in the cluster.
  2. A label_identity_export_controller in the leader cluster, which watches for ResourceExports of type labelidentity from all member clusters, dedups the label identities and assigns a unique id for each for them. It also creates an LabelIdentityImport CRD object for each such labelidentity and id combination in the leader cluster.
  3. A label_identity_export_controller in each member cluster, which watches for LabelIdentityImport events in the leader, and creates a LabelIdentity CRD object in each member cluster for each LabelIdentityImport.

Signed-off-by: Yang Ding [email protected]

Dyanngg avatar Apr 19 '22 22:04 Dyanngg

Codecov Report

Merging #3664 (604667e) into main (e7486d5) will increase coverage by 0.57%. The diff coverage is 73.02%.

:exclamation: Current head 604667e differs from pull request most recent head 4e0ea62. Consider uploading reports for the commit 4e0ea62 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3664      +/-   ##
==========================================
+ Coverage   62.24%   62.81%   +0.57%     
==========================================
  Files         385      388       +3     
  Lines       54513    55115     +602     
==========================================
+ Hits        33929    34622     +693     
+ Misses      18105    17981     -124     
- Partials     2479     2512      +33     
Flag Coverage Δ
e2e-tests 39.59% <ø> (?)
integration-tests 34.43% <12.00%> (-0.72%) :arrow_down:
kind-e2e-tests 49.16% <ø> (+1.02%) :arrow_up:
unit-tests 44.09% <66.23%> (+0.25%) :arrow_up:
Impacted Files Coverage Δ
multicluster/cmd/multicluster-controller/leader.go 0.00% <0.00%> (ø)
multicluster/cmd/multicluster-controller/member.go 0.00% <0.00%> (ø)
...uster/controllers/multicluster/stale_controller.go 66.66% <59.70%> (-2.44%) :arrow_down:
...s/multicluster/label_identity_export_controller.go 72.92% <72.92%> (ø)
...lers/multicluster/commonarea/remote_common_area.go 72.60% <75.00%> (+0.21%) :arrow_up:
...uster/commonarea/labelidentityimport_controller.go 75.30% <75.30%> (ø)
...trollers/multicluster/label_identity_controller.go 81.72% <81.72%> (ø)
...lticluster/commonarea/resourceimport_controller.go 81.54% <88.88%> (+0.50%) :arrow_up:
...trollers/multicluster/resourceexport_controller.go 78.87% <88.88%> (-1.18%) :arrow_down:
...icluster/controllers/multicluster/common/helper.go 92.72% <100.00%> (+0.72%) :arrow_up:
... and 36 more

codecov-commenter avatar Apr 19 '22 22:04 codecov-commenter

@Dyanngg Could you check the github checks and fix them? some builds are failed. Please update the commit and summery of this PR to provide some info about what does this PR do. thanks.

luolanzone avatar Jun 13 '22 04:06 luolanzone

This pull request introduces 1 alert when merging 82c1d29e798fe8b636b8ac96fb01354ef3051692 into 5b9cde5b77b99be3b660f5ddc6ab2f06679c23da - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

lgtm-com[bot] avatar Jun 16 '22 21:06 lgtm-com[bot]

@Dyanngg @GraysonWu Will you add unit tests on this PR?

luolanzone avatar Jun 28 '22 13:06 luolanzone

@Dyanngg @GraysonWu Will you add unit tests on this PR?

Working on it.

GraysonWu avatar Jun 28 '22 18:06 GraysonWu

Hi @GraysonWu Could you help to fix the github check issue? thanks.

luolanzone avatar Jul 04 '22 03:07 luolanzone

Have not read the code yet. A typo in commit description:

which is a normalized string calculated base on Pod's own labels and its Namespace labels.

based -> base

And good to change "id" to "ID".

jianjuns avatar Aug 25 '22 22:08 jianjuns

/test-multicluster-e2e

Dyanngg avatar Sep 20 '22 18:09 Dyanngg

/test-all

Dyanngg avatar Sep 21 '22 17:09 Dyanngg

/test-all

Dyanngg avatar Sep 27 '22 23:09 Dyanngg

/test-all

Dyanngg avatar Sep 29 '22 19:09 Dyanngg

/test-all

jianjuns avatar Oct 03 '22 18:10 jianjuns

/test-multicluster-e2e

Dyanngg avatar Oct 03 '22 21:10 Dyanngg

All tests passed in Jenkins, but the status are not updated to this PR.

jianjuns avatar Oct 03 '22 23:10 jianjuns