Open MinhThieu145 opened 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 69.30%. Comparing base (
96968d6
) to head (6c8c31e
). Report is 1110 commits behind head on master.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Here is the expectation:
See this method: https://github.com/Cloud-CV/EvalAI/blob/da7e0680c11a8e60c335c821902211a06ed581de/apps/challenges/aws_utils.py#L1361C1-L1475C15
Now, if you have delete infra, and suppose it starts with deletion of IAM, followed by deletion of EFS, here is what you would write:
@app.task
def destroy_eks_cluster(challenge):
"""
Destroy EKS cluster. Starts with deletion of EKS and Nodegroup roles, and relays to deletion of EFS.
Arguments:
instance {<class 'django.db.models.query.QuerySet'>} -- instance of the model calling the post hook
"""
from .models import ChallengeEvaluationCluster
from .serializers import ChallengeEvaluationClusterSerializer
from .utils import get_aws_credentials_for_challenge
for obj in serializers.deserialize("json", challenge):
challenge_obj = obj.object
challenge_aws_keys = get_aws_credentials_for_challenge(challenge_obj.pk)
client = get_boto3_client("iam", challenge_aws_keys)
eks_role_arn = ...
try:
<LOGIC FOR EKS CLUSTER ROLE DELETION>
except ClientError as e:
logger.exception(e)
return
waiter = client.get_waiter("role_deleted") # TODO: Find correct argument
waiter.wait(<TODO>)
node_group_role_name = "evalai-code-upload-nodegroup-role-{}".format(
environment_suffix
)
node_group_arn_role = ...
try:
<LOGIC FOR EKS NODEGROUP ROLE DELETION>
except ClientError as e:
logger.exception(e)
return
waiter = client.get_waiter("role_exists")
waiter.wait(RoleName=node_group_role_name)
# Delete custom ECR all access policy and attach to node_group_role
ecr_all_access_policy_arn = ...
try:
<LOGIC TO DELETE CUSTOM ECR ALL ACCESS POLICY>
except ClientError as e:
logger.exception(e)
return
# Remove these details from the evaluation cluster on backend
try:
challenge_evaluation_cluster = ChallengeEvaluationCluster.objects.get(
challenge=challenge_obj
)
serializer = ChallengeEvaluationClusterSerializer(
challenge_evaluation_cluster,
data={
"eks_arn_role": '',
"node_group_arn_role": '',
"ecr_all_access_policy_arn": '',
},
partial=True,
)
if serializer.is_valid():
serializer.save()
# Delete efs
delete_efs.delay(challenge)
except Exception as e:
logger.exception(e)
return
This pull request removes the AWS infrastructure for the code upload challenge if the challenge is disapproved by the admin.