Skip to content

Commit 42dbb01

Browse files
committed
Rename radas_sign_timeout_retry_count and radas_sign_timeout_retry_interval
1 parent 07e43f3 commit 42dbb01

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

charon/config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
"""
16+
1617
import logging
1718
import os
1819
from typing import Dict, List, Optional
@@ -34,6 +35,10 @@ def __init__(self, data: Dict):
3435
self.__client_key: str = data.get("client_key", None)
3536
self.__client_key_pass_file: str = data.get("client_key_pass_file", None)
3637
self.__root_ca: str = data.get("root_ca", "/etc/pki/tls/certs/ca-bundle.crt")
38+
self.__radas_sign_timeout_retry_count: int = data.get("radas_sign_timeout_retry_count", 10)
39+
self.__radas_sign_timeout_retry_interval: int = data.get(
40+
"radas_sign_timeout_retry_interval", 60
41+
)
3742

3843
def validate(self) -> bool:
3944
if not self.__umb_host:
@@ -60,7 +65,7 @@ def validate(self) -> bool:
6065
return True
6166

6267
def umb_target(self) -> str:
63-
return f'amqps://{self.__umb_host}:{self.__umb_host_port}'
68+
return f"amqps://{self.__umb_host}:{self.__umb_host_port}"
6469

6570
def result_queue(self) -> str:
6671
return self.__result_queue
@@ -77,7 +82,7 @@ def client_key(self) -> str:
7782
def client_key_password(self) -> str:
7883
pass_file = self.__client_key_pass_file
7984
if os.access(pass_file, os.R_OK):
80-
with open(pass_file, 'r') as f:
85+
with open(pass_file, "r") as f:
8186
return f.read()
8287
elif pass_file:
8388
logger.warning("The key password file is not accessible. Will ignore the password.")
@@ -86,6 +91,12 @@ def client_key_password(self) -> str:
8691
def root_ca(self) -> str:
8792
return self.__root_ca
8893

94+
def radas_sign_timeout_retry_count(self) -> int:
95+
return self.__radas_sign_timeout_retry_count
96+
97+
def radas_sign_timeout_retry_interval(self) -> int:
98+
return self.__radas_sign_timeout_retry_interval
99+
89100

90101
class CharonConfig(object):
91102
"""CharonConfig is used to store all configurations for charon

charon/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,5 @@
176176

177177
DEFAULT_REGISTRY = "localhost"
178178
DEFAULT_SIGN_RESULT_LOC = "/tmp/sign"
179-
DEFAULT_RADAS_SIGN_TIMEOUT_COUNT = 10
180-
DEFAULT_RADAS_SIGN_WAIT_INTERVAL_SEC = 60
179+
DEFAULT_RADAS_SIGN_TIMEOUT_RETRY_COUNT = 10
180+
DEFAULT_RADAS_SIGN_TIMEOUT_RETRY_INTERVAL = 60

charon/pkgs/radas_signature_handler.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
from typing import List, Any, Tuple, Callable, Dict
2727
from charon.config import get_config
2828
from charon.constants import DEFAULT_SIGN_RESULT_LOC
29-
from charon.constants import DEFAULT_RADAS_SIGN_TIMEOUT_COUNT
30-
from charon.constants import DEFAULT_RADAS_SIGN_WAIT_INTERVAL_SEC
29+
from charon.constants import DEFAULT_RADAS_SIGN_TIMEOUT_RETRY_COUNT
30+
from charon.constants import DEFAULT_RADAS_SIGN_TIMEOUT_RETRY_INTERVAL
3131
from charon.pkgs.oras_client import OrasClient
3232

3333
logger = logging.getLogger(__name__)
@@ -132,19 +132,22 @@ def generate_radas_sign(top_level: str) -> Tuple[List[str], List[str]]:
132132
Generate .asc files based on RADAS sign result json file
133133
"""
134134
conf = get_config()
135-
timeout_count = (
136-
conf.get_radas_sign_timeout_count() if conf else DEFAULT_RADAS_SIGN_TIMEOUT_COUNT
135+
rconf = conf.get_radas_config() if conf else None
136+
timeout_retry_count = (
137+
rconf.radas_sign_timeout_retry_count() if rconf else DEFAULT_RADAS_SIGN_TIMEOUT_RETRY_COUNT
137138
)
138-
wait_interval_sec = (
139-
conf.get_radas_sign_wait_interval_sec() if conf else DEFAULT_RADAS_SIGN_WAIT_INTERVAL_SEC
139+
timeout_retry_interval = (
140+
rconf.radas_sign_timeout_retry_interval()
141+
if conf
142+
else DEFAULT_RADAS_SIGN_TIMEOUT_RETRY_INTERVAL
140143
)
141144
wait_count = 0
142145
while SignHandler.is_processing():
143146
wait_count += 1
144-
if wait_count > timeout_count:
147+
if wait_count > timeout_retry_count:
145148
logger.warning("Timeout when waiting for sign response.")
146149
break
147-
time.sleep(wait_interval_sec)
150+
time.sleep(timeout_retry_interval)
148151

149152
files = SignHandler.get_downloaded_files()
150153
if not files:

0 commit comments

Comments
 (0)