da80593ecb
Modify j2 template files in docker-dhcp-relay. Add dhcprelayd to group dhcp-relay instead of isc-dhcp-relay-VlanXXX, which would make dhcprelayd to become critical process. In dhcprelayd, subscribe FEATURE table to check whether dhcp_server feature is enabled. 2.1 If dhcp_server feature is disabled, means we need original dhcp_relay functionality, dhcprelayd would do nothing. Because dhcrelay/dhcpmon configuration is generated in supervisord configuration, they will automatically run. 2.2 If dhcp_server feature is enabled, dhcprelayd will stop dhcpmon/dhcrelay processes started by supervisord and subscribe dhcp_server related tables in config_db to start dhcpmon/dhcrelay processes. 2.3 While dhcprelayd running, it will regularly check feature status (by default per 5s) and would encounter below 4 state change about dhcp_server feature: A) disabled -> enabled In this scenario, dhcprelayd will subscribe dhcp_server related tables and stop dhcpmon/dhcrelay processes started by supervisord and start new pair of dhcpmon/dhcrelay processes. After this, dhcpmon/dhcrelay processes are totally managed by dhcprelayd. B) enabled -> enabled In this scenaro, dhcprelayd will monitor db changes in dhcp_server related tables to determine whether to restart dhcpmon/dhrelay processes. C) enabled -> disabled In this scenario, dhcprelayd would unsubscribe dhcp_server related tables and kill dhcpmon/dhcrelay processes started by itself. And then dhcprelayd will start dhcpmon/dhcrelay processes via supervisorctl. D) disabled -> disabled dhcprelayd will check whether dhcrelay processes running status consistent with supervisord configuration file. If they are not consistent, dhcprelayd will kill itself, then dhcp_relay container will stop because dhcprelayd is critical process.
79 lines
2.2 KiB
Django/Jinja
79 lines
2.2 KiB
Django/Jinja
[supervisord]
|
|
logfile_maxbytes=1MB
|
|
logfile_backups=2
|
|
nodaemon=true
|
|
|
|
[eventlistener:dependent-startup]
|
|
command=python3 -m supervisord_dependent_startup
|
|
autostart=true
|
|
autorestart=unexpected
|
|
startretries=0
|
|
exitcodes=0,3
|
|
events=PROCESS_STATE
|
|
buffer_size=1024
|
|
|
|
[eventlistener:supervisor-proc-exit-listener]
|
|
command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_relay
|
|
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
|
|
autostart=true
|
|
autorestart=unexpected
|
|
buffer_size=1024
|
|
|
|
[program:rsyslogd]
|
|
command=/usr/sbin/rsyslogd -n -iNONE
|
|
priority=1
|
|
autostart=false
|
|
autorestart=false
|
|
stdout_logfile=syslog
|
|
stderr_logfile=syslog
|
|
dependent_startup=true
|
|
|
|
[program:start]
|
|
command=/usr/bin/start.sh
|
|
priority=2
|
|
autostart=false
|
|
autorestart=false
|
|
startsecs=0
|
|
stdout_logfile=syslog
|
|
stderr_logfile=syslog
|
|
dependent_startup=true
|
|
dependent_startup_wait_for=rsyslogd:running
|
|
|
|
{# If our configuration has VLANs... #}
|
|
{% if VLAN_INTERFACE %}
|
|
{# Count how many VLANs require a DHCP relay agent... #}
|
|
{% set ipv4_num_relays = { 'count': 0 } %}
|
|
{% set ipv6_num_relays = { 'count': 0 } %}
|
|
{% for vlan_name in VLAN_INTERFACE %}
|
|
{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %}
|
|
{% set _dummy = ipv4_num_relays.update({'count': ipv4_num_relays.count + 1}) %}
|
|
{% endif %}
|
|
{% if DHCP_RELAY and vlan_name in DHCP_RELAY and DHCP_RELAY[vlan_name]['dhcpv6_servers']|length > 0 %}
|
|
{% set _dummy = ipv6_num_relays.update({'count': ipv6_num_relays.count + 1}) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{# If one or more of the VLANs require a DHCP relay agent... #}
|
|
{% if ipv4_num_relays.count > 0 or ipv6_num_relays.count > 0 %}
|
|
{% include 'dhcp-relay.programs.j2' %}
|
|
|
|
{# Create a program entry for each DHCP relay agent instance #}
|
|
{% set relay_for_ipv4 = { 'flag': False } %}
|
|
{% set relay_for_ipv6 = { 'flag': False } %}
|
|
{% for vlan_name in VLAN_INTERFACE %}
|
|
{% include 'dhcpv4-relay.agents.j2' %}
|
|
{% endfor %}
|
|
|
|
{% include 'dhcpv6-relay.agents.j2' %}
|
|
{% include 'dhcp-relay.monitors.j2' %}
|
|
{% endif %}
|
|
{% endif %}
|
|
[program:dhcprelayd]
|
|
command=/usr/local/bin/dhcprelayd
|
|
priority=3
|
|
autostart=false
|
|
autorestart=false
|
|
stdout_logfile=syslog
|
|
stderr_logfile=syslog
|
|
dependent_startup=true
|
|
dependent_startup_wait_for=start:exited
|