Skip to content

Commit 80feddc

Browse files
committed
refactoring: remove hardcoded headless service name
1 parent 723394d commit 80feddc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/controller/cluster/cluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (r *ReconcileCluster) Reconcile(request reconcile.Request) (reconcile.Resul
244244
return reconcile.Result{RequeueAfter: time.Duration(5 * time.Second)}, err
245245
}
246246

247-
topologyClient := topology.NewBuiltInTopologyService(topology.WithTopologyEndpoint(fmt.Sprintf("http://%s/admin/api", leader)))
247+
topologyClient := topology.NewBuiltInTopologyService(topology.WithTopologyEndpoint(fmt.Sprintf("http://%s/admin/api", leader)), topology.WithClusterID(cluster.GetName()))
248248
for _, sts := range stsList.Items {
249249
for i := 0; i < int(*sts.Spec.Replicas); i++ {
250250
pod := &corev1.Pod{}

pkg/topology/builtin.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type BootstrapVshardResponse struct {
4242

4343
type BuiltInTopologyService struct {
4444
serviceHost string
45+
clusterID string
4546
}
4647

4748
type EditReplicasetResponse struct {
@@ -62,7 +63,7 @@ var edit_rs_mutation = `mutation editReplicaset($uuid: String!, $weight: Float)
6263
}`
6364

6465
func (s *BuiltInTopologyService) Join(pod *corev1.Pod) error {
65-
advURI := fmt.Sprintf("%s.examples-kv-cluster:3301", pod.GetObjectMeta().GetName())
66+
advURI := fmt.Sprintf("%s.%s:3301", pod.GetObjectMeta().GetName(), s.clusterID)
6667
replicasetUUID, ok := pod.GetLabels()["tarantool.io/replicaset-uuid"]
6768
if !ok {
6869
return errors.New("replicaset uuid empty")
@@ -192,6 +193,12 @@ func WithTopologyEndpoint(url string) Option {
192193
}
193194
}
194195

196+
func WithClusterID(id string) Option {
197+
return func(s *BuiltInTopologyService) {
198+
s.clusterID = id
199+
}
200+
}
201+
195202
func NewBuiltInTopologyService(opts ...Option) *BuiltInTopologyService {
196203
s := &BuiltInTopologyService{}
197204
for _, opt := range opts {

0 commit comments

Comments
 (0)