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

fix: Use status instead of targetStatus in UpdateWorker. #29

Merged
merged 1 commit into from
Sep 14, 2023
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
2 changes: 1 addition & 1 deletion src/deadline_worker_agent/aws/deadline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def update_worker(
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=status.value,
status=status.value,
)
if host_properties:
request["hostProperties"] = host_properties
Expand Down
4 changes: 2 additions & 2 deletions src/deadline_worker_agent/boto/shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def update_worker(
farmId: str,
fleetId: str,
workerId: str,
targetStatus: Union[str, WorkerStatus],
status: Union[str, WorkerStatus],
capabilities: dict[str, Any] | None = None,
hostProperties: HostProperties | None = None,
) -> UpdateWorkerResponse:
Expand All @@ -425,7 +425,7 @@ def update_worker(
"farmId": farmId,
"fleetId": fleetId,
"workerId": workerId,
"targetStatus": targetStatus,
"status": status,
}
if capabilities is not None:
request["capabilities"] = capabilities
Expand Down
5 changes: 4 additions & 1 deletion src/deadline_worker_agent/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ def _transition_to_stopping(self, timeout: timedelta) -> None:
given additional new tasks to work on.
"""
request = dict[str, Any](
farmId=self._farm_id, fleetId=self._fleet_id, workerId=self._worker_id, state="STOPPING"
Copy link
Contributor Author

@karthikbekalp karthikbekalp Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this worked before and was not updated when undergoing renames from state to targetStatus earlier ...

farmId=self._farm_id,
fleetId=self._fleet_id,
workerId=self._worker_id,
status="STOPPING",
)

start_time = monotonic()
Expand Down
2 changes: 1 addition & 1 deletion src/deadline_worker_agent/session_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LoggingAllowList(TypedDict, total=False):
"deadline.AssumeQueueRoleForWorker": {"log_request_url": True},
"deadline.UpdateWorker": {
"log_request_url": True,
"req_body_keys": ["targetStatus"],
"req_body_keys": ["status"],
"res_body_keys": ["log"],
},
"deadline.BatchGetJobEntity": {"log_request_url": True},
Expand Down
14 changes: 7 additions & 7 deletions test/unit/aws/deadline/test_update_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_success(
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=status.value,
status=status.value,
hostProperties=host_properties,
)
else:
Expand All @@ -126,7 +126,7 @@ def test_success(
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=status.value,
status=status.value,
)


Expand Down Expand Up @@ -180,23 +180,23 @@ def test_updates_to_stopped_if_required(
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=WorkerStatus.STARTED.value,
status=WorkerStatus.STARTED.value,
hostProperties=HOST_PROPERTIES,
),
call(
farmId=config.farm_id,
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=WorkerStatus.STOPPED.value,
status=WorkerStatus.STOPPED.value,
hostProperties=HOST_PROPERTIES,
),
call(
farmId=config.farm_id,
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=WorkerStatus.STARTED.value,
status=WorkerStatus.STARTED.value,
hostProperties=HOST_PROPERTIES,
),
)
Expand Down Expand Up @@ -300,15 +300,15 @@ def test_reraises_when_updates_to_stopped(
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=WorkerStatus.STARTED.value,
status=WorkerStatus.STARTED.value,
hostProperties=HOST_PROPERTIES,
),
call(
farmId=config.farm_id,
fleetId=config.fleet_id,
workerId=worker_id,
capabilities=config.capabilities.for_update_worker(),
targetStatus=WorkerStatus.STOPPED.value,
status=WorkerStatus.STOPPED.value,
hostProperties=HOST_PROPERTIES,
),
)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/scheduler/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test_updates_to_stopping(self, scheduler: WorkerScheduler) -> None:

# THEN
api_mock.assert_called_once()
assert api_mock.call_args.kwargs["state"] == "STOPPING"
assert api_mock.call_args.kwargs["status"] == "STOPPING"

@pytest.mark.parametrize("code", ["ThrottlingException", "InternalServerException"])
def test_retries_on_exception(self, scheduler: WorkerScheduler, code: str) -> None:
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_session_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_logging_allow_list():
"deadline.AssumeQueueRoleForWorker": {"log_request_url": True},
"deadline.UpdateWorker": {
"log_request_url": True,
"req_body_keys": ["targetStatus"],
"req_body_keys": ["status"],
"res_body_keys": ["log"],
},
"deadline.BatchGetJobEntity": {"log_request_url": True},
Expand Down Expand Up @@ -66,10 +66,10 @@ def test_logging_allow_list():
"Content-Type": "application/json",
"User-Agent": "Boto3/1.28.12 md/Botocore#1.31.12 ua/2.0 os/linux#5.4.247-169.350.amzn2int.x86_64 md/arch#x86_64 lang/python#3.9.17 md/pyimpl#CPython cfg/retry-mode#legacy Botocore/1.31.12",
},
"body": b'{"targetStatus": "STARTED", "capabilities": {"amounts": [{"name": "amount.worker.vcpu", "value": 8.0}, {"name": "amount.worker.memory", "value": 14987.5234375}, {"name": "amount.worker.disk.scratch", "value": 0.0}, {"name": "amount.worker.gpu", "value": 0.0}, {"name": "amount.worker.gpu.memory", "value": 0.0}], "attributes": [{"name": "attr.worker.os.family", "values": ["linux"]}, {"name": "attr.worker.cpu.arch", "values": ["x86_64"]}]}, "hostProperties": {"ipAddresses": {"ipV4Addresses": ["127.0.0.1", "0.0.0.0", "0.0.0.0"], "ipV6Addresses": ["0000:0000:0000:0000:0000:0000:00000:0000", "0000:0000:0000:0000:0000:0000:0000:0001", "0000:0000:0000:0000:0000:0000:0000:0000"]}, "hostName": "host.us-west-2.amazon.com"}}',
"body": b'{"status": "STARTED", "capabilities": {"amounts": [{"name": "amount.worker.vcpu", "value": 8.0}, {"name": "amount.worker.memory", "value": 14987.5234375}, {"name": "amount.worker.disk.scratch", "value": 0.0}, {"name": "amount.worker.gpu", "value": 0.0}, {"name": "amount.worker.gpu.memory", "value": 0.0}], "attributes": [{"name": "attr.worker.os.family", "values": ["linux"]}, {"name": "attr.worker.cpu.arch", "values": ["x86_64"]}]}, "hostProperties": {"ipAddresses": {"ipV4Addresses": ["127.0.0.1", "0.0.0.0", "0.0.0.0"], "ipV6Addresses": ["0000:0000:0000:0000:0000:0000:00000:0000", "0000:0000:0000:0000:0000:0000:0000:0001", "0000:0000:0000:0000:0000:0000:0000:0000"]}, "hostName": "host.us-west-2.amazon.com"}}',
"url": "https://**********.execute-api.us-west-2.amazonaws.com/2020-08-21/farms/farm-0000000000000000000000000000000/fleets/fleet-0000000000000000000000000000000/workers/worker-0000000000000000000000000000000",
},
"{'log_type': 'boto_request', 'operation': 'deadline.UpdateWorker', 'params': {'targetStatus': 'STARTED'}, 'request_url': 'https://**********.execute-api.us-west-2.amazonaws.com/2020-08-21/farms/farm-0000000000000000000000000000000/fleets/fleet-0000000000000000000000000000000/workers/worker-0000000000000000000000000000000'}",
"{'log_type': 'boto_request', 'operation': 'deadline.UpdateWorker', 'params': {'status': 'STARTED'}, 'request_url': 'https://**********.execute-api.us-west-2.amazonaws.com/2020-08-21/farms/farm-0000000000000000000000000000000/fleets/fleet-0000000000000000000000000000000/workers/worker-0000000000000000000000000000000'}",
id="UpdateWorkerBeforeCallTest",
),
pytest.param(
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_log_before_call(
"RequestId": "abc878ee-32b5-44d4-885f-29071648328c",
"HTTPStatusCode": 200,
},
"targetStatus": "STOPPED",
"status": "STOPPED",
},
"{'log_type': 'boto_response', 'operation': 'deadline.UpdateWorker', 'status_code': 200, 'params': {'log': None}}",
id="UpdateWorkerAfterCallTest",
Expand Down