Sentinel: add missing calls for sentinelflushconfig when config master at runtime (#8229)

(cherry picked from commit 84a2084d0734052ed05df5b8d67f26d62c02ec67)
This commit is contained in:
Wen Hui 2020-12-22 09:14:15 -05:00 committed by Oran Agra
parent a93d343902
commit 2355a7056f

View File

@ -3509,14 +3509,13 @@ void sentinelSetCommand(client *c) {
"Reconfiguration of scripts path is denied for " "Reconfiguration of scripts path is denied for "
"security reasons. Check the deny-scripts-reconfig " "security reasons. Check the deny-scripts-reconfig "
"configuration directive in your Sentinel configuration"); "configuration directive in your Sentinel configuration");
return; goto seterr;
} }
if (strlen(value) && access(value,X_OK) == -1) { if (strlen(value) && access(value,X_OK) == -1) {
addReplyError(c, addReplyError(c,
"Notification script seems non existing or non executable"); "Notification script seems non existing or non executable");
if (changes) sentinelFlushConfig(); goto seterr;
return;
} }
sdsfree(ri->notification_script); sdsfree(ri->notification_script);
ri->notification_script = strlen(value) ? sdsnew(value) : NULL; ri->notification_script = strlen(value) ? sdsnew(value) : NULL;
@ -3529,15 +3528,14 @@ void sentinelSetCommand(client *c) {
"Reconfiguration of scripts path is denied for " "Reconfiguration of scripts path is denied for "
"security reasons. Check the deny-scripts-reconfig " "security reasons. Check the deny-scripts-reconfig "
"configuration directive in your Sentinel configuration"); "configuration directive in your Sentinel configuration");
return; goto seterr;
} }
if (strlen(value) && access(value,X_OK) == -1) { if (strlen(value) && access(value,X_OK) == -1) {
addReplyError(c, addReplyError(c,
"Client reconfiguration script seems non existing or " "Client reconfiguration script seems non existing or "
"non executable"); "non executable");
if (changes) sentinelFlushConfig(); goto seterr;
return;
} }
sdsfree(ri->client_reconfig_script); sdsfree(ri->client_reconfig_script);
ri->client_reconfig_script = strlen(value) ? sdsnew(value) : NULL; ri->client_reconfig_script = strlen(value) ? sdsnew(value) : NULL;
@ -3587,8 +3585,7 @@ void sentinelSetCommand(client *c) {
} else { } else {
addReplyErrorFormat(c,"Unknown option or number of arguments for " addReplyErrorFormat(c,"Unknown option or number of arguments for "
"SENTINEL SET '%s'", option); "SENTINEL SET '%s'", option);
if (changes) sentinelFlushConfig(); goto seterr;
return;
} }
/* Log the event. */ /* Log the event. */
@ -3614,9 +3611,11 @@ void sentinelSetCommand(client *c) {
return; return;
badfmt: /* Bad format errors */ badfmt: /* Bad format errors */
if (changes) sentinelFlushConfig();
addReplyErrorFormat(c,"Invalid argument '%s' for SENTINEL SET '%s'", addReplyErrorFormat(c,"Invalid argument '%s' for SENTINEL SET '%s'",
(char*)c->argv[badarg]->ptr,option); (char*)c->argv[badarg]->ptr,option);
seterr:
if (changes) sentinelFlushConfig();
return;
} }
/* Our fake PUBLISH command: it is actually useful only to receive hello messages /* Our fake PUBLISH command: it is actually useful only to receive hello messages