Skip to content

Commit

Permalink
refactor: replace Operation.action_name with Operation.name.action
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulFarault committed Nov 21, 2024
1 parent d830730 commit 55df193
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tdp/core/cluster_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def generate_stale_sch_logs(
nodes=list(source_reconfigure_operations), restart=True
):
# Only create a log when config or restart operation is available
if operation.action_name not in ["config", "restart"]:
if operation.name.action not in ["config", "restart"]:
continue

# Create a log for each host where the entity is deployed
Expand All @@ -148,9 +148,9 @@ def generate_stale_sch_logs(
source=SCHStatusLogSourceEnum.STALE,
),
)
if operation.action_name == "config":
if operation.name.action == "config":
log.to_config = True
elif operation.action_name == "restart":
elif operation.name.action == "restart":
log.to_restart = True

return set(logs.values())
Expand Down
8 changes: 4 additions & 4 deletions tdp/core/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,18 @@ def warning(collection_name: str, message: str) -> None:
# Part 1
service_actions = services_actions.setdefault(operation.name.service, set())
if operation.is_service_operation():
service_actions.add(operation.action_name)
service_actions.add(operation.name.action)

# Each service action (config, start, init) except the first (install) must have an explicit
# dependency with the previous service action within the same service
actions_order = ["install", "config", "start", "init"]
# Check only if the action is in actions_order and is not the first
if (
operation.action_name in actions_order
and operation.action_name != actions_order[0]
operation.name.action in actions_order
and operation.name.action != actions_order[0]
):
previous_action = actions_order[
actions_order.index(operation.action_name) - 1
actions_order.index(operation.name.action) - 1
]
previous_service_action = f"{operation.name.service}_{previous_action}"
previous_service_action_found = False
Expand Down
2 changes: 1 addition & 1 deletion tdp/core/deployment/deployment_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _process_operation_fn(
for host in hosts:
sch_status_log = self._cluster_status.update_hosted_entity(
create_hosted_entity(entity_name, host),
action_name=operation.action_name,
action_name=operation.name.action,
version=self._cluster_variables[operation.name.service].version,
can_update_stale=can_update_stale,
)
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 @@ -175,7 +175,7 @@ def from_dag(
for operation in operations:
can_perform_rolling_restart = (
rolling_interval is not None
and operation.action_name == "restart"
and operation.name.action == "restart"
and operation.host_names
)
deployment.operations.append(
Expand Down Expand Up @@ -245,7 +245,7 @@ def from_operations(
for operation in operations:
can_perform_rolling_restart = (
rolling_interval is not None
and operation.action_name == "restart"
and operation.name.action == "restart"
and operation.host_names
)
for host_name in host_names or (
Expand Down Expand Up @@ -378,7 +378,7 @@ def from_stale_hosted_entities(
)
)
# Add sleep operation after each "restart"
if rolling_interval is not None and operation.action_name == "restart":
if rolling_interval is not None and operation.name.action == "restart":
operation_order += 1
deployment.operations.append(
OperationModel(
Expand Down
2 changes: 0 additions & 2 deletions tdp/core/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def __init__(
self.noop = noop
self.host_names = host_names or set()

self.action_name = self.name.action

for host_name in self.host_names:
if len(host_name) > HOST_NAME_MAX_LENGTH:
raise ValueError(
Expand Down

0 comments on commit 55df193

Please sign in to comment.