Skip to content

Commit

Permalink
feat: DeploymentModel.from_stale_hosted_entities can take all hosted …
Browse files Browse the repository at this point in the history
…entities

Not only stale one as it is filtering it anyway.
  • Loading branch information
PaulFarault committed Nov 20, 2024
1 parent e0c4cb3 commit 6cb062f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions tdp/cli/commands/plan/reconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def reconfigure(
with Dao(db_engine, commit_on_exit=True) as dao:
deployment = DeploymentModel.from_stale_hosted_entities(
collections=collections,
stale_hosted_entity_statuses=dao.get_hosted_entity_statuses(
filter_stale=True
),
hosted_entity_statuses=dao.get_hosted_entity_statuses(filter_stale=True),
rolling_interval=rolling_interval,
)
if preview:
Expand Down
4 changes: 1 addition & 3 deletions tdp/core/deployment/deployment_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def __init__(
self._reconfigure_operations = _group_hosts_by_operation(
DeploymentModel.from_stale_hosted_entities(
collections=self._collections,
stale_hosted_entity_statuses=[
status for status in cluster_status.values() if status.is_stale
],
hosted_entity_statuses=list(cluster_status.values()),
)
)
except NothingToReconfigureError:
Expand Down
6 changes: 3 additions & 3 deletions tdp/core/models/deployment_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,21 @@ def from_operations_hosts_vars(
@staticmethod
def from_stale_hosted_entities(
collections: Collections,
stale_hosted_entity_statuses: list[HostedEntityStatus],
hosted_entity_statuses: list[HostedEntityStatus],
rolling_interval: Optional[int] = None,
) -> DeploymentModel:
"""Generate a deployment plan for stale components.
Args:
collections: Collections to retrieve the operations from.
stale_hosted_entity_statuses: List of stale hosted entity statuses.
hosted_entity_statuses: List of hosted entity statuses.
rolling_interval: Number of seconds to wait between component restart.
Raises:
NothingToReconfigureError: If no component needs to be reconfigured.
"""
operation_hosts: set[OperationHostTuple] = set()
for status in stale_hosted_entity_statuses:
for status in hosted_entity_statuses:
if status.to_config:
operation_hosts.add(
OperationHostTuple(
Expand Down
2 changes: 1 addition & 1 deletion test_dag_order/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def plan_reconfigure(
# return the deployment plan (it is neither persisted in the database nor executed)
return DeploymentModel.from_stale_hosted_entities(
collections=collections,
stale_hosted_entity_statuses=dao.get_hosted_entity_statuses(filter_stale=True),
hosted_entity_statuses=dao.get_hosted_entity_statuses(filter_stale=True),
)


Expand Down

0 comments on commit 6cb062f

Please sign in to comment.