Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove granularity #209

Merged
merged 3 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tardis/adapters/sites/cloudstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ def handle_exceptions(self):
yield
except asyncio.TimeoutError as te:
raise TardisTimeout from te
except ClientConnectionError:
except ClientConnectionError as err:
logger.warning("Connection reset error")
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from err
except CloudStackClientException as ce:
log_msg = (
f"Error code: {ce.error_code}, error text: {ce.error_text}, "
f"response: {ce.response}"
)
if ce.error_code == 535:
logger.warning(f"Quota exceeded: {log_msg}")
raise TardisQuotaExceeded
raise TardisQuotaExceeded from ce
elif ce.error_code == 500:
if "timed out" in ce.response["message"]:
logger.warning(f"Timed out: {log_msg}")
Expand Down
2 changes: 1 addition & 1 deletion tardis/adapters/sites/htcondor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async def resource_status(
if (
self._htcondor_queue.last_update - resource_attributes.created
).total_seconds() < 0:
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from None
else:
return AttributeDict(resource_status=ResourceStatus.Deleted)
else:
Expand Down
6 changes: 3 additions & 3 deletions tardis/adapters/sites/moab.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ async def resource_status(
try:
resource_uuid = resource_attributes.remote_resource_uuid
resource_status = self._moab_status[str(resource_uuid)]
except KeyError:
except KeyError as err:
if (
self._moab_status._last_update - resource_attributes.created
).total_seconds() < 0:
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from err
else:
resource_status = {
"JobID": resource_attributes.remote_resource_uuid,
Expand Down Expand Up @@ -234,7 +234,7 @@ def handle_exceptions(self):
raise TardisTimeout from te
except asyncssh.Error as exc:
logger.warning("SSH connection failed: " + str(exc))
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from exc
except IndexError as ide:
raise TardisResourceStatusUpdateFailed from ide
except TardisResourceStatusUpdateFailed:
Expand Down
12 changes: 6 additions & 6 deletions tardis/adapters/sites/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ def handle_exceptions(self):
raise TardisTimeout from te
except AuthError as ae:
raise TardisAuthError from ae
except ContentTypeError:
except ContentTypeError as cte:
logger.warning("OpenStack: content Type Error")
raise TardisResourceStatusUpdateFailed
except ClientError:
raise TardisResourceStatusUpdateFailed from cte
except ClientError as ce:
logger.warning("REST client error")
raise TardisDroneCrashed
except ClientConnectionError:
raise TardisDroneCrashed from ce
except ClientConnectionError as cde:
logger.warning("Connection reset error")
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from cde
except Exception as ex:
raise TardisError from ex
4 changes: 2 additions & 2 deletions tardis/adapters/sites/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def resource_status(
# In case the created timestamp is after last update timestamp of the
# asynccachemap, no decision about the current state can be given,
# since map is updated asynchronously. Just retry later on.
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from None
else:
resource_status = {
"JobID": resource_attributes.remote_resource_uuid,
Expand Down Expand Up @@ -209,7 +209,7 @@ def handle_exceptions(self):
yield
except CommandExecutionFailure as ex:
logger.warning("Execute command failed: %s" % str(ex))
raise TardisResourceStatusUpdateFailed
raise TardisResourceStatusUpdateFailed from ex
except TardisResourceStatusUpdateFailed:
raise
except TimeoutError as te:
Expand Down
8 changes: 4 additions & 4 deletions tardis/resources/dronestates.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ async def resource_status(state_transition, drone: "Drone", current_state: Type[
await drone.site_agent.resource_status(drone.resource_attributes)
)
logger.debug(f"Resource attributes: {drone.resource_attributes}")
except (TardisAuthError, TardisTimeout, TardisResourceStatusUpdateFailed):
except (TardisAuthError, TardisTimeout, TardisResourceStatusUpdateFailed) as err:
# Retry to get current state of the resource
raise StopProcessing(last_result=current_state())
except TardisDroneCrashed:
raise StopProcessing(last_result=current_state()) from err
except TardisDroneCrashed as tdc:
# Try to cleanup crashed resources
raise StopProcessing(last_result=CleanupState())
raise StopProcessing(last_result=CleanupState()) from tdc
else:
return state_transition[drone.resource_attributes.resource_status]()

Expand Down
1 change: 0 additions & 1 deletion tardis/resources/poolfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def create_composite_pool(configuration: str = None) -> WeightedComposite:
Standardiser(
FactoryPool(*check_pointed_drones, factory=drone_factory),
minimum=cpu_cores,
granularity=cpu_cores,
),
name=f"{site.name.lower()}_{machine_type.lower()}",
)
Expand Down
4 changes: 2 additions & 2 deletions tardis/utilities/attributedict.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __getattr__(self, item):
except KeyError:
raise AttributeError(
f"{item} is not a valid attribute. Dict contains {str(self)}."
)
) from None

def __setattr__(self, key, value):
self[key] = value
Expand All @@ -27,4 +27,4 @@ def __delattr__(self, item):
except KeyError:
raise AttributeError(
f"{item} is not a valid attribute. Dict contains {str(self)}."
)
) from None
2 changes: 1 addition & 1 deletion tests/resources_t/test_poolfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_create_composite(
self.assertEqual(
mock_standardiser.mock_calls,
[
call(mock_factory_pool(), minimum=cpu_cores, granularity=cpu_cores),
call(mock_factory_pool(), minimum=cpu_cores),
call(mock_weighted_composite(), maximum=self.config.Sites[0].quota),
],
)
Expand Down