1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-12 04:58:34 +03:00

Fixed default retries to 1 day (failures) and state checks (lock on an single state) to 3 hours...

This commit is contained in:
Adolfo Gómez García 2024-09-04 22:36:59 +02:00
parent e90099bcac
commit 01c41704a9
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
3 changed files with 21 additions and 15 deletions

View File

@ -32,10 +32,16 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import typing
SUGGESTED_CHECK_INTERVAL: typing.Final[int] = 8 # In seconds
MAX_RETRIES: typing.Final[int] = 7 * 24 * 60 // SUGGESTED_CHECK_INTERVAL # 7 days
MAX_STATE_CHECKS: typing.Final[int] = 32 # Max number of state checks before giving up
HOURS_BEFORE_CONSIDERED_LOCKED: typing.Final[int] = 2 # In hours
USRV_SUGGESTED_CHECK_INTERVAL: typing.Final[int] = 8 # In seconds
USRV_MAX_RETRIES: typing.Final[int] = 24 * 3600 // USRV_SUGGESTED_CHECK_INTERVAL # 1 day
USRV_MAX_STATE_CHECKS: typing.Final[int] = (
HOURS_BEFORE_CONSIDERED_LOCKED * 3600 // USRV_SUGGESTED_CHECK_INTERVAL
) # hours for a single state at most
PUB_SUGGESTED_CHECK_INTERVAL: typing.Final[int] = 30 # In seconds
PUB_MAX_RETRIES: typing.Final[int] = 7 * 24 * 60 // PUB_SUGGESTED_CHECK_INTERVAL # 7 days
PUB_MAX_STATE_CHECKS: typing.Final[int] = 7200 // PUB_SUGGESTED_CHECK_INTERVAL # 2 hours for a single state at most
PUB_MAX_RETRIES: typing.Final[int] = 24 * 3600 // PUB_SUGGESTED_CHECK_INTERVAL # 1 day
PUB_MAX_STATE_CHECKS: typing.Final[int] = (
HOURS_BEFORE_CONSIDERED_LOCKED * 3600 // PUB_SUGGESTED_CHECK_INTERVAL
) # hours for a single state at most

View File

@ -71,15 +71,15 @@ class DynamicUserService(services.UserService, autoserializable.AutoSerializable
and that will be always the from a "fixed" machine, that is, a machine that is not created.
"""
suggested_delay = consts.services.SUGGESTED_CHECK_INTERVAL
suggested_delay = consts.services.USRV_SUGGESTED_CHECK_INTERVAL
# How many times we will check for a state before giving up
max_state_checks: typing.ClassVar[int] = consts.services.USRV_MAX_STATE_CHECKS
# How many "retries" operation on same state will be allowed before giving up
max_retries: typing.ClassVar[int] = consts.services.USRV_MAX_RETRIES
# Some customization fields
# If ip can be manually overriden, normally True... (set by actor, for example)
can_set_ip: typing.ClassVar[bool] = True
# How many times we will check for a state before giving up
max_state_checks: typing.ClassVar[int] = 20
# How many "retries" operation on same state will be allowed before giving up
max_retries: typing.ClassVar[int] = consts.services.MAX_RETRIES
# If store_error_as_finished is true, and an error occurs, the machine is set to FINISHED instead of ERROR
store_error_as_finished: typing.ClassVar[bool] = False
# If must wait untill finish queue for destroying the machine
@ -157,7 +157,7 @@ class DynamicUserService(services.UserService, autoserializable.AutoSerializable
count = data.get('exec_count', 0) + 1
data['exec_count'] = count
if count > self.max_state_checks:
return self.error(f'Max checks reached on {op}')
return self.error(f'Max checks reached on {op.as_str()}: {self.max_state_checks}')
return None
@typing.final
@ -172,7 +172,7 @@ class DynamicUserService(services.UserService, autoserializable.AutoSerializable
data['retries'] = retries
if retries > self.max_retries: # get "own class" max retries
return self.error(f'Max retries reached')
return self.error(f'Max retries reached on {self._current_op().as_str()}: {self.max_retries}')
return None

View File

@ -68,11 +68,11 @@ class FixedUserService(services.UserService, autoserializable.AutoSerializable,
- FINISH
"""
suggested_delay = 8
suggested_delay = consts.services.USRV_SUGGESTED_CHECK_INTERVAL
# How many times we will check for a state before giving up
max_state_checks: typing.ClassVar[int] = 20
max_state_checks: typing.ClassVar[int] = consts.services.USRV_MAX_STATE_CHECKS
# How many "retries" operation on same state will be allowed before giving up
max_retries: typing.ClassVar[int] = consts.services.MAX_RETRIES
max_retries: typing.ClassVar[int] = consts.services.USRV_MAX_RETRIES
_name = autoserializable.StringField(default='')
_mac = autoserializable.StringField(default='')