|
|
8f19656 |
From 08cebe5fae426c11b51e645754b87e4ec5737ef3 Mon Sep 17 00:00:00 2001
|
|
|
8f19656 |
From: Ondrej Nosek <onosek@redhat.com>
|
|
|
8f19656 |
Date: Tue, 22 Aug 2023 22:22:03 +0200
|
|
|
b48b289 |
Subject: [PATCH 08/17] Make lookaside cache retries configurable
|
|
|
8f19656 |
|
|
|
8f19656 |
The number of attempts for lookaside cache network operations is now
|
|
|
8f19656 |
configurable - there are new keys 'lookaside_attempts'
|
|
|
8f19656 |
and 'lookaside_delay' in the configuration.
|
|
|
8f19656 |
The Former expresses a maximum number of attempts to try the operation.
|
|
|
8f19656 |
'0' or '1' is for a single try (no-retry).
|
|
|
8f19656 |
The latter means an initial delay between network operation attempts.
|
|
|
8f19656 |
Each attempt doubles the previous delay value. In seconds.
|
|
|
8f19656 |
|
|
|
8f19656 |
JIRA: RHELCMP-11210
|
|
|
8f19656 |
|
|
|
8f19656 |
Signed-off-by: Ondrej Nosek <onosek@redhat.com>
|
|
|
8f19656 |
---
|
|
|
8f19656 |
pyrpkg/__init__.py | 10 ++++++++--
|
|
|
8f19656 |
pyrpkg/cli.py | 34 +++++++++++++++++++++++++++++++++-
|
|
|
8f19656 |
2 files changed, 41 insertions(+), 3 deletions(-)
|
|
|
8f19656 |
|
|
|
8f19656 |
diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
|
|
|
8f19656 |
index f69f2ce..5928d47 100644
|
|
|
8f19656 |
--- a/pyrpkg/__init__.py
|
|
|
8f19656 |
+++ b/pyrpkg/__init__.py
|
|
|
8f19656 |
@@ -110,7 +110,8 @@ class Commands(object):
|
|
|
8f19656 |
build_client, user=None,
|
|
|
8f19656 |
dist=None, target=None, quiet=False,
|
|
|
8f19656 |
distgit_namespaced=False, realms=None, lookaside_namespaced=False,
|
|
|
8f19656 |
- git_excludes=None, results_dir='root', allow_pre_generated_srpm=False):
|
|
|
8f19656 |
+ git_excludes=None, results_dir='root', allow_pre_generated_srpm=False,
|
|
|
8f19656 |
+ lookaside_attempts=None, lookaside_delay=None):
|
|
|
8f19656 |
"""Init the object and some configuration details."""
|
|
|
8f19656 |
|
|
|
8f19656 |
# Path to operate on, most often pwd
|
|
|
8f19656 |
@@ -242,6 +243,10 @@ class Commands(object):
|
|
|
8f19656 |
# A Configuration value used in 'import_srpm' command (comes from the Copr team)
|
|
|
8f19656 |
# If pre-generated srpms are allowed, don't care specfile is processed by rpmautospec
|
|
|
8f19656 |
self.allow_pre_generated_srpm = allow_pre_generated_srpm
|
|
|
8f19656 |
+ # number of attempts for lookaside network operations
|
|
|
8f19656 |
+ self.lookaside_attempts = lookaside_attempts
|
|
|
8f19656 |
+ # initial delay between network operation attempts. In seconds.
|
|
|
8f19656 |
+ self.lookaside_delay = lookaside_delay
|
|
|
8f19656 |
|
|
|
8f19656 |
# Define properties here
|
|
|
8f19656 |
# Properties allow us to "lazy load" various attributes, which also means
|
|
|
8f19656 |
@@ -262,7 +267,8 @@ class Commands(object):
|
|
|
8f19656 |
"""
|
|
|
8f19656 |
return CGILookasideCache(
|
|
|
8f19656 |
self.lookasidehash, self.lookaside, self.lookaside_cgi,
|
|
|
8f19656 |
- client_cert=self.cert_file, ca_cert=self.ca_cert)
|
|
|
8f19656 |
+ client_cert=self.cert_file, ca_cert=self.ca_cert,
|
|
|
8f19656 |
+ attempts=self.lookaside_attempts, delay=self.lookaside_delay)
|
|
|
8f19656 |
|
|
|
8f19656 |
@property
|
|
|
8f19656 |
def path(self):
|
|
|
8f19656 |
diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py
|
|
|
8f19656 |
index 1bd7979..16298f0 100644
|
|
|
8f19656 |
--- a/pyrpkg/cli.py
|
|
|
8f19656 |
+++ b/pyrpkg/cli.py
|
|
|
8f19656 |
@@ -261,7 +261,9 @@ class cliClient(object):
|
|
|
8f19656 |
realms=realms,
|
|
|
8f19656 |
lookaside_namespaced=la_namespaced,
|
|
|
8f19656 |
git_excludes=git_excludes,
|
|
|
8f19656 |
- results_dir=results_dir
|
|
|
8f19656 |
+ results_dir=results_dir,
|
|
|
8f19656 |
+ lookaside_attempts=self.lookaside_attempts,
|
|
|
8f19656 |
+ lookaside_delay=self.lookaside_delay
|
|
|
8f19656 |
)
|
|
|
8f19656 |
|
|
|
8f19656 |
if self.args.repo_name:
|
|
|
8f19656 |
@@ -3087,3 +3089,33 @@ class cliClient(object):
|
|
|
8f19656 |
|
|
|
8f19656 |
def pre_push_check(self):
|
|
|
8f19656 |
self.cmd.pre_push_check(self.args.ref)
|
|
|
8f19656 |
+
|
|
|
8f19656 |
+ @property
|
|
|
8f19656 |
+ def lookaside_attempts(self):
|
|
|
8f19656 |
+ """loads parameter 'lookaside_attempts' from the config file
|
|
|
8f19656 |
+ """
|
|
|
8f19656 |
+ val = None
|
|
|
8f19656 |
+ if self.config.has_option(self.name, 'lookaside_attempts'):
|
|
|
8f19656 |
+ val = self.config.get(self.name, 'lookaside_attempts')
|
|
|
8f19656 |
+ try:
|
|
|
8f19656 |
+ val = int(val)
|
|
|
8f19656 |
+ except Exception:
|
|
|
8f19656 |
+ self.log.error("Error: The config value 'lookaside_attempts' "
|
|
|
8f19656 |
+ "should be an integer.")
|
|
|
8f19656 |
+ val = None
|
|
|
8f19656 |
+ return val
|
|
|
8f19656 |
+
|
|
|
8f19656 |
+ @property
|
|
|
8f19656 |
+ def lookaside_delay(self):
|
|
|
8f19656 |
+ """loads parameter 'lookaside_delay' from the config file
|
|
|
8f19656 |
+ """
|
|
|
8f19656 |
+ val = None
|
|
|
8f19656 |
+ if self.config.has_option(self.name, 'lookaside_delay'):
|
|
|
8f19656 |
+ val = self.config.get(self.name, 'lookaside_delay')
|
|
|
8f19656 |
+ try:
|
|
|
8f19656 |
+ val = int(val)
|
|
|
8f19656 |
+ except Exception:
|
|
|
8f19656 |
+ self.log.error("Error: The config value 'lookaside_delay' "
|
|
|
8f19656 |
+ "should be an integer.")
|
|
|
8f19656 |
+ val = None
|
|
|
8f19656 |
+ return val
|
|
|
8f19656 |
--
|
|
|
b48b289 |
2.43.0
|
|
|
8f19656 |
|