Skip to content

Commit 5ae2269

Browse files
authored
Fix: non-leader instances must be joined through an joined leader (#195)
* fix: non-leader instances must be joined through an joined leader * fix: return correct join instance error
1 parent f0649c6 commit 5ae2269

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

pkg/reconciliation/steps/role/join_instances.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,25 @@ func (r *JoinInstancesStep[PhaseType, RoleType, CtxType, CtrlType]) Reconcile(ct
7272
if uuidErr != nil {
7373
ctx.GetLogger().Error(uuidErr, "unable to get instance uuid")
7474

75-
return Error(err)
75+
return Error(uuidErr)
7676
}
7777

7878
if instanceUUID == "" {
79+
leader := ctx.GetLeader()
80+
81+
if leader.Name != pod.Name {
82+
switch leaderUUID, uuidErr := topologyClient.GetInstanceUUID(ctx, leader); {
83+
case uuidErr != nil:
84+
ctx.GetLogger().Error(uuidErr, "unable to get leader instance uuid")
85+
86+
return Error(uuidErr)
87+
case leaderUUID == "":
88+
allJoined = false
89+
90+
continue
91+
}
92+
}
93+
7994
vshard := role.GetVShardConfig()
8095

8196
alias, err := role.GetReplicasetName(stsOrdinal)
@@ -85,7 +100,7 @@ func (r *JoinInstancesStep[PhaseType, RoleType, CtxType, CtrlType]) Reconcile(ct
85100

86101
joinErr := topologyClient.Join(
87102
ctx,
88-
ctx.GetLeader(),
103+
leader,
89104
alias,
90105
ctrl.GetReplicasetsManger().GetReplicasetUUID(role, stsOrdinal),
91106
vshard.GetRoles(),
@@ -105,7 +120,7 @@ func (r *JoinInstancesStep[PhaseType, RoleType, CtxType, CtrlType]) Reconcile(ct
105120
return Complete()
106121
}
107122

108-
return Error(err)
123+
return Error(joinErr)
109124
}
110125
}
111126
}

0 commit comments

Comments
 (0)