当前,scaling nemesis 会随意的 scale 集群的任意节点。
|
func (s scaling) Invoke(ctx context.Context, node *cluster.Node, args ...interface{}) error { |
|
log.Printf("apply nemesis scaling on ns %s", node.Namespace) |
|
return s.scaleCluster(ctx, node.Namespace, node.Namespace, 2) |
|
} |
|
|
|
func (s scaling) Recover(ctx context.Context, node *cluster.Node, args ...interface{}) error { |
|
log.Printf("unapply nemesis scaling on ns %s", node.Namespace) |
|
return s.scaleCluster(ctx, node.Namespace, node.Namespace, -2) |
|
} |
|
|
|
func (s scaling) scaleCluster(ctx context.Context, ns, name string, n int32) error { |
|
var tc v1alpha1.TidbCluster |
|
err := wait.PollImmediate(5*time.Second, time.Minute*time.Duration(5), func() (bool, error) { |
|
key := types.NamespacedName{ |
|
Namespace: ns, |
|
Name: name, |
|
} |
|
if err := s.cli.cli.Get(context.TODO(), key, &tc); err != nil { |
|
return false, err |
|
} |
|
return true, nil |
|
}) |
|
if err != nil { |
|
return err |
|
} |
|
_, err = controllerutil.CreateOrUpdate(context.TODO(), s.cli.cli, &tc, func() error { |
|
tc.Spec.TiDB.Replicas += n |
|
tc.Spec.PD.Replicas += n |
|
tc.Spec.TiKV.Replicas += n |
|
log.Printf("Scale TiDB's nodes to %d PD's nodes to %d TiKV's nodes to %d", tc.Spec.TiDB.Replicas, tc.Spec.PD.Replicas, tc.Spec.TiKV.Replicas) |
|
return nil |
|
}) |
|
return err |
|
} |
但在 resolve-lock 这个测试用例中,我们想只 scale tikv,并且保证 tikv 的 replicas 总是不少于 n(3) 个。
希望 tipocket 能提供另外一种 nemesis 以符合上述需求。
当前,scaling nemesis 会随意的 scale 集群的任意节点。
tipocket/pkg/nemesis/scaling.go
Lines 61 to 94 in fbafe82
但在 resolve-lock 这个测试用例中,我们想只 scale tikv,并且保证 tikv 的 replicas 总是不少于 n(3) 个。
希望 tipocket 能提供另外一种 nemesis 以符合上述需求。