Skip to content

[Fastboot] Delay LLDP service for better fastboot performance #10568

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

Merged
merged 3 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
{%- set features = [("bgp", "enabled", false, "enabled"),
("database", "always_enabled", false, "always_enabled"),
("lldp", "enabled", false, "enabled"),
("lldp", "enabled", true, "enabled"),
("pmon", "enabled", false, "enabled"),
("radv", "enabled", false, "enabled"),
("snmp", "enabled", true, "enabled"),
Expand Down Expand Up @@ -83,6 +83,6 @@
"state" : "disabled", {% endif %}
"rate_limit_interval" : "600"
}{%if not loop.last %},{% endif -%}
{% endfor %}
{% endfor %}
}
}
1 change: 1 addition & 0 deletions files/build_templates/lldp.timer.j2
3 changes: 0 additions & 3 deletions files/build_templates/per_namespace/lldp.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ ExecStartPre=/usr/local/bin/{{docker_container_name}}.sh start{% if multi_instan
ExecStart=/usr/local/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
ExecStop=/usr/local/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
RestartSec=30

[Install]
WantedBy=sonic.target
12 changes: 12 additions & 0 deletions files/build_templates/per_namespace/lldp.timer.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
# This delay is for fast/warm reboot performance
Description=Delays LLDP docker until SONiC has started
PartOf=lldp{% if multi_instance == 'true' %}@%i{% endif %}.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=1min 30 sec
Unit=lldp{% if multi_instance == 'true' %}@%i{% endif %}.service

[Install]
WantedBy=timers.target sonic.target sonic-delayed.target
15 changes: 14 additions & 1 deletion files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ fi
## ensure proc is mounted
sudo mount proc /proc -t proc || true
if [[ $CONFIGURED_ARCH == armhf ]]; then
# A workaround to fix the armhf build hung issue, caused by sonic-platform-nokia-7215_1.0_armhf.deb post installation script
# A workaround to fix the armhf build hung issue, caused by sonic-platform-nokia-7215_1.0_armhf.deb post installation script
ps -eo pid,cmd | grep python | grep "/etc/entropy.py" | awk '{print $1}' | xargs sudo kill -9 2>/dev/null || true
fi

Expand Down Expand Up @@ -766,6 +766,19 @@ if [ -f {{service}} ]; then
echo "{{service}}" | sudo tee -a $GENERATED_SERVICE_FILE
fi
{% endfor %}
{% for timer in installer_timers.split(' ') -%}
if [ -f {{timer}} ]; then
sudo cp {{timer}} $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM

{% if "@" in timer %}
MULTI_INSTANCE="{{timer}}"
SINGLE_INSTANCE=${MULTI_INSTANCE/"@"}
sudo cp $SINGLE_INSTANCE $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
{% endif %}

echo "{{timer}}" | sudo tee -a $GENERATED_SERVICE_FILE
fi
{% endfor %}
if [ -f iccpd.service ]; then
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable iccpd.service
fi
Expand Down
13 changes: 10 additions & 3 deletions files/scripts/syncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ function startplatform() {
}

function waitplatform() {

if [[ x"$sonic_asic_platform" == x"mellanox" ]]; then
debug "Starting pmon service..."
/bin/systemctl start pmon
debug "Started pmon service"
fi
if [[ x"$BOOT_TYPE" = @(x"fast"|x"warm"|x"fastfast") ]]; then
debug "LLDP service is delayed by a timer for better fast/warm boot performance"
else
debug "Starting lldp service..."
/bin/systemctl start lldp
debug "Started lldp service"
fi
}

function stopplatform1() {
Expand All @@ -64,7 +71,7 @@ function stopplatform1() {
debug "${TYPE} shutdown syncd process ..."
/usr/bin/docker exec -i syncd$DEV /usr/bin/syncd_request_shutdown --${TYPE}

# wait until syncd quits gracefully or force syncd to exit after
# wait until syncd quits gracefully or force syncd to exit after
# waiting for 20 seconds
start_in_secs=${SECONDS}
end_in_secs=${SECONDS}
Expand All @@ -76,7 +83,7 @@ function stopplatform1() {
done

if [[ $((end_in_secs - start_in_secs)) -gt $timer_threshold ]]; then
debug "syncd process in container syncd$DEV did not exit gracefully"
debug "syncd process in container syncd$DEV did not exit gracefully"
fi

/usr/bin/docker exec -i syncd$DEV /bin/sync
Expand Down
31 changes: 31 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,14 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
$(eval $(docker:-dbg.gz=.gz)_GLOBAL = yes)
)
fi
if [ -f files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 ]; then
j2 files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer

# Set the flag GLOBAL_TIMER for all the global system-wide dockers timers.
$(if $(shell ls files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 2>/dev/null),\
$(eval $(docker:-dbg.gz=.gz)_GLOBAL_TIMER = yes)
)
fi
# Any service template, inside instance directory, will be used to generate .service and @.service file.
if [ -f files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
export multi_instance="true"
Expand All @@ -1111,6 +1119,16 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export multi_instance="false"
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
fi
# Any timer template, inside instance directory, will be used to generate .timer and @.timer file.
if [ -f files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 ]; then
export multi_instance="true"
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME)@.timer
$(if $(shell ls files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 2>/dev/null),\
$(eval $(docker:-dbg.gz=.gz)_TEMPLATE_TIMER = yes)
)
export multi_instance="false"
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).timer
fi
# Any service template, inside share_image directory, will be used to generate -chassis.service file.
# TODO: need better way to name the image-shared service
if [ -f files/build_templates/share_image/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
Expand Down Expand Up @@ -1148,7 +1166,20 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
$(eval SERVICES += "$(addsuffix -chassis.service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
)
)
# Marks template timers with an "@" according to systemd convention
# If the $($docker)_TEMPLATE_TIMER) variable is set, the timer will be treated as a template
# If the $($docker)_GLOBAL_TIMER) and $($docker)_TEMPLATE_TIMER) variables are set the timer will be added both as a global and template timer.
$(foreach docker, $($*_DOCKERS),\
$(if $($(docker:-dbg.gz=.gz)_TEMPLATE_TIMER),\
$(if $($(docker:-dbg.gz=.gz)_GLOBAL_TIMER),\
$(eval TIMERS += "$(addsuffix .timer, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")\
)\
$(eval TIMERS += "$(addsuffix @.timer, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))"),\
$(eval TIMERS += "$(addsuffix .timer, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
)
)
export installer_services="$(SERVICES)"
export installer_timers="$(TIMERS)"

export installer_extra_files="$(foreach docker, $($*_DOCKERS), $(foreach file, $($(docker:-dbg.gz=.gz)_BASE_IMAGE_FILES), $($(docker:-dbg.gz=.gz)_PATH)/base_image_files/$(file)))"

Expand Down