Describe the bug

On Sentinel config rewrite, rewritten lines appear below "# Generated by CONFIG REWRITE" line. However this is misleading as other lines in the configuration file can be re-written as well, because automatically changed configuration directives can actually occur above this message, it is misleading in understanding what is static config v's automatic config.

To reproduce

Create simple sentinel.conf with line:

... sentinel monitor mymaster 192.168.0.1 6379 2 ...

Start sentinel on ie 192.168.0.1

Expected behavior

[failure rewrite] ... # Generated by CONFIG REWRITE sentinel monitor mymaster \<NEW IP ADDRESS> 6379 2 ...

NOT [failure rewrite] .. sentinel monitor mymaster \<NEW IP ADDRESS> 6379 2 ... # Generated by CONFIG REWRITE ...

Additional information

Priming a cluster from config files using sentinel monitor X.X.X.X assumes X.X.X.X is always referring to co-located redis instance, at least in conventional docs. However to initialise a cluster from scratch with functioning sentinel failover, all sentinel monitor configs should point to same redis, centralised instance. ie start from a functioning cluster. Then sentinel takes over (and manages ie config monitor entries). If sentinel did not take over, then this issue would not be relevant. However, sentinel does take over, and rewrites the config file, whenever the original master fails and the failed-to instance has a monitor config line that needs updating.

Redis v6.2.6 (Gentoo)

Comment From: hwware

@yossigo Could you please share your idea about this part? I do not think this is a bug, but maybe we could improve the log format. Thanks

Comment From: damobrisbane

Hi @yossigo. When the config file gets dynamically updated, you would expect only the parts below the line Generated by CONFIG REWRITE, get updated. However this is not the case, for example any lines above config rewrite comment, like the monitor line, can be dynamically updated as well. Anything that gets dynamically updated, is better grouped together, below the CONFIG REWRITE comment. An alternative perhaps, is dont bother with it because it seems pretty complicated way of doing things anyway, but is there somewhere that says, "these are the configuration directives that can, or might, get dynamically updated by the Sentinel configuration update process".

Comment From: yossigo

@damobrisbane I'm not able to reproduce this issue, for example:

yossi@ubuntu:~/redis$ cat > test.conf
sentinel monitor mymaster 127.0.0.1 6379 2
yossi@ubuntu:~/redis$ ./src/redis-sentinel test.conf
47017:X 21 Nov 2021 16:22:20.897 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
47017:X 21 Nov 2021 16:22:20.897 # Redis version=6.2.6, bits=64, commit=4930d19e, modified=0, pid=47017, just started
[...]
47017:X 21 Nov 2021 16:22:20.901 # Sentinel ID is 95958f6cfee04a874768a5fd5f36350095e6e588
47017:X 21 Nov 2021 16:22:20.901 # +monitor master mymaster 127.0.0.1 6379 quorum 2
^C47017:signal-handler (1637504541) Received SIGINT scheduling shutdown...
47017:X 21 Nov 2021 16:22:21.593 # User requested shutdown...
47017:X 21 Nov 2021 16:22:21.593 # Sentinel is now ready to exit, bye bye...
yossi@ubuntu:~/redis$ cat test.conf 
sentinel monitor mymaster 127.0.0.1 6379 2
# Generated by CONFIG REWRITE
protected-mode no
port 26379
user default on nopass ~* &* +@all
dir "/home/yossi/redis"
sentinel myid 95958f6cfee04a874768a5fd5f36350095e6e588
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
sentinel current-epoch 0