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

Chore/clean up #1320

Merged
merged 2 commits into from
Jul 14, 2020
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
24 changes: 18 additions & 6 deletions gen3/bin/bucket-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ EOF

# Run k8s jobs to submitting jobs and consuming sqs
local sqsUrl=$(aws sqs get-queue-url --queue-name $sqs_name | jq -r .QueueUrl)
gen3 gitops filter $HOME/cloud-automation/kube/services/jobs/bucket-manifest-job.yaml BUCKET $bucket JOB_QUEUE $job_queue JOB_DEFINITION $job_definition SQS $sqsUrl AUTHZ "$authz" OUT_BUCKET $temp_bucket | sed "s|sa-#SA_NAME_PLACEHOLDER#|$saName|g" | sed "s|bucket-manifest#PLACEHOLDER#|bucket-manifest-${jobId}|g" > ./bucket-manifest-${jobId}-job.yaml
gen3 job run ./bucket-manifest-${jobId}-job.yaml
gen3 gitops filter $HOME/cloud-automation/kube/services/jobs/bucket-manifest-job.yaml BUCKET $bucket JOB_QUEUE $job_queue JOB_DEFINITION $job_definition SQS $sqsUrl AUTHZ "$authz" OUT_BUCKET $temp_bucket | sed "s|sa-#SA_NAME_PLACEHOLDER#|$saName|g" | sed "s|bucket-manifest#PLACEHOLDER#|bucket-manifest-${jobId}|g" > ./aws-bucket-manifest-${jobId}-job.yaml
gen3 job run ./aws-bucket-manifest-${jobId}-job.yaml
gen3_log_info "The job is started. Job ID: ${jobId}"

}
Expand All @@ -153,7 +153,17 @@ EOF
# @param job-id
#
gen3_manifest_generating_status() {
gen3_log_info "Please use kubectl logs -f bucket-manifest-{jobid}-xxx command"
if [[ $# -lt 1 ]]; then
gen3_log_info "An jobId is required"
exit 1
fi
jobid=$1
pod_name=$(g3kubectl get pod | grep aws-bucket-manifest-$jobid | grep -e Completed -e Running | cut -d' ' -f1)
if [[ $? != 0 ]]; then
gen3_log_err "The job has not been started. Check it again"
exit 0
fi
g3kubectl logs -f ${pod_name}
}


Expand Down Expand Up @@ -205,8 +215,10 @@ gen3_batch_cleanup() {
gen3 cd
gen3_load "gen3/lib/terraform"
gen3_terraform destroy
gen3 trash --apply

if [[ $? == 0 ]]; then
gen3 trash --apply
fi

# Delete service acccount, role and policy attached to it
role=$(g3kubectl describe serviceaccount $saName | grep Annotations | sed -n "s/^.*:role\/\(\S*\)$/\1/p")
policyName=$(gen3_aws_run aws iam list-role-policies --role-name $role | jq -r .PolicyNames[0])
Expand All @@ -229,7 +241,7 @@ case "$command" in
gen3_batch_cleanup "$@"
;;
'status')
gen3_manifest_generating_status
gen3_manifest_generating_status "$@"
;;
'list' )
gen3_bucket_manifest_list
Expand Down
5 changes: 4 additions & 1 deletion gen3/bin/gcp-bucket-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ gen3_batch_cleanup() {
gen3 cd
gen3_load "gen3/lib/terraform"
gen3_terraform destroy
gen3 trash --apply

if [[ $? == 0 ]]; then
gen3 trash --apply
fi

gsutil rm -r gs://"${temp_bucket}"
g3kubectl delete job google-bucket-manifest-${jobId}
Expand Down
2 changes: 1 addition & 1 deletion kube/services/jobs/bucket-manifest-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: bucket-manifest#PLACEHOLDER#
name: aws-bucket-manifest#PLACEHOLDER#
spec:
template:
metadata:
Expand Down