Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pd-ctl: print warn information when set max-replica to less than 3 #8983

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tools/pd-ctl/pdctl/command/config_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/spf13/cobra"

sc "github.com/tikv/pd/pkg/schedule/config"
"github.com/tikv/pd/pkg/schedule/placement"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/reflectutil"
Expand Down Expand Up @@ -374,6 +375,12 @@ func postConfigDataWithPath(cmd *cobra.Command, key, value, path string) error {
val = value
}
data[key] = val
if key == "max-replicas" {
replica, err := strconv.ParseInt(value, 10, 64)
if err == nil && replica < sc.DefaultMaxReplicas {
cmd.Println("Setting max-replica to less than 3 may be a mistake and carries high risk. Please confirm the setting.")
Copy link
Member

@rleungx rleungx Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original issue wants an interactive way to confirm the operation instead of just printing a message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the discussion with @niubell , we will not add an interactive way in pd-ctl for now.

}
}
reqData, err := json.Marshal(data)
if err != nil {
return err
Expand Down
Loading