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

Add clusterID annotation to ServiceExport/Import #3359

Merged
merged 1 commit into from Feb 28, 2022

Conversation

luolanzone
Copy link
Contributor

Add local cluster ID as an annotation to ServiceExport/Import
which help to simplify the logic to group ServiceExport/Import in
Antctl.

Signed-off-by: Lan Luo luola@vmware.com

@luolanzone
Copy link
Contributor Author

/test-multicluster-e2e

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2022

Codecov Report

Merging #3359 (08fabf7) into main (26c039c) will increase coverage by 0.01%.
The diff coverage is 68.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3359      +/-   ##
==========================================
+ Coverage   60.85%   60.86%   +0.01%     
==========================================
  Files         268      268              
  Lines       26723    26753      +30     
==========================================
+ Hits        16263    16284      +21     
- Misses       8649     8655       +6     
- Partials     1811     1814       +3     
Flag Coverage Δ
kind-e2e-tests 47.64% <ø> (-0.01%) ⬇️
unit-tests 42.14% <68.18%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...lers/multicluster/commonarea/remote_common_area.go 23.56% <0.00%> (-0.14%) ⬇️
...ntrollers/multicluster/serviceexport_controller.go 67.47% <63.63%> (-0.14%) ⬇️
...lticluster/commonarea/resourceimport_controller.go 68.48% <80.00%> (+0.08%) ⬆️
pkg/agent/nodeportlocal/k8s/annotations.go 83.87% <0.00%> (-9.68%) ⬇️
pkg/apiserver/storage/ram/watch.go 90.38% <0.00%> (-3.85%) ⬇️
pkg/agent/nodeportlocal/k8s/npl_controller.go 59.04% <0.00%> (-1.71%) ⬇️
pkg/apiserver/storage/ram/store.go 78.35% <0.00%> (-1.50%) ⬇️
...g/agent/controller/serviceexternalip/controller.go 79.24% <0.00%> (-0.95%) ⬇️
...trollers/multicluster/resourceexport_controller.go 69.92% <0.00%> (-0.12%) ⬇️
pkg/agent/apiserver/handlers/ovsflows/handler.go 75.00% <0.00%> (ø)
... and 6 more

@luolanzone luolanzone added the area/multi-cluster Issues or PRs related to multi cluster. label Feb 25, 2022
jianjuns
jianjuns previously approved these changes Feb 25, 2022
Dyanngg
Dyanngg previously approved these changes Feb 25, 2022
Copy link
Contributor

@Dyanngg Dyanngg left a comment

Choose a reason for hiding this comment

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

LGTM

Namespace: resImp.Spec.Namespace,
Name: resImp.Spec.Name,
Namespace: resImp.Spec.Namespace,
Annotations: map[string]string{"localClusterID": clusterID},
Copy link
Member

Choose a reason for hiding this comment

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

Can we use format similar to Antrea and K8s's well know annotations? There should be a prefix defining its scope, and words should be connected with "-". For instances:
node.antrea.io/mac-address
service.antrea.io/external-ip-pool
service.kubernetes.io/topology-aware-hints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, add a new annotation const AntreaMCClusterIDAnnotation = "multicluster.antrea.io/local-cluster-id" in helper.go

Copy link
Member

Choose a reason for hiding this comment

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

forget to update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, fix it and unit test. thanks.


if err = r.updateSvcExportAnnotation(svcExport); err != nil {
// Ignore the error since it's not critical and we can update in next event.
klog.V(2).ErrorS(err, "failed to update ServiceExport annotation", "serviceexport", klog.KObj(&svcExport))
Copy link
Member

Choose a reason for hiding this comment

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

But with V(2), the error will never be caught if there is something wrong leading to the failure permanently.
And first word in log message should be capitalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. there are quite a lot capitalization issue in other logs and files, I will submit a separate PR for it.

@luolanzone luolanzone dismissed stale reviews from Dyanngg and jianjuns via f73144b February 28, 2022 03:57
@luolanzone luolanzone force-pushed the add-clusterid branch 2 times, most recently from f73144b to ae0f937 Compare February 28, 2022 08:12
func checkAnnotation(t *testing.T, svcImport *k8smcsapi.ServiceImport) {
id, ok := svcImport.Annotations[common.AntreaMCClusterIDAnnotation]
if id != localClusterID || !ok {
t.Errorf("latest ServiceImport annotation should be "+localClusterID+" but got %v", id)
Copy link
Member

Choose a reason for hiding this comment

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

why don't use the expected cluster IP but an uncommon place holder?

t.Errorf("latest ServiceImport annotation should be %v but got %v", localClusterID, id)

Or

assert.Equal(t, localClusterID, id, "Unexpected ServiceImport clusterID annotation")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -378,12 +383,21 @@ func (r *ServiceExportReconciler) handleEndpointDeleteEvent(ctx context.Context,
return nil
}

func (r *ServiceExportReconciler) updateSvcExportAnnotation(svcExport k8smcsv1alpha1.ServiceExport) error {
Copy link
Member

Choose a reason for hiding this comment

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

nit: this should use pointer, otherwise there would be an unnecessary copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

func checkAnnotation(t *testing.T, svcExport *k8smcsv1alpha1.ServiceExport) {
id, ok := svcExport.Annotations[common.AntreaMCClusterIDAnnotation]
if id != localClusterID || !ok {
t.Errorf("latest ServiceExport annotation should be "+localClusterID+" but got %v", id)
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Add local cluster ID as an annotation to ServiceExport/Import
which help to simplify the logic to group ServiceExport/Import in
Antctl.

Signed-off-by: Lan Luo <luola@vmware.com>
@tnqn
Copy link
Member

tnqn commented Feb 28, 2022

/skip-networkpolicy
/skip-e2e
/skip-conformance
/test-multicluster-e2e

@tnqn tnqn merged commit 2060eb2 into antrea-io:main Feb 28, 2022
bangqipropel pushed a commit to bangqipropel/antrea that referenced this pull request Mar 2, 2022
Add local cluster ID as an annotation to ServiceExport/Import
which help to simplify the logic to group ServiceExport/Import in
Antctl.

Signed-off-by: Lan Luo <luola@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/multi-cluster Issues or PRs related to multi cluster.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants