Skip to content

Commit 317a4b3

Browse files
authored
[hostcfgd]: wait till system initialization is done before starting hostcfgd (#6232)
- Why I did it The change is done to make sure the system initialization is done before updating the feature states - How I did it use the command "systemctl is-system-running --wait" to wait till system has finished booting up before updating the feature states
1 parent a624aa0 commit 317a4b3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/sonic-host-services/scripts/hostcfgd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class HostConfigDaemon:
300300
self.kdumpCfg = KdumpCfg(self.config_db)
301301
self.kdumpCfg.load(self.config_db.get_table('KDUMP'))
302302

303+
303304
def load(self):
304305
aaa = self.config_db.get_table('AAA')
305306
tacacs_global = self.config_db.get_table('TACPLUS')
@@ -447,6 +448,13 @@ class HostConfigDaemon:
447448
syslog.syslog(syslog.LOG_INFO, 'Kdump handler...')
448449
self.kdumpCfg.kdump_update(key, data, False)
449450

451+
def wait_till_system_init_done(self):
452+
453+
# No need to print the output in the log file so using the "--quiet"
454+
# flag
455+
systemctl_cmd = "sudo systemctl is-system-running --wait --quiet"
456+
subprocess.call(systemctl_cmd, shell=True)
457+
450458
def start(self):
451459

452460
self.config_db.subscribe('AAA', lambda table, key, data: self.aaa_handler(key, data))
@@ -456,6 +464,12 @@ class HostConfigDaemon:
456464
self.config_db.subscribe('FEATURE', lambda table, key, data: self.feature_state_handler(key, data))
457465
self.config_db.subscribe('KDUMP', lambda table, key, data: self.kdump_handler(key, data))
458466

467+
syslog.syslog(syslog.LOG_INFO,
468+
"Waiting for systemctl to finish initialization")
469+
self.wait_till_system_init_done()
470+
syslog.syslog(syslog.LOG_INFO,
471+
"systemctl has finished initialization -- proceeding ...")
472+
459473
# Update all feature states once upon starting
460474
self.update_all_feature_states()
461475

0 commit comments

Comments
 (0)