@@ -417,6 +417,28 @@ func getPrimaryLabels(Name string, ClusterName string, replicaFlag bool, userLab
417417 return primaryLabels
418418}
419419
420+ // GetReplicaAffinity ...
421+ // use NotIn as an operator when a node-label is not specified on the
422+ // replica, use the node labels from the primary in this case
423+ // use In as an operator when a node-label is specified on the replica
424+ // use the node labels from the replica in this case
425+ func GetReplicaAffinity (clusterLabels , replicaLabels map [string ]string ) string {
426+ var operator , key , value string
427+ log .Debug ("GetReplicaAffinity " )
428+ if replicaLabels ["NodeLabelKey" ] != "" {
429+ //use the replica labels
430+ operator = "In"
431+ key = replicaLabels ["NodeLabelKey" ]
432+ value = replicaLabels ["NodeLabelValue" ]
433+ } else {
434+ //use the cluster labels
435+ operator = "NotIn"
436+ key = clusterLabels ["NodeLabelKey" ]
437+ value = clusterLabels ["NodeLabelValue" ]
438+ }
439+ return GetAffinity (key , value , operator )
440+ }
441+
420442// GetAffinity ...
421443func GetAffinity (nodeLabelKey , nodeLabelValue string , operator string ) string {
422444 log .Debugf ("GetAffinity with nodeLabelKey=[%s] nodeLabelKey=[%s] and operator=[%s]\n " , nodeLabelKey , nodeLabelValue , operator )
@@ -556,7 +578,7 @@ func (r Strategy1) Scale(clientset *kubernetes.Clientset, client *rest.RESTClien
556578 RootSecretName : cluster .Spec .RootSecretName ,
557579 PrimarySecretName : cluster .Spec .PrimarySecretName ,
558580 UserSecretName : cluster .Spec .UserSecretName ,
559- NodeSelector : GetAffinity (cluster .Spec .UserLabels [ "NodeLabelKey" ], cluster .Spec .UserLabels [ "NodeLabelValue" ], "NotIn" ),
581+ NodeSelector : GetReplicaAffinity (cluster .Spec .UserLabels , replica .Spec .UserLabels ),
560582 }
561583
562584 switch replica .Spec .ReplicaStorage .StorageType {
0 commit comments