Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(
region_name: str | None = None,
verify: bool | str | None = None,
botocore_config: dict | None = None,
cancel_waiter_names: list[str] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the corresponding docstring for this parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am waiting for the high level approval for the approach from @vincbeck . Once I get go ahead with the approach then I'll add UT's and the doc string also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry forgot to change the PR to draft

):
super().__init__()
# parameters that should be hardcoded in the child's implem
Expand All @@ -105,6 +106,7 @@ def __init__(
self.region_name = region_name
self.verify = verify
self.botocore_config = botocore_config
self.cancel_waiter_names = cancel_waiter_names

def serialize(self) -> tuple[str, dict[str, Any]]:
# here we put together the "common" params,
Expand Down Expand Up @@ -159,3 +161,25 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
self.status_queries,
)
yield TriggerEvent({"status": "success", self.return_key: self.return_value})

async def cleanup(self):
hook = self.hook()
async with await hook.get_async_conn() as client:
if not self.cancel_waiter_names:
return
for waiter_name in self.cancel_waiter_names:
waiter = hook.get_waiter(
waiter_name,
deferrable=True,
client=client,
config_overrides=self.waiter_config_overrides,
)
await async_wait(
waiter,
self.waiter_delay,
self.attempts,
self.waiter_args,
self.failure_message,
self.status_message,
self.status_queries,
)
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def __init__(
waiter_delay=waiter_delay,
waiter_max_attempts=waiter_max_attempts,
aws_conn_id=aws_conn_id,
cancel_waiter_names=["container_job_cancel", "container_job_complete"],
)

def hook(self) -> AwsGenericHook:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
"state": "failure"
}
]
},
"container_job_cancel": {
"operation": "CancelJobRun",
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I understand, this should not be a waiter. A waiter is usually a get method and you need to wait for that response to reach a given state. Here this is an operation, you do not need to call it multiple times

"delay": 30,
"maxAttempts": 60,
"acceptors": [
{
"matcher": "status",
"expected": "200",
"state": "success"
}
]
}
}
}