@@ -1797,7 +1797,14 @@ static void usage(void) {
17971797 exit (1 );
17981798}
17991799
1800- static int confirmWithYes (char * msg ) {
1800+ static int confirmWithYes (char * msg , int force ) {
1801+ /* if force is true and --cluster-yes option is on,
1802+ * do not prompt for an answer */
1803+ if (force &&
1804+ (config .cluster_manager_command .flags & CLUSTER_MANAGER_CMD_FLAG_YES )) {
1805+ return 1 ;
1806+ }
1807+
18011808 printf ("%s (type 'yes' to accept): " , msg );
18021809 fflush (stdout );
18031810 char buf [4 ];
@@ -4485,12 +4492,16 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
44854492 }
44864493 dictReleaseIterator (iter );
44874494
4495+ /* we want explicit manual confirmation from users for all the fix cases */
4496+ int force = 0 ;
4497+
44884498 /* Handle case "1": keys in no node. */
44894499 if (listLength (none ) > 0 ) {
44904500 printf ("The following uncovered slots have no keys "
44914501 "across the cluster:\n" );
44924502 clusterManagerPrintSlotsList (none );
4493- if (confirmWithYes ("Fix these slots by covering with a random node?" )){
4503+ if (confirmWithYes ("Fix these slots by covering with a random node?" ,
4504+ force )) {
44944505 listIter li ;
44954506 listNode * ln ;
44964507 listRewind (none , & li );
@@ -4516,7 +4527,8 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
45164527 if (listLength (single ) > 0 ) {
45174528 printf ("The following uncovered slots have keys in just one node:\n" );
45184529 clusterManagerPrintSlotsList (single );
4519- if (confirmWithYes ("Fix these slots by covering with those nodes?" )){
4530+ if (confirmWithYes ("Fix these slots by covering with those nodes?" ,
4531+ force )) {
45204532 listIter li ;
45214533 listNode * ln ;
45224534 listRewind (single , & li );
@@ -4548,7 +4560,7 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) {
45484560 printf ("The following uncovered slots have keys in multiple nodes:\n" );
45494561 clusterManagerPrintSlotsList (multi );
45504562 if (confirmWithYes ("Fix these slots by moving keys "
4551- "into a single node?" )) {
4563+ "into a single node?" , force )) {
45524564 listIter li ;
45534565 listNode * ln ;
45544566 listRewind (multi , & li );
@@ -5511,7 +5523,8 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
55115523 }
55125524 clusterManagerOptimizeAntiAffinity (ip_nodes , ip_count );
55135525 clusterManagerShowNodes ();
5514- if (confirmWithYes ("Can I set the above configuration?" )) {
5526+ int force = 1 ;
5527+ if (confirmWithYes ("Can I set the above configuration?" , force )) {
55155528 listRewind (cluster_manager .nodes , & li );
55165529 while ((ln = listNext (& li )) != NULL ) {
55175530 clusterManagerNode * node = ln -> value ;
0 commit comments