This is an automated email from the ASF dual-hosted git repository. roryqi pushed a commit to branch support-annotations in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
commit fe0bf29ff81e63d7e73f0dca7d8f57519e22f80c Author: Rory <[email protected]> AuthorDate: Fri Jun 21 15:54:58 2024 +0800 Fix ut and add ut --- .../pkg/controller/sync/coordinator/coordinator.go | 2 +- .../sync/coordinator/coordinator_test.go | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go index f1b62b8b4..84b6c84a6 100644 --- a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go +++ b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator.go @@ -237,7 +237,7 @@ func GenerateDeploy(rss *unifflev1alpha1.RemoteShuffleService, index int) *appsv // add custom annotations annotations := map[string]string{} - for key, value := range rss.Spec.ShuffleServer.Annotations { + for key, value := range rss.Spec.Coordinator.Annotations { annotations[key] = value } deploy.Spec.Template.Annotations = annotations diff --git a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go index d1464043f..b9759c86f 100644 --- a/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go +++ b/deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go @@ -133,6 +133,11 @@ var ( Name: "default-secret", }, } + + testAnotations = map[string]string{ + "key1": "value1", + "key2": "value2", + } ) func buildRssWithLabels() *uniffleapi.RemoteShuffleService { @@ -177,6 +182,12 @@ func withCustomImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) return rss } +func withCustomAnnotations(annotations map[string]string) *uniffleapi.RemoteShuffleService { + rss := utils.BuildRSSWithDefaultValue() + rss.Spec.Coordinator.Annotations = annotations + return rss +} + func buildRssWithCustomRPCPort() *uniffleapi.RemoteShuffleService { rss := utils.BuildRSSWithDefaultValue() rss.Spec.Coordinator.RPCPort = pointer.Int32(testRPCPort) @@ -461,6 +472,19 @@ func TestGenerateDeploy(t *testing.T) { return false, fmt.Errorf("generated deploy should include imagePullSecrets: %v", testImagePullSecrets) }, }, + { + name: "set custom annotations", + rss: withCustomAnnotations(testAnotations), + IsValidDeploy: func(deploy *appsv1.Deployment, rss *uniffleapi.RemoteShuffleService) (bool, error) { + if deploy.Spec.Template.Annotations != nil { + equal := reflect.DeepEqual(deploy.Spec.Template.Annotations, testAnotations) + if equal { + return true, nil + } + } + return false, fmt.Errorf("generated deploy should include annotations: %v", testAnotations) + }, + }, } { t.Run(tt.name, func(tc *testing.T) { deploy := GenerateDeploy(tt.rss, 0)
