Skip to content

Sentinel: return an error if configuration save fails#10151

Merged
yossigo merged 4 commits into
redis:unstablefrom
hwware:sentinel-save-config-test
Feb 3, 2022
Merged

Sentinel: return an error if configuration save fails#10151
yossigo merged 4 commits into
redis:unstablefrom
hwware:sentinel-save-config-test

Conversation

@hwware

@hwware hwware commented Jan 19, 2022

Copy link
Copy Markdown
Contributor

When performing SENTINEL SET, Sentinel updates the local configuration file. Before this commit, failure to update the file would still result with an +OK reply. Now, a -ERR Failed to save config file error will be returned.

Comment thread tests/sentinel/tests/03-runtime-reconf.tcl Outdated

@moticless moticless left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. Thank you.

@oranagra

Copy link
Copy Markdown
Member

@hwware @moticless please put some description in the top comment.

@hwware

hwware commented Jan 27, 2022

Copy link
Copy Markdown
Contributor Author

@hwware @moticless please put some description in the top comment.

@oranagra The description for this PR is added in the top, please take a look, Thanks

If SENTINEL SET fails input validation *and* fails to flush other
changes, we need to choose as we can't produce two errors. For now, keep
reporting the user error - but ultimately this should probably be
atomic.

Other minor changes:
* Shorten error message
* Use a helper function to avoid repeating the check/error reply.
@yossigo

yossigo commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

@moticless @hwware Added a commit to fix an issue + a small cleanup, PTAL. Thanks!

Comment thread src/sentinel.c Outdated
@yossigo yossigo changed the title Add Failed to save configuration to file test case for sentinel Sentinel: return an error if configuration save fails Feb 3, 2022
@yossigo yossigo added the release-notes indication that this issue needs to be mentioned in the release notes label Feb 3, 2022
@yossigo yossigo merged commit 65ef543 into redis:unstable Feb 3, 2022
@enjoy-binbin

enjoy-binbin commented Feb 4, 2022

Copy link
Copy Markdown
Contributor

The test failed, chmod 000 the sentinel config look like, it will still rewrite successfully in CentOS (we use tmp file + rename)
Not sure how it will be in Ubantu, i see the tests pass in Ubantu. (i don't have a Ubantu to see the serverLog..)

https://github.com/redis/redis/runs/5060122241?check_suite_focus=true#step:9:70
https://github.com/enjoy-binbin/redis/actions/runs/1793244881 
00:28:57> Sentinel Set with other error situations: FAILED: Expected 'ERR Failed to save config file' to be equal to 'invalid 
command name "OK"' (context: type source line 58 file /__w/redis/redis/tests/sentinel/tests/03-runtime-reconf.tcl cmd 
{assert_equal "ERR Failed to save config file" $err} proc ::test)

I think a way to pass in Centos, is rm config_file, mkdir config_file, make it become a dir, then it will fail in rename

[root@binblog redis]# chmod 000 sentinel.conf
[root@binblog redis]# src/redis-cli -p 26379
127.0.0.1:26379> SENTINEL SET mymaster quorum 3
OK
127.0.0.1:26379>
[root@binblog redis]# rm sentinel.conf -rf
[root@binblog redis]# mkdir sentinel.conf
[root@binblog redis]# src/redis-cli -p 26379
127.0.0.1:26379> SENTINEL SET mymaster quorum 3
(error) ERR Failed to save config file

19653:X 04 Feb 2022 12:26:10.876 # WARNING: Sentinel was not able to save the new configuration on disk!!!: Is a directory

i am running a daily and see how it (dir things) will look like (passed): https://github.com/enjoy-binbin/redis/actions/runs/1793640021

enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Feb 4, 2022
Change the sentinel config file to a directory in SENTINEL SET test.
So it will now fail on the `rename` in `rewriteConfigOverwriteFile`.

The test used to set the sentinel config file permissions to `000` to
simulate failure. But it fails on centos7 / freebsd / alpine. (introduced in redis#10151)

Other changes:
1. More error messages after the config rewrite failure.
2. Modify arg name `force_all` in `rewriteConfig` to `force_write`. (was rename in redis#9304)
3. Fix a typo in debug quicklist-packed-threshold, then -> than. (redis#9357)
oranagra pushed a commit that referenced this pull request Feb 4, 2022
Change the sentinel config file to a directory in SENTINEL SET test.
So it will now fail on the `rename` in `rewriteConfigOverwriteFile`.

The test used to set the sentinel config file permissions to `000` to
simulate failure. But it fails on centos7 / freebsd / alpine. (introduced in #10151)

Other changes:
1. More error messages after the config rewrite failure.
2. Modify arg name `force_all` in `rewriteConfig` to `force_write`. (was rename in #9304)
3. Fix a typo in debug quicklist-packed-threshold, then -> than. (#9357)
@oranagra oranagra mentioned this pull request Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants