Skip to content

Commit

Permalink
[config-setup]: create a SONiC configuration management service (soni…
Browse files Browse the repository at this point in the history
…c-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.
  • Loading branch information
rajendra-dendukuri authored and pphuchar committed Mar 9, 2020
1 parent 9c4807e commit 896c967
Show file tree
Hide file tree
Showing 5 changed files with 430 additions and 73 deletions.
18 changes: 18 additions & 0 deletions files/build_templates/config-setup.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Config initialization and migration service
After=rc-local.service
After=database.service
Requires=database.service
{% if sonic_asic_platform == 'mellanox' -%}
Requires=hw-management.service
{% endif -%}


[Service]
Type=oneshot
ExecStart=/usr/bin/config-setup boot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

5 changes: 5 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ sudo bash -c "echo '{ \"DEVICE_METADATA\": { \"localhost\": { \"default_bgp_stat
\"{{crm_res}}_threshold_type\": \"percentage\", \"{{crm_res}}_low_threshold\": \"70\", \"{{crm_res}}_high_threshold\": \"85\"{% if not loop.last %}, {% endif %}
{%- endfor %} } } }' >> $FILESYSTEM_ROOT/etc/sonic/init_cfg.json"

# Copy config-setup script and service file
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/config-setup.service
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service

# Copy SNMP configuration files
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/

Expand Down
9 changes: 2 additions & 7 deletions files/build_templates/updategraph.service.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
[Unit]
Description=Update minigraph and set configuration based on minigraph
After=rc-local.service
After=database.service
Requires=database.service
{% if sonic_asic_platform == 'mellanox' -%}
Requires=hw-management.service
{% endif -%}

After=config-setup.service
Requires=config-setup.service

[Service]
Type=oneshot
Expand Down
Loading

0 comments on commit 896c967

Please sign in to comment.