Skip to content

Commit 804edc4

Browse files
authored
fix: restore shard cluster failed if the origin cluster's shards less than cluster's shards (#10021)
1 parent d5f8fb8 commit 804edc4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/apps/cluster/transformer_cluster_restore.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
package cluster
2121

2222
import (
23+
"fmt"
2324
"sort"
25+
"time"
2426

2527
"k8s.io/apimachinery/pkg/util/json"
2628
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -74,7 +76,10 @@ func (c *clusterRestoreTransformer) Transform(ctx graph.TransformContext, dag *g
7476
if err != nil {
7577
return err
7678
}
77-
79+
if int(spec.Shards) > len(backup.Status.Targets) && len(shardComponents) < int(spec.Shards) {
80+
return intctrlutil.NewRequeueError(time.Second,
81+
fmt.Sprintf(`the shard components of sharding "%s" are not ready, wait for next loop to allocate source targets`, spec.Name))
82+
}
7883
targets := backup.Status.Targets
7984
// obtain components that have already been assigned targets.
8085
allocateTargetMap := map[string]string{}

0 commit comments

Comments
 (0)