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

[BUG] redis-sentinel command does not operate in sentinel mode #719

Closed
infordb opened this issue Jul 1, 2024 · 3 comments · Fixed by #731
Closed

[BUG] redis-sentinel command does not operate in sentinel mode #719

infordb opened this issue Jul 1, 2024 · 3 comments · Fixed by #731

Comments

@infordb
Copy link

infordb commented Jul 1, 2024

Describe the bug

The redis-sentinel command does not operate in sentinel mode when sentinel starts.
I have to explicitly pass "--sentine" as a parameter for it to work properly.

To reproduce

Test Version : valkey-7.2.5

[root@test bin]# ls -al
total 38480
drwxr-xr-x. 2 root root 4096 Jun 12 09:25 .
drwxr-xr-x. 13 root root 146 Jun 10 09:44 ..
lrwxrwxrwx 1 root root 37 Jun 10 09:44 aws -> /usr/local/aws-cli/v2/current/bin/aws
lrwxrwxrwx 1 root root 47 Jun 10 09:44 aws_completer -> /usr/local/aws-cli/v2/current/bin/aws_completer
lrwxrwxrwx 1 root root 16 Jun 12 09:25 redis-benchmark -> valkey-benchmark
lrwxrwxrwx 1 root root 16 Jun 12 09:25 redis-check-aof -> valkey-check-aof
lrwxrwxrwx 1 root root 16 Jun 12 09:25 redis-check-rdb -> valkey-check-rdb
lrwxrwxrwx 1 root root 10 Jun 12 09:25 redis-cli -> valkey-cli
lrwxrwxrwx 1 root root 15 Jun 12 09:25 redis-sentinel -> valkey-sentinel
lrwxrwxrwx 1 root root 13 Jun 12 09:25 redis-server -> valkey-server
-rwxr-xr-x 1 root root 9455248 Jun 12 09:25 valkey-benchmark
lrwxrwxrwx 1 root root 13 Jun 12 09:25 valkey-check-aof -> valkey-server
lrwxrwxrwx 1 root root 13 Jun 12 09:25 valkey-check-rdb -> valkey-server
-rwxr-xr-x 1 root root 10185376 Jun 12 09:25 valkey-cli
lrwxrwxrwx 1 root root 13 Jun 12 09:25 valkey-sentinel -> valkey-server
-rwxr-xr-x 1 root root 19754120 Jun 12 09:25 valkey-server

Fail

[root@test ~]# /usr/local/bin/redis-sentinel /etc/redis/sentinel.conf
*** FATAL CONFIG FILE ERROR (Version 7.2.5) ***
Reading the configuration file, at line 14

'sentinel monitor aaasentinel 192.168.x.x 6379 2'
sentinel directive while not in sentinel mode

Success

[root@test ~]# /usr/local/bin/redis-sentinel /etc/redis/sentinel.conf --sentinel

Success

[root@test ~]# /usr/local/bin/valkey-sentinel /etc/redis/sentinel.conf

@infordb infordb changed the title [BUG] [BUG] redis-sentinel command does not operate in sentinel mode Jul 1, 2024
@enjoy-binbin
Copy link
Member

Fail
[root@test ~]# /usr/local/bin/redis-sentinel /etc/redis/sentinel.conf
*** FATAL CONFIG FILE ERROR (Version 7.2.5) ***
Reading the configuration file, at line 14
'sentinel monitor aaasentinel 192.168.x.x 6379 2'
sentinel directive while not in sentinel mode

This is because redis-sentinel causes it to not enter this if statement, so --sentinel needs to be passed explicitly. @madolson do wo need to worry about this?

/* Returns 1 if there is --sentinel among the arguments or if
 * executable name contains "valkey-sentinel". */
int checkForSentinelMode(int argc, char **argv, char *exec_name) {
    if (strstr(exec_name, "valkey-sentinel") != NULL) return 1;

    for (int j = 1; j < argc; j++)
        if (!strcmp(argv[j], "--sentinel")) return 1;
    return 0;
}

@madolson
Copy link
Member

madolson commented Jul 1, 2024

@madolson do to need to worry about this?

I suppose we probably should care about it if we want to be a drop in replacement. We could change it to search for *-sentinel instead perhaps?

@enjoy-binbin
Copy link
Member

good idea, i see we already had these:

    /* valkey may install symlinks like
     * redis-server -> valkey-server, redis-check-rdb -> valkey-check-rdb,
     * redis-check-aof -> valkey-check-aof, etc. */
    if (strstr(exec_name, "redis-check-rdb") != NULL)
        redis_check_rdb_main(argc, argv, NULL);
    else if (strstr(exec_name, "redis-check-aof") != NULL)
        redis_check_aof_main(argc, argv);

so i think we can just add a new line:

if (strstr(exec_name, "redis-sentinel") != NULL) return 1;

enjoy-binbin added a commit to enjoy-binbin/valkey that referenced this issue Jul 2, 2024
We already have similar changes to check-rdb / check-aof, apply
this change to sentinel.

Fixes valkey-io#719.

Signed-off-by: Binbin <[email protected]>
@hwware hwware closed this as completed in 1ea49e5 Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants