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
Conversation
|
/test-multicluster-e2e |
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
| Namespace: resImp.Spec.Namespace, | ||
| Name: resImp.Spec.Name, | ||
| Namespace: resImp.Spec.Namespace, | ||
| Annotations: map[string]string{"localClusterID": clusterID}, |
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.
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
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.
done, add a new annotation const AntreaMCClusterIDAnnotation = "multicluster.antrea.io/local-cluster-id" in helper.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.
forget to update?
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.
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)) |
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.
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.
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.
done. there are quite a lot capitalization issue in other logs and files, I will submit a separate PR for it.
f73144b
to
ae0f937
Compare
| 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) |
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.
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")
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.
done
| @@ -378,12 +383,21 @@ func (r *ServiceExportReconciler) handleEndpointDeleteEvent(ctx context.Context, | |||
| return nil | |||
| } | |||
|
|
|||
| func (r *ServiceExportReconciler) updateSvcExportAnnotation(svcExport k8smcsv1alpha1.ServiceExport) error { | |||
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: this should use pointer, otherwise there would be an unnecessary copy.
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.
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) |
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.
ditto
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.
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>
ae0f937
to
08fabf7
Compare
|
/skip-networkpolicy |
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>
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