Skip to content

Commit ce60800

Browse files
authored
Ignore failures in enabling a systemd service (#320)
With Trixie, there will be services that will be defined in /run/systemd/generator (this is a workaround for dealing with restrictions from systemd placed on service generators and for multi-ASIC units). Enabling such services fails because it's assumed to be always enabled. Therefore, if the enable command for some service fails, don't treat it as a hard error, and continue. Additionally, change the featured.timer to restart featured every 1 second instead of instantaneously. This prevents a CPU and syslog flood from happening on initial bringup of certain topologies (multi ASIC and T2) on KVM; physical devices are likely unaffected.
1 parent ee9ef3f commit ce60800

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

data/debian/sonic-host-services-data.featured.timer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description=Delays feature daemon until SONiC has started
33
PartOf=featured.service
44

55
[Timer]
6-
OnUnitActiveSec=0 sec
6+
OnUnitActiveSec=1 sec
77
OnBootSec=1min 30 sec
88
Unit=featured.service
99

scripts/featured

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,21 @@ class FeatureHandler(object):
437437
for cmd in cmds:
438438
syslog.syslog(syslog.LOG_INFO, "Running cmd: '{}'".format(cmd))
439439
try:
440-
run_cmd(cmd, raise_exception=True)
440+
if "enable" in cmd:
441+
# If we are running an enable command, then ignore any errors that might come
442+
# from the service file being defined only in the /run folder. This is because
443+
# it doesn't make sense to enable generated services. In Trixie, because of
444+
# restrictions from systemd and limitations around resetting fields relating
445+
# to dependencies, we are basically copying the service files from the /usr/lib
446+
# folder to /run, except for any dependency-related fields.
447+
#
448+
# We need a better solution to this, maybe something like custom fields in
449+
# the service files for specifying SONiC dependencies. That way, our service
450+
# generator can just look for that and translate that to either non-instanced
451+
# units or to instanced units and add those as dependencies.
452+
run_cmd(cmd, raise_exception=False)
453+
else:
454+
run_cmd(cmd, raise_exception=True)
441455
except Exception as err:
442456
syslog.syslog(syslog.LOG_ERR, "Feature '{}.{}' failed to be enabled and started"
443457
.format(feature.name, feature_suffixes[-1]))

0 commit comments

Comments
 (0)