Skip to content

Commit 2982f64

Browse files
Update cluster.go
merge two if judges
1 parent 762aba8 commit 2982f64

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

controller/cluster.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -339,28 +339,12 @@ func (c *ClusterChecker) tryUpdateMigrationStatus(ctx context.Context, clonedClu
339339
continue
340340
}
341341

342-
// If there is no migration information on the master node, you need to clear the migration information on the controller.
343-
if sourceNodeClusterInfo.MigratingSlot == nil {
344-
log.Error("Mismatch migrating slot, no migrating info on node",
345-
zap.Int("shard_index", i),
346-
zap.String("source_node", sourceNode.Addr()),
347-
zap.String("migrating_slot", shard.MigratingSlot.String()),
348-
)
349-
clonedCluster.Shards[i].ClearMigrateState()
350-
if err = c.clusterStore.UpdateCluster(ctx, c.namespace, clonedCluster); err != nil {
351-
log.Error("Failed to update the migrate state by UpdateCluster method", zap.Error(err))
352-
return
353-
}
354-
c.updateCluster(clonedCluster)
355-
continue
356-
}
357-
// If the migration information on the master node is inconsistent with the controller, you need to clear the migration information on the controller.
358-
if sourceNodeClusterInfo.MigratingSlot != nil &&
359-
!sourceNodeClusterInfo.MigratingSlot.Equal(shard.MigratingSlot.SlotRange) {
342+
// If there is no migration information on the source node or source node migratingslot is not eauqls shard, you need to clear the migration information on the controller.
343+
if sourceNodeClusterInfo.MigratingSlot == nil || (sourceNodeClusterInfo.MigratingSlot != nil &&
344+
!sourceNodeClusterInfo.MigratingSlot.Equal(shard.MigratingSlot.SlotRange)) {
360345
log.Error("Mismatch migrating slot",
361346
zap.Int("shard_index", i),
362-
zap.String("source node cluster info migrating_slot", sourceNodeClusterInfo.MigratingSlot.String()),
363-
zap.String("controller migrating_slot", shard.MigratingSlot.String()),
347+
zap.String("migrating_slot", shard.MigratingSlot.String()),
364348
)
365349
clonedCluster.Shards[i].ClearMigrateState()
366350
if err = c.clusterStore.UpdateCluster(ctx, c.namespace, clonedCluster); err != nil {

0 commit comments

Comments
 (0)