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
This commit is squash of 3 following commits:
I4397e9e82f8d4114ced50ff253679a8f27762c17
I8f07c79e2e48e032f41efa52a14e4a4e60137abd
Ib3263accde3d902fec98bd8676db29ff2812e7e2
Closes-Bug: PROD-22473
Closes-Bug: PROD-28414
Related prod: PROD-28458 (PROD:28458)
Change-Id: Ib3263accde3d902fec98bd8676db29ff2812e7e2
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index 2cfdb3b..326dee4 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -389,31 +389,49 @@
{%- endif %}
{%- if interface.type in ('eth','ovs_port') %}
-{%- if interface.get('ipflush_onchange', False) %}
+ {%- if interface.get('ifdown_before_changes', False) %}
+linux_interface_down_before_change_{{ interface_name }}:
+ cmd.run:
+ - name: ifdown {{ interface_name }}
+ - prereq:
+ {%- if interface.type == 'eth' %}
+ - network: linux_interface_{{ interface_name }}
+ {%- else %}
+ - file: ovs_port_{{ interface_name }}
+ {%- endif %}
+
+linux_interface_up_after_change_{{ interface_name }}:
+ cmd.run:
+ - name: ifup {{ interface_name }}
+ - onchanges:
+ {%- if interface.type == 'eth' %}
+ - network: linux_interface_{{ interface_name }}
+ {%- else %}
+ - file: ovs_port_{{ interface_name }}
+ {%- endif %}
+ {%- endif %}
+
+ {%- if interface.get('ipflush_onchange', False) %}
linux_interface_ipflush_onchange_{{ interface_name }}:
cmd.run:
- name: "/sbin/ip address flush dev {{ interface_name }}"
-{%- if interface.type == 'eth' %}
+ {%- if interface.type == 'eth' %}
- onchanges:
- network: linux_interface_{{ interface_name }}
-{%- elif interface.type == 'ovs_port' %}
+ {%- elif interface.type == 'ovs_port' %}
- onchanges:
- file: ovs_port_{{ interface_name }}
-{%- endif %}
+ {%- endif %}
-{%- if interface.get('restart_on_ipflush', False) %}
-
+ {%- 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 %}
+ {%- endif %}
{%- endif %}
{%- endfor %}