Fix logic for ipflush_onchange and restart_on_ipflush
Old logic for ipflush_onchange and restart_on_ipflush restored
for backward compatibility according readme and name semantics.
New pillar option introduced: ifdown_before_changes
New logic for PROD-22473 bug wraped in it
It should be disable in devcloud deployment due to
ifdown will not be executed correctly while interface configuration
is missing in /etc/network/interfaces, until configuration state happens
Related prod: PROD-28458 (PROD:28458)
Change-Id: Ib3263accde3d902fec98bd8676db29ff2812e7e2
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index 706af45..5d7e22b 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -397,9 +397,9 @@
{%- endif %}
{%- if interface.type in ('eth','ovs_port') %}
- {%- if interface.get('restart_on_ipflush', False) %}
-linux_interface_down_on_ipflush_{{ interface_name }}:
+ {%- if interface.get('ifdown_before_changes', False) %}
+linux_interface_down_before_change_{{ interface_name }}:
cmd.run:
- name: ifdown {{ interface_name }}
- prereq:
@@ -409,7 +409,7 @@
- file: ovs_port_{{ interface_name }}
{%- endif %}
-linux_interface_up_on_ipflush_{{ interface_name }}:
+linux_interface_up_after_change_{{ interface_name }}:
cmd.run:
- name: ifup {{ interface_name }}
- onchanges:
@@ -418,18 +418,27 @@
{%- else %}
- file: ovs_port_{{ interface_name }}
{%- endif %}
+ {%- endif %}
- {%- elif interface.get('ipflush_onchange', False)%}
+ {%- if interface.get('ipflush_onchange', False) %}
linux_interface_ipflush_onchange_{{ interface_name }}:
cmd.run:
- name: "/sbin/ip address flush dev {{ interface_name }}"
- - onchanges:
{%- if interface.type == 'eth' %}
+ - onchanges:
- network: linux_interface_{{ interface_name }}
- {%- else %}
+ {%- elif interface.type == 'ovs_port' %}
+ - onchanges:
- file: ovs_port_{{ interface_name }}
{%- endif %}
+ {%- if interface.get('restart_on_ipflush', False) %}
+linux_interface_restart_on_ipflush_{{ interface_name }}:
+ cmd.run:
+ - name: "ifdown {{ interface_name }}; ifup {{ interface_name }};"
+ - onchanges:
+ - cmd: linux_interface_ipflush_onchange_{{ interface_name }}
+ {%- endif %}
{%- endif %}
{%- endif %}