Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@
# only describe the pod if the task above failed, to help diagnose
describe_pod.trigger_rule = TriggerRule.ONE_FAILED

# Wait for fargate profile to be in stable state before deletion
await_fargate_profile_stable = EksFargateProfileStateSensor(
task_id="await_fargate_profile_stable",
trigger_rule=TriggerRule.ALL_DONE,
cluster_name=cluster_name,
fargate_profile_name=fargate_profile_name,
target_state=FargateProfileStates.ACTIVE,
)

# An Amazon EKS cluster can not be deleted with attached resources such as nodegroups or Fargate profiles.
# Setting the `force` to `True` will delete any attached resources before deleting the cluster.
delete_cluster_and_fargate_profile = EksDeleteClusterOperator(
Expand Down Expand Up @@ -146,6 +155,7 @@
start_pod,
# TEST TEARDOWN
describe_pod,
await_fargate_profile_stable,
delete_cluster_and_fargate_profile,
await_delete_cluster,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@
# only describe the pod if the task above failed, to help diagnose
describe_pod.trigger_rule = TriggerRule.ONE_FAILED

# Wait for fargate profile to be in stable state before deletion
await_fargate_profile_stable = EksFargateProfileStateSensor(
task_id="await_fargate_profile_stable",
trigger_rule=TriggerRule.ALL_DONE,
cluster_name=cluster_name,
fargate_profile_name=fargate_profile_name,
target_state=FargateProfileStates.ACTIVE,
)

# [START howto_operator_eks_delete_fargate_profile]
delete_fargate_profile = EksDeleteFargateProfileOperator(
task_id="delete_eks_fargate_profile",
Expand All @@ -154,6 +163,14 @@
poke_interval=10,
)

# Wait for cluster to be in stable state before deletion
await_cluster_stable = EksClusterStateSensor(
task_id="await_cluster_stable",
trigger_rule=TriggerRule.ALL_DONE,
cluster_name=cluster_name,
target_state=ClusterStates.ACTIVE,
)

delete_cluster = EksDeleteClusterOperator(
task_id="delete_eks_cluster",
cluster_name=cluster_name,
Expand All @@ -178,8 +195,10 @@
start_pod,
# TEARDOWN
describe_pod,
await_fargate_profile_stable,
delete_fargate_profile, # part of the test AND teardown
await_delete_fargate_profile,
await_cluster_stable,
delete_cluster,
await_delete_cluster,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ def delete_launch_template(template_name: str):
# only describe the pod if the task above failed, to help diagnose
describe_pod.trigger_rule = TriggerRule.ONE_FAILED

# Wait for nodegroup to be in stable state before deletion
await_nodegroup_stable = EksNodegroupStateSensor(
task_id="await_nodegroup_stable",
trigger_rule=TriggerRule.ALL_DONE,
cluster_name=cluster_name,
nodegroup_name=nodegroup_name,
target_state=NodegroupStates.ACTIVE,
)

# [START howto_operator_eks_force_delete_cluster]
# An Amazon EKS cluster can not be deleted with attached resources such as nodegroups or Fargate profiles.
# Setting the `force` to `True` will delete any attached resources before deleting the cluster.
Expand Down Expand Up @@ -166,6 +175,7 @@ def delete_launch_template(template_name: str):
start_pod,
# TEST TEARDOWN
describe_pod,
await_nodegroup_stable,
delete_nodegroup_and_cluster,
await_delete_cluster,
delete_launch_template(launch_template_name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ def delete_launch_template(template_name: str):
# only describe the pod if the task above failed, to help diagnose
describe_pod.trigger_rule = TriggerRule.ONE_FAILED

# Wait for nodegroup to be in stable state before deletion
await_nodegroup_stable = EksNodegroupStateSensor(
task_id="await_nodegroup_stable",
trigger_rule=TriggerRule.ALL_DONE,
cluster_name=cluster_name,
nodegroup_name=nodegroup_name,
target_state=NodegroupStates.ACTIVE,
)

# [START howto_operator_eks_delete_nodegroup]
delete_nodegroup = EksDeleteNodegroupOperator(
task_id="delete_nodegroup",
Expand All @@ -179,6 +188,14 @@ def delete_launch_template(template_name: str):
target_state=NodegroupStates.NONEXISTENT,
)

# Wait for cluster to be in stable state before deletion
await_cluster_stable = EksClusterStateSensor(
task_id="await_cluster_stable",
trigger_rule=TriggerRule.ALL_DONE,
cluster_name=cluster_name,
target_state=ClusterStates.ACTIVE,
)

# [START howto_operator_eks_delete_cluster]
delete_cluster = EksDeleteClusterOperator(
task_id="delete_cluster",
Expand Down Expand Up @@ -207,8 +224,10 @@ def delete_launch_template(template_name: str):
start_pod,
# TEST TEARDOWN
describe_pod,
await_nodegroup_stable,
delete_nodegroup, # part of the test AND teardown
await_delete_nodegroup,
await_cluster_stable,
delete_cluster, # part of the test AND teardown
await_delete_cluster,
delete_launch_template(launch_template_name),
Expand Down