Skip to content

Commit

Permalink
fix(MrackConfig): Fix MrackConfig class properties
Browse files Browse the repository at this point in the history
Signed-off-by: Tibor Dudlák <[email protected]>
  • Loading branch information
Tiboris committed Feb 21, 2023
1 parent 38313f8 commit 1421b37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/mrack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,28 @@ def require_owner(self, default=False):
"""Return value of require-owner."""
return value_to_bool(self.get("require-owner", default))

def delta_sleep(self, default=15):
@property
def delta_sleep(self):
"""Return value of `delta-sleep` value from config to randomize sleep window."""
return int(self.get("delta-sleep", default))
return int(self.get("delta-sleep", default=15))

@property
def max_utilization(self, default=90):
def max_utilization(self):
"""Return value `max-utilization` from mrack config file."""
return int(self.get("max-utilization", default))
return int(self.get("max-utilization", default=90))

@property
def usable_network_threshold(self, default=95):
def usable_network_threshold(self):
"""Return maximum acceptable network utilization of provider."""
return int(self.get("usable-network-threshold", default))
return int(self.get("usable-network-threshold", default=95))

@property
def network_spread(self, default="allow"):
def network_spread(self):
"""Return `network-spread` setting value from mrack config.
Possible values are:
- no: disable network spreading feature
- allow: allow network spreading feature (default)
- force: always use network spreading feature
"""
return self.get("network-spread", default).lower()
return self.get("network-spread", default="allow").lower()
4 changes: 2 additions & 2 deletions src/mrack/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ async def strategy_retry(self, reqs):
attempts = 0
success_hosts = []
error_hosts = []
delta_sleep = global_context.CONFIG.delta_sleep()
max_utilization = global_context.CONFIG.max_utilization()
delta_sleep = global_context.CONFIG.delta_sleep
max_utilization = global_context.CONFIG.max_utilization

while missing_reqs:
# number of attempts should be greater than max_retry
Expand Down

0 comments on commit 1421b37

Please sign in to comment.