diff --git a/components/cluster/command/prune.go b/components/cluster/command/prune.go index 44f2aeb463..dfb430e22e 100644 --- a/components/cluster/command/prune.go +++ b/components/cluster/command/prune.go @@ -43,6 +43,7 @@ func newPruneCmd() *cobra.Command { } cmd.Flags().BoolVar(&gOpt.Force, "force", false, "Ignore errors when deleting the instance with data from the cluster") + cmd.Flags().StringSliceVar(&gOpt.IngoreInitConfigRoles, "ignore-config-roles", nil, "ignore generate config in specified components(tidb,pd,tikv)") return cmd } diff --git a/components/cluster/command/scale_in.go b/components/cluster/command/scale_in.go index 59ebe53479..098835b175 100644 --- a/components/cluster/command/scale_in.go +++ b/components/cluster/command/scale_in.go @@ -63,6 +63,7 @@ func newScaleInCmd() *cobra.Command { cmd.Flags().StringSliceVarP(&gOpt.Nodes, "node", "N", nil, "Specify the nodes (required)") cmd.Flags().Uint64Var(&gOpt.APITimeout, "transfer-timeout", 600, "Timeout in seconds when transferring PD and TiKV store leaders, also for TiCDC drain one capture") cmd.Flags().BoolVar(&gOpt.Force, "force", false, "Force just try stop and destroy instance before removing the instance from topo") + cmd.Flags().StringSliceVar(&gOpt.IngoreInitConfigRoles, "ignore-config-roles", nil, "ignore generate config in specified components(tidb,pd,tikv)") _ = cmd.MarkFlagRequired("node") diff --git a/components/cluster/command/scale_out.go b/components/cluster/command/scale_out.go index 448ef0c145..26d5eafbb8 100644 --- a/components/cluster/command/scale_out.go +++ b/components/cluster/command/scale_out.go @@ -94,6 +94,7 @@ func newScaleOutCmd() *cobra.Command { cmd.Flags().BoolVarP(&opt.NoLabels, "no-labels", "", false, "Don't check TiKV labels") cmd.Flags().BoolVarP(&opt.Stage1, "stage1", "", false, "Don't start the new instance after scale-out, need to manually execute cluster scale-out --stage2") cmd.Flags().BoolVarP(&opt.Stage2, "stage2", "", false, "Start the new instance and init config after scale-out --stage1") + cmd.Flags().StringSliceVar(&gOpt.IngoreInitConfigRoles, "ignore-config-roles", nil, "ignore generate config in specified components(tidb,pd,tikv)") return cmd } diff --git a/pkg/cluster/manager/builder.go b/pkg/cluster/manager/builder.go index 3344adcb82..ee1ab4bfbc 100644 --- a/pkg/cluster/manager/builder.go +++ b/pkg/cluster/manager/builder.go @@ -629,6 +629,13 @@ func buildInitConfigTasks( return } compName := instance.ComponentName() + + for _, IgnoreComp := range gOpt.IngoreInitConfigRoles { + if IgnoreComp == compName { + return + } + } + deployDir := spec.Abs(base.User, instance.DeployDir()) // data dir would be empty for components which don't need it dataDirs := spec.MultiDirAbs(base.User, instance.DataDir()) diff --git a/pkg/cluster/operation/operation.go b/pkg/cluster/operation/operation.go index 6c97324b85..60a61431c5 100644 --- a/pkg/cluster/operation/operation.go +++ b/pkg/cluster/operation/operation.go @@ -57,6 +57,8 @@ type Options struct { DisplayMode string // the output format Operation Operation + + IngoreInitConfigRoles []string // ignore config generate in the specific roles } // Operation represents the type of cluster operation