From 7a4a54a9ec68a8b10ba84e13d5f9f69fbf6c912b Mon Sep 17 00:00:00 2001
From: Yuming Zhu <yzhu@redhat.com>
Date: Nov 26 2018 07:16:42 +0000
Subject: [PATCH 1/2] make timeout of authentication configurable


---

diff --git a/cli/koji.conf b/cli/koji.conf
index 26c24cf..addd4e3 100644
--- a/cli/koji.conf
+++ b/cli/koji.conf
@@ -39,3 +39,9 @@
 
 ;enabled plugins for CLI, runroot and save_failed_tree are available
 ;plugins =
+
+;timeout of XMLRPC requests by seconds, default: 60 * 60 * 12 = 43200
+;timeout = 43200
+
+;timeout of GSSAPI/SSL authentication by seconds, default: 60
+;auth_timeout = 60
diff --git a/koji/__init__.py b/koji/__init__.py
index bc40a98..d6ba9fe 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -1648,6 +1648,7 @@ def read_config(profile_name, user_config=None):
         'offline_retry_interval' : None,
         'keepalive' : True,
         'timeout' : None,
+        'auth_timeout' : None,
         'use_fast_upload': False,
         'upload_blocksize': 1048576,
         'poll_interval': 6,
@@ -1719,7 +1720,8 @@ def read_config(profile_name, user_config=None):
                                 'debug', 'debug_xmlrpc', 'krb_canon_host'):
                         result[name] = config.getboolean(profile_name, name)
                     elif name in ('max_retries', 'retry_interval',
-                                  'offline_retry_interval', 'poll_interval', 'timeout',
+                                  'offline_retry_interval', 'poll_interval',
+                                  'timeout', 'auth_timeout',
                                   'upload_blocksize', 'pyver'):
                         try:
                             result[name] = int(value)
@@ -2037,6 +2039,7 @@ def grab_session_options(options):
         'anon_retry',
         'keepalive',
         'timeout',
+        'auth_timeout',
         'use_fast_upload',
         'upload_blocksize',
         'krb_rdns',
@@ -2239,7 +2242,7 @@ class ClientSession(object):
         old_opts = self.opts
         self.opts = old_opts.copy()
         try:
-            self.opts['timeout'] = 60
+            self.opts['timeout'] = self.opts.get('auth_timeout') or 60
             kwargs = {}
             if keytab:
                 old_env['KRB5_CLIENT_KTNAME'] = os.environ.get('KRB5_CLIENT_KTNAME')
@@ -2304,7 +2307,7 @@ class ClientSession(object):
         # 60 second timeout during login
         old_opts = self.opts
         self.opts = old_opts.copy()
-        self.opts['timeout'] = 60
+        self.opts['timeout'] = self.opts.get('auth_timeout') or 60
         self.opts['cert'] = cert
         self.opts['serverca'] = serverca
         try:

From 3ca79d7db859ffc4601c19e2cc2259b887ce87e8 Mon Sep 17 00:00:00 2001
From: Yuming Zhu <yzhu@redhat.com>
Date: Nov 27 2018 10:53:52 +0000
Subject: [PATCH 2/2] set default value for timeout and auth_timeout in read_config


and do not override auth_timeout = 0 by default: 60 which means no timeout

---

diff --git a/koji/__init__.py b/koji/__init__.py
index d6ba9fe..f529eb7 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -268,6 +268,10 @@ BASEDIR = '/mnt/koji'
 # default task priority
 PRIO_DEFAULT = 20
 
+# default timeouts
+DEFAULT_REQUEST_TIMEOUT = 60 * 60 * 12
+DEFAULT_AUTH_TIMEOUT = 60
+
 ## BEGIN kojikamid dup
 
 #Exceptions
@@ -1647,8 +1651,8 @@ def read_config(profile_name, user_config=None):
         'offline_retry' : None,
         'offline_retry_interval' : None,
         'keepalive' : True,
-        'timeout' : None,
-        'auth_timeout' : None,
+        'timeout' : DEFAULT_REQUEST_TIMEOUT,
+        'auth_timeout' : DEFAULT_AUTH_TIMEOUT,
         'use_fast_upload': False,
         'upload_blocksize': 1048576,
         'poll_interval': 6,
@@ -2077,7 +2081,7 @@ class ClientSession(object):
         self.logger = logging.getLogger('koji')
         self.rsession = None
         self.new_session()
-        self.opts.setdefault('timeout',  60 * 60 * 12)
+        self.opts.setdefault('timeout', DEFAULT_REQUEST_TIMEOUT)
 
 
     def new_session(self):
@@ -2236,13 +2240,14 @@ class ClientSession(object):
         # Force a new session
         self.new_session()
 
-        # 60 second timeout during login
         sinfo = None
         old_env = {}
         old_opts = self.opts
         self.opts = old_opts.copy()
         try:
-            self.opts['timeout'] = self.opts.get('auth_timeout') or 60
+            # temporary timeout value during login
+            self.opts['timeout'] = self.opts.get('auth_timeout',
+                                                 DEFAULT_AUTH_TIMEOUT)
             kwargs = {}
             if keytab:
                 old_env['KRB5_CLIENT_KTNAME'] = os.environ.get('KRB5_CLIENT_KTNAME')
@@ -2304,10 +2309,11 @@ class ClientSession(object):
         # Force a new session
         self.new_session()
 
-        # 60 second timeout during login
         old_opts = self.opts
         self.opts = old_opts.copy()
-        self.opts['timeout'] = self.opts.get('auth_timeout') or 60
+        # temporary timeout value during login
+        self.opts['timeout'] = self.opts.get('auth_timeout',
+                                             DEFAULT_AUTH_TIMEOUT)
         self.opts['cert'] = cert
         self.opts['serverca'] = serverca
         try:

