-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feature(redis) support redis sentinel #11155
Conversation
5f69094
to
2235db0
Compare
Codecov Report
@@ Coverage Diff @@
## master #11155 +/- ##
==========================================
- Coverage 63.64% 63.40% -0.25%
==========================================
Files 878 880 +2
Lines 54133 54289 +156
Branches 1836 1836
==========================================
- Hits 34455 34422 -33
- Misses 16100 16286 +186
- Partials 3578 3581 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
1f51deb
to
9b94732
Compare
a2b29c2
to
3890b87
Compare
This is a valuable PR thanks @bitsf ! But I have some comment in regards to how we set the redis/redis+sentinel settings into core. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments left
3890b87
to
5bbad65
Compare
5bbad65
to
27d2646
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename internal/cache
to lib/redis
because there is no internal
in the harbor now and cache
it does not match the function of this pkg.
PoolMaxIdle: 0, | ||
PoolMaxActive: 1, | ||
PoolIdleTimeout: 60 * time.Second, | ||
DialConnectionTimeout: dialConnectionTimeout, | ||
DialReadTimeout: dialReadTimeout, | ||
DialWriteTimeout: dialWriteTimeout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we unify the Redis param in harbor core?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is focus on support redis sentinel, so I don't want to optimize the param too much for each components, as this might introduce new issues.
07a678b
to
57755bc
Compare
from g import templates_dir, config_dir, data_dir, DEFAULT_UID, DEFAULT_GID | ||
from urllib.parse import urlsplit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard lib should be placed in the first import group
elif u.scheme == 'redis+sentinel': | ||
return { | ||
'cache_store': 'redis_sentinel', | ||
'cache_redis_mastername': u.path.split('/')[1], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
master isn't political right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redis itself is using words master/slave
# password: | ||
# # sentinel_master_set must be set to support redis+sentinel | ||
# #sentinel_master_set: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
master should changed to main or something else
make/photon/prepare/utils/configs.py
Outdated
from g import versions_file_path, host_root_dir, DEFAULT_UID, INTERNAL_NO_PROXY_DN | ||
from models import InternalTLS | ||
from urllib.parse import urlencode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urllib shuold placed in system library import group
'password': '', | ||
} | ||
kwargs.update(redis or {}) | ||
kwargs['db'] = db | ||
kwargs['scheme'] = kwargs.get('sentinel_master_set', None) and 'redis+sentinel' or 'redis' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
word 'master' should change.
'None' seems useless here.
if kwargs['password']: | ||
return "redis://anonymous:{password}@{host}:{port}/{db}".format(**kwargs) | ||
return "redis://{host}:{port}/{db}".format(**kwargs) | ||
return "{scheme}://{password_part}{host}{sentinel_part}{db_part}".format(**kwargs) + get_redis_url_param(kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend only store content in variables like 'db_part', 'sentinel_part', 'password_part'. And the delimiter like/
,@
can rendered in format string.
make/photon/prepare/utils/configs.py
Outdated
|
||
def get_redis_url_param(redis=None): | ||
s = {} | ||
if 'idle_timeout_seconds' in redis: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command will raise an Exception instead of go to the false branch if redis is None
make/photon/prepare/utils/configs.py
Outdated
|
||
|
||
def get_redis_url_param(redis=None): | ||
s = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better use a meaningful variable name
make/photon/prepare/utils/misc.py
Outdated
from g import DEFAULT_UID, DEFAULT_GID, host_root_dir | ||
from pathlib import Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move pathlib
to system lib import group
04b35d9
to
1aec7f7
Compare
Signed-off-by: Ziming Zhang <zziming@vmware.com>
1aec7f7
to
d6cf579
Compare
fix #10365
fix #6828
Add redis sentinel support
change the redis conf, remove port field, add schema field, change host field format to
hostname:post
hostname1:port,hostname2:port,hostname3:port/monitor_name
the full raw url is
redis://<hostname>:<post>/<dbnum>
redis+sentinel://<hostname1>:<port>,<hostname2>:<port>,<hostname2>:<port>/<monitor_name>/<dbnum>
Signed-off-by: Ziming Zhang zziming@vmware.com
Change-Id: Icbcbb5ebe842c4866657e32d5a253f293e643854