Skip to content

Commit

Permalink
[config] Reload Monit configuration after potential hostname changes (s…
Browse files Browse the repository at this point in the history
…onic-net#1132)

**- What I did**

After hostname changes, we need to reload the Monit configuration in order for Monit to pick up the new system hostname. Otherwise, it will retain the previous hostname.

**- How I did it**

Call `sudo monit reload` after restarting hostname-config.service.
  • Loading branch information
jleveque authored Oct 8, 2020
1 parent efb08f8 commit 2e024de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ def _restart_services(config_db):

execute_systemctl(services_to_restart, SYSTEMCTL_ACTION_RESTART)

# Reload Monit configuration to pick up new hostname in case it changed
click.echo("Reloading Monit configuration ...")
clicommon.run_command("sudo monit reload")


def interface_is_in_vlan(vlan_member_table, interface_name):
""" Check if an interface is in a vlan """
Expand Down Expand Up @@ -1235,6 +1239,11 @@ def hostname(new_hostname):
except SystemExit as e:
click.echo("Restarting hostname-config service failed with error {}".format(e))
raise

# Reload Monit configuration to pick up new hostname in case it changed
click.echo("Reloading Monit configuration ...")
clicommon.run_command("sudo monit reload")

click.echo("Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`.")

#
Expand Down
1 change: 1 addition & 0 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
Executing restart of service hostcfgd...
Executing restart of service nat...
Executing restart of service telemetry...
Reloading Monit configuration ...
Please note setting loaded from minigraph will be lost after system reboot. To preserve setting, run `config save`.
"""

Expand Down

0 comments on commit 2e024de

Please sign in to comment.