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

multi-DB Part 1: create multiple Redis DB instances based on CONFIG at /etc/sonic/database_config.json #2182

Merged
merged 13 commits into from
Aug 28, 2019

Conversation

dzhangalibaba
Copy link
Collaborator

@dzhangalibaba dzhangalibaba commented Oct 23, 2018

  • this is the first step to moving different databases tables into different database instances

  • in this PR, only handle multiple database instances creation based on user configuration at /etc/sonic/database_config.json

  • we keep current method to create single database instance if no extra/new DATABASE configuration exist in database_config.json file.

  • if user try to configure more db instances at database_config.json , we create those new db instances along with the original db instance existing today.

  • The configuration is as below, later we can add more db related information if needed:
    {
    ...
    "DATABASE": {
    "redis-db-01" : {
    "port" : "6380",
    "database": ["APPL_DB", "STATE_DB"]
    },
    "redis-db-02" : {
    "port" : "6381",
    "database":["ASIC_DB"]
    },
    }
    ...
    }

  • The detail description is at design doc at Design of creating user defined multiple database instances SONiC#271

  • The main idea is : when database.sh started, we check the configuration and generate corresponding scripts.

  • rc.local service handle old_config copy when loading new images, there is no dependency between rc.local and database service today, for safety and make sure the copy operation are done before database try to read it, we make database service run after rc.local

  • Then database docker started, we check the configuration and generate corresponding scripts/.conf in database docker as well.

  • based on those conf, we create databases instances as required.

  • at last, we ping_pong check database are up and continue


Signed-off-by: Dong Zhang d.zhang@alibaba-inc.com

@jipanyang
Copy link
Collaborator

Once the solution is agreed upon, "Configuration DB schema" section of https://github.com/Azure/sonic-swss/blob/master/doc/swss-schema.md should be updated with redis db instance schema.

@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Oct 23, 2018

May I ask a well formatted design doc before reviewing the implementation? We don't want to waste your time on implementation when we still have concerns on the design. #Closed

@dzhangalibaba
Copy link
Collaborator Author

dzhangalibaba commented Oct 23, 2018

sure. I'll prepare some slides to introduce the ideas. We can share it on the weekly meeting.

May I ask a well formatted design doc before reviewing the implementation? We don't want to waste your time on implementation when we still have concerns on the design.

#Resolved

@dzhangalibaba
Copy link
Collaborator Author

dzhangalibaba commented Oct 28, 2018

The Design DOC is here

sonic-net/SONiC#271

sure. I'll prepare some slides to introduce the ideas. We can share it on the weekly meeting.

May I ask a well formatted design doc before reviewing the implementation? We don't want to waste your time on implementation when we still have concerns on the design.

#Resolved

@dzhangalibaba dzhangalibaba changed the title create Redis DB instances based on CONF in config_db.json create multiple Redis DB instances based on CONFIG at /etc/sonic/database_config.json Dec 5, 2018
@@ -35,6 +35,15 @@ RUN sed -ri 's/^(save .*$)/# \1/g; \
s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/ \
' /etc/redis/redis.conf

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]

ENTRYPOINT ["/usr/bin/supervisord"]
Copy link
Collaborator

@qiluo-msft qiluo-msft Dec 6, 2018

Choose a reason for hiding this comment

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

supervisord [](start = 22, length = 11)

supervisord [](start = 22, length = 11)

We prefer keep supervisord as entrypoint. You may refer other docker containers for example with a start.sh. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if the database_config file is static as you said, then we can use supervisord as Entrypoint, and we can generate supervisord.conf during compiling/building

Copy link
Collaborator

Choose a reason for hiding this comment

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

Keeping supervisord as entrypoint is a good practice. Even with database_config.json, it shall be possilble to generate redis-server.sh from redis-server.sh.j2 within db-docker-init.sh(dockers/docker-database/docker_init.sh), and let redis-server.sh handle the dynamic db instances case?

[program:db-docker-init.sh]
command=/usr/bin/db-docker-init.sh
priority=2
autostart=true
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:redis-server.sh]
command=/usr/bin/redis-server.sh
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

Copy link
Collaborator

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comments

@dzhangalibaba
Copy link
Collaborator Author

dzhangalibaba commented Dec 7, 2018

@qiluo-msft Thanks, will take a look #Resolved

@nikos-github
Copy link
Collaborator

nikos-github commented Dec 13, 2018

I haven't followed the entire thread but I will read through it. In the meantime a comment on the config part that caught my eye - I feel that the database config should be under /etc/sonic/database or under /etc/sonic/db. Also I would suggest against a rigid/static config db file. #Resolved

@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Dec 13, 2018

From switch operator's point of view, this is not a config and it is an implementation detail and can be static in an image. Since it is a "config" for redis partitioning, it will be weird that we store it in a redis db.


In reply to: 447149304 [](ancestors = 447149304)

@dzhangalibaba
Copy link
Collaborator Author

@qiluo-msft re-commit the codes, please have a look when you are available.

@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Dec 27, 2018

@dzhangalibaba Could you keep old commits and add new iteration as incremental commits. The review context are all lost and it is difficult to check your improvement. #Closed

@dzhangalibaba
Copy link
Collaborator Author

Sorry Qi, I used git push -force on my local branch and the old commit is overwritten. I thought the comment on this PR is enough and didn't keep the old commit. I'll keep them in future commit. Basically, the main changes is :
1 . database entry point is still supervisord
2. change the SED syntax easily to read and clean
3. make database_config.json static and is known while buidling/compiling
4. then database_config.json will always exist
5. use python to loop on the json file instead of rendering template

The new changes in the commit is more clear to follow. Could you take a look and comment. Thanks.

Best,
Dong

@dzhangalibaba Could you keep old commits and add new iteration as incremental commits. The review context are all lost and it is difficult to check your improvement.

@@ -35,6 +35,15 @@ RUN sed -ri 's/^(save .*$)/# \1/g; \
s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/ \
' /etc/redis/redis.conf

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]

ENTRYPOINT ["/usr/bin/supervisord"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keeping supervisord as entrypoint is a good practice. Even with database_config.json, it shall be possilble to generate redis-server.sh from redis-server.sh.j2 within db-docker-init.sh(dockers/docker-database/docker_init.sh), and let redis-server.sh handle the dynamic db instances case?

[program:db-docker-init.sh]
command=/usr/bin/db-docker-init.sh
priority=2
autostart=true
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:redis-server.sh]
command=/usr/bin/redis-server.sh
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

files/image_config/database/database_config.json Outdated Show resolved Hide resolved
@dzhangalibaba
Copy link
Collaborator Author

redesign and recode this PR after the discussion with SONiC team

@lguohan
Copy link
Collaborator

lguohan commented Aug 15, 2019

thanks for the work. only one comment is left.

@dzhangalibaba
Copy link
Collaborator Author

thanks for the work. only one comment is left.

modified as required

@lguohan
Copy link
Collaborator

lguohan commented Aug 28, 2019

retest this please

@lguohan
Copy link
Collaborator

lguohan commented Aug 28, 2019

retest this please

@lguohan lguohan merged commit 768beb7 into sonic-net:master Aug 28, 2019
@dzhangalibaba dzhangalibaba changed the title create multiple Redis DB instances based on CONFIG at /etc/sonic/database_config.json multi-DB Part 1: create multiple Redis DB instances based on CONFIG at /etc/sonic/database_config.json Sep 5, 2019
@dzhangalibaba dzhangalibaba deleted the createDBinst branch September 27, 2019 23:05
wangshengjun pushed a commit to wangshengjun/sonic-buildimage that referenced this pull request Nov 16, 2020
…base_config.json (sonic-net#2182)

this is the first step to moving different databases tables into different database instances

in this PR, only handle multiple database instances creation based on user configuration at /etc/sonic/database_config.json

we keep current method to create single database instance if no extra/new DATABASE configuration exist in database_config.json file.

if user try to configure more db instances at database_config.json , we create those new db instances along with the original db instance existing today.

The configuration is as below, later we can add more db related information if needed:
{
...
"DATABASE": {
"redis-db-01" : {
"port" : "6380",
"database": ["APPL_DB", "STATE_DB"]
},
"redis-db-02" : {
"port" : "6381",
"database":["ASIC_DB"]
},
}
...
}

The detail description is at design doc at sonic-net/SONiC#271

The main idea is : when database.sh started, we check the configuration and generate corresponding scripts.

rc.local service handle old_config copy when loading new images, there is no dependency between rc.local and database service today, for safety and make sure the copy operation are done before database try to read it, we make database service run after rc.local

Then database docker started, we check the configuration and generate corresponding scripts/.conf in database docker as well.

based on those conf, we create databases instances as required.

at last, we ping_pong check database are up and continue


Signed-off-by: Dong Zhang d.zhang@alibaba-inc.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants