Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function updateSyslogConf()
{
# On multiNPU platforms, change the syslog target ip to docker0 ip to allow logs from containers
# running on the namespace to reach the rsyslog service running on the host
# Also update the container name
# Also update the container name
if [[ ($NUM_ASIC -gt 1) ]]; then
TARGET_IP=$(docker network inspect bridge --format={{ "'{{(index .IPAM.Config 0).Gateway}}'" }})
CONTAINER_NAME="$DOCKERNAME"
Expand Down Expand Up @@ -364,9 +364,11 @@ start() {
-e SX_API_SOCKET_FILE=/var/run/sx_sdk/sx_api.sock \
-v /dev/shm:/dev/shm:rw \
{%- else %}
{%- if mount_default_tmpfs is defined and mount_default_tmpfs == "y" %}
--tmpfs /tmp \
{%- endif %}
{%- endif %}
{%- endif %}
{%- if sonic_asic_platform == "broadcom" %}
{%- if docker_container_name == "syncd" %}
-v /var/run/docker-syncd$DEV:/var/run/sswsyncd \
Expand All @@ -388,13 +390,23 @@ start() {
$REDIS_MNT \
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
{%- if sonic_asic_platform != "mellanox" %}
{%- if mount_default_tmpfs is defined and mount_default_tmpfs == "y" %}
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jan 29, 2021

Choose a reason for hiding this comment

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

This and condition is verbose. Is it possible to simplify? #Closed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, please check the new way:

{%- if mount_default_tmpfs|default("n") == "y" %}

--tmpfs /tmp \
{%- endif %}
{%- endif %}
{%- if mount_default_tmpfs is defined and mount_default_tmpfs == "y" %}
--tmpfs /var/tmp \
{%- endif %}
--env "NAMESPACE_ID"="$DEV" \
--env "NAMESPACE_PREFIX"="$NAMESPACE_PREFIX" \
--env "NAMESPACE_COUNT"=$NUM_ASIC \
--name=$DOCKERNAME {{docker_image_name}}:latest || {
--name=$DOCKERNAME \
{%- if docker_image_name is defined %}
{{docker_image_name}}:latest \
{%- else %}
{{docker_image_id}} \
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jan 29, 2021

Choose a reason for hiding this comment

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

Why add docker_image_id? I don't find any clue in your PR description. #Closed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I updated title and PR description.
With coming app ext feature docker image might not have a 'latest' tag or it might not have a name at all.
So this template is required to accept more general docker_image_id, but preserving compatibility if docker_image_name was passed.

{%- endif %}
|| {
echo "Failed to docker run" >&1
exit 4
}
Expand Down
1 change: 1 addition & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export docker_image="$(docker)"
export docker_image_name="$(basename $(docker))"
export docker_container_name="$($(docker:-dbg.gz=.gz)_CONTAINER_NAME)"
export mount_default_tmpfs="y"
$(eval $(docker:-dbg.gz=.gz)_RUN_OPT += $($(docker:-dbg.gz=.gz)_$($*_IMAGE_TYPE)_RUN_OPT))
export docker_image_run_opt="$($(docker:-dbg.gz=.gz)_RUN_OPT)"

Expand Down