Skip to content

Commit 6a56da8

Browse files
rajendra-dendukuritiantianlv
authored andcommitted
[config-setup]: create a SONiC configuration management service (sonic-net#3227)
* Create a SONiC configuration management service * Perform config db migration after loading config_db.json to redis DB * Migrate config-setup post migration hooks on image upgrade config-setup post migration hooks help user to migrate configurations from old image to new image. If the installed hooks are user defined they will not be part of the newly installed image. So these hooks have to be migrated to new image and only then they can be executing when the new image is booting. The changes in this fix migrate config-setup post-migration hooks and ensure that any hooks with the same filename in newly installed image are not overwritten. It is expected that users install new hooks as per their requirement and not edit existing hooks. Any changes to existing hooks need to be done as part of new image and not post bootup.
1 parent b81e587 commit 6a56da8

File tree

5 files changed

+430
-73
lines changed

5 files changed

+430
-73
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Config initialization and migration service
3+
After=rc-local.service
4+
After=database.service
5+
Requires=database.service
6+
{% if sonic_asic_platform == 'mellanox' -%}
7+
Requires=hw-management.service
8+
{% endif -%}
9+
10+
11+
[Service]
12+
Type=oneshot
13+
ExecStart=/usr/bin/config-setup boot
14+
RemainAfterExit=yes
15+
16+
[Install]
17+
WantedBy=multi-user.target
18+

files/build_templates/sonic_debian_extension.j2

+5
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ sudo bash -c "echo '{ \"DEVICE_METADATA\": { \"localhost\": { \"default_bgp_stat
258258
\"{{crm_res}}_threshold_type\": \"percentage\", \"{{crm_res}}_low_threshold\": \"70\", \"{{crm_res}}_high_threshold\": \"85\"{% if not loop.last %}, {% endif %}
259259
{%- endfor %} } } }' >> $FILESYSTEM_ROOT/etc/sonic/init_cfg.json"
260260

261+
# Copy config-setup script and service file
262+
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/config-setup.service
263+
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
264+
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
265+
261266
# Copy SNMP configuration files
262267
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/
263268

files/build_templates/updategraph.service.j2

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
[Unit]
22
Description=Update minigraph and set configuration based on minigraph
3-
After=rc-local.service
4-
After=database.service
5-
Requires=database.service
6-
{% if sonic_asic_platform == 'mellanox' -%}
7-
Requires=hw-management.service
8-
{% endif -%}
9-
3+
After=config-setup.service
4+
Requires=config-setup.service
105

116
[Service]
127
Type=oneshot

0 commit comments

Comments
 (0)