Do not mount redis.sock to avoid race condition #229
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why I did it
Service restapi is mounting /var/run/redis/redis.sock by command parameter "-v /var/run/redis/redis.sock:/var/run/redis/redis.sock". This is dangerous since it will create a directory named "/var/run/redis/redis.sock" if it does not exists. It could cause race condition like this:
2 .redis server starts and try to bind to unix socket, but the folder already exists, so redis failed with log:
"""
Jun 20 22:52:08.451081 sonic INFO database#supervisord: redis 64:M 20 Jun 2024 22:52:08.442 # Opening Unix socket: bind: Address already in use
"""
Work item tracking
How I did it
Since docker_image_ctl.j2 has already mounted /var/run/redis for all containers, there is no point and not safe to mount /var/run/redis/redis.sock. So, I removed the mount from the make file.
How to verify it
Manual test
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)