From 7ab2db63f7d5f30035d6db2ec2a86a156c50d2f6 Mon Sep 17 00:00:00 2001
From: Radek Vykydal <rvykydal@redhat.com>
Date: Wed, 19 Aug 2020 13:50:48 +0200
Subject: [PATCH] network: add timeout for synchronous activation of a
 connection

Related: rhbz#1869323
---
 pyanaconda/modules/network/constants.py |  1 +
 pyanaconda/modules/network/nm_client.py | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/modules/network/constants.py b/pyanaconda/modules/network/constants.py
index 33c99d76e..530a8e281 100644
--- a/pyanaconda/modules/network/constants.py
+++ b/pyanaconda/modules/network/constants.py
@@ -24,6 +24,7 @@ from pyanaconda.core.constants import FIREWALL_DEFAULT, FIREWALL_DISABLED, \
 
 
 NM_CONNECTION_UUID_LENGTH = 36
+CONNECTION_ACTIVATION_TIMEOUT = 45
 
 
 @unique
diff --git a/pyanaconda/modules/network/nm_client.py b/pyanaconda/modules/network/nm_client.py
index 5e1fb854e..2f5703e76 100644
--- a/pyanaconda/modules/network/nm_client.py
+++ b/pyanaconda/modules/network/nm_client.py
@@ -23,9 +23,10 @@ gi.require_version("NM", "1.0")
 from gi.repository import NM
 
 import socket
-from queue import Queue
+from queue import Queue, Empty
 from pykickstart.constants import BIND_TO_MAC
-from pyanaconda.modules.network.constants import NM_CONNECTION_UUID_LENGTH
+from pyanaconda.modules.network.constants import NM_CONNECTION_UUID_LENGTH, \
+    CONNECTION_ACTIVATION_TIMEOUT
 from pyanaconda.modules.network.kickstart import default_ks_vlan_interface_name
 from pyanaconda.modules.network.utils import is_s390, get_s390_settings, netmask2prefix, \
     prefix2netmask
@@ -939,7 +940,13 @@ def activate_connection_sync(nm_client, connection, device):
         sync_queue
     )
 
-    return sync_queue.get()
+    try:
+        ret = sync_queue.get(timeout=CONNECTION_ACTIVATION_TIMEOUT)
+    except Empty:
+        log.error("Activation of a connection timed out.")
+        ret = None
+
+    return ret
 
 
 def get_dracut_arguments_from_connection(nm_client, connection, iface, target_ip,
-- 
2.23.0