[lxc-devel] [lxc-ci/master] Fix cloud networking issue

monstermunchkin on Github lxc-bot at linuxcontainers.org
Mon May 25 16:04:49 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 303 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200525/209454f1/attachment.bin>
-------------- next part --------------
From 227e0ce0a0e33e6bd2b3b1c7dce5e5a75a234878 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 25 May 2020 17:45:42 +0200
Subject: [PATCH 1/4] images/oracle: Disable network device once

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 images/oracle.yaml | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/images/oracle.yaml b/images/oracle.yaml
index a46fc40..0cdff0d 100644
--- a/images/oracle.yaml
+++ b/images/oracle.yaml
@@ -105,22 +105,22 @@ files:
   releases:
   - 8
 
-- name: override.conf
-  path: /etc/systemd/system/NetworkManager.service.d/override.conf
+- name: network-device-down.service
+  path: /etc/systemd/system/network-device-down.service
   generator: dump
   content: |-
-    [Service]
-    ExecStartPre=-/usr/sbin/ip link set eth0 down
-  variant:
-  - default
+    [Unit]
+    Description=Turn off network device
+    Before=NetworkManager.service
 
-- name: override.conf
-  path: /etc/systemd/system/NetworkManager.service.d/override.conf
-  generator: dump
-  content: |-
     [Service]
-    ExecStartPre=-/usr/sbin/ip link set eth0 up
-  variant:
+    ExecStart=-/usr/sbin/ip link set eth0 down
+    Type=oneshot
+    RemainAfterExit=true
+
+    [Install]
+    WantedBy=default.target
+  variants:
   - cloud
 
 - name: network
@@ -261,3 +261,12 @@ actions:
 
     # Disable loginuid in PAM stack
     sed -i '/^session.*pam_loginuid.so/s/^session/# session/' /etc/pam.d/*
+
+- trigger: post-files
+  action: |-
+    #!/bin/bsh
+    set -eux
+
+    systemctl enable network-device-down.service
+  variants:
+  - cloud

From ca31bfb0ccda580542deb675b569b44023b5d41c Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 25 May 2020 17:55:07 +0200
Subject: [PATCH 2/4] images/centos: Disable network device once

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 images/centos.yaml | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/images/centos.yaml b/images/centos.yaml
index 496760b..1a7e0a8 100644
--- a/images/centos.yaml
+++ b/images/centos.yaml
@@ -371,12 +371,23 @@ files:
   types:
   - vm
 
-- name: override.conf
-  path: /etc/systemd/system/NetworkManager.service.d/override.conf
+- name: network-device-down.service
+  path: /etc/systemd/system/network-device-down.service
   generator: dump
   content: |-
+    [Unit]
+    Description=Turn off network device
+    Before=NetworkManager.service
+
     [Service]
-    ExecStartPre=-/usr/sbin/ip link set eth0 down
+    ExecStart=-/usr/sbin/ip link set eth0 down
+    Type=oneshot
+    RemainAfterExit=true
+
+    [Install]
+    WantedBy=default.target
+  variants:
+  - cloud
 
 - name: network
   path: /etc/sysconfig/network
@@ -617,3 +628,12 @@ actions:
   releases:
   - 8
   - 8-Stream
+
+- trigger: post-files
+  action: |-
+    #!/bin/bsh
+    set -eux
+
+    systemctl enable network-device-down.service
+  variants:
+  - cloud

From ce9c509cc0a84558a241f7086d93e0b88513ac08 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 25 May 2020 17:55:51 +0200
Subject: [PATCH 3/4] images/fedora: Disable network device once

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 images/fedora.yaml | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/images/fedora.yaml b/images/fedora.yaml
index 54e1e00..be4ade4 100644
--- a/images/fedora.yaml
+++ b/images/fedora.yaml
@@ -120,12 +120,21 @@ files:
   types:
   - container
 
-- name: override.conf
-  path: /etc/systemd/system/NetworkManager.service.d/override.conf
+- name: network-device-down.service
+  path: /etc/systemd/system/network-device-down.service
   generator: dump
   content: |-
+    [Unit]
+    Description=Turn off network device
+    Before=NetworkManager.service
+
     [Service]
-    ExecStartPre=-/usr/sbin/ip link set eth0 down
+    ExecStart=-/usr/sbin/ip link set eth0 down
+    Type=oneshot
+    RemainAfterExit=true
+
+    [Install]
+    WantedBy=default.target
   variants:
   - cloud
   types:
@@ -286,3 +295,12 @@ actions:
     exit 0
   types:
   - vm
+
+- trigger: post-files
+  action: |-
+    #!/bin/bsh
+    set -eux
+
+    systemctl enable network-device-down.service
+  variants:
+  - cloud

From ec74e7cd592aa0ed9e765ab57d9a699667f4b20f Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 25 May 2020 18:02:05 +0200
Subject: [PATCH 4/4] images/sabayon: Disable network device once

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 images/sabayon.yaml | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/images/sabayon.yaml b/images/sabayon.yaml
index c3da51d..3a5ed48 100644
--- a/images/sabayon.yaml
+++ b/images/sabayon.yaml
@@ -56,11 +56,23 @@ files:
     ExecStart=
     ExecStart=/usr/lib/systemd/systemd-sysctl  --prefix=/etc/sysctl.d/
 
-- path: /etc/systemd/system/NetworkManager.service.d/override.conf
+- name: network-device-down.service
+  path: /etc/systemd/system/network-device-down.service
   generator: dump
   content: |-
+    [Unit]
+    Description=Turn off network device
+    Before=NetworkManager.service
+
     [Service]
-    ExecStartPre=-/bin/ip -4 link set dev eth0 down
+    ExecStart=-/bin/ip -4 link set eth0 down
+    Type=oneshot
+    RemainAfterExit=true
+
+    [Install]
+    WantedBy=default.target
+  variants:
+  - cloud
 
 - name: meta-data
   generator: cloud-init
@@ -126,6 +138,9 @@ actions:
 
     # Enable cloud-init systemd unit
     systemctl enable cloud-init.service
+
+    systemctl enable network-device-down.service
+
   variants:
   - cloud
 


More information about the lxc-devel mailing list