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

Update run-task command to give access to the output from the aws cli #135

Closed
liron-quantum opened this issue Jun 3, 2021 · 2 comments · Fixed by #167
Closed

Update run-task command to give access to the output from the aws cli #135

liron-quantum opened this issue Jun 3, 2021 · 2 comments · Fixed by #167
Assignees

Comments

@liron-quantum
Copy link

liron-quantum commented Jun 3, 2021

Describe Request:

The run-task command in that job is great for starting the job, but it doesn't save the output of the run-task command anywhere, which means that there's no easy way to check on the status of the task and wait for it to run before going onto the next build step.

If this functionality could be added to the orb, it would be fantastic.

Examples:

If the task IDs could be added into an environment variable, or if you could specify an output file that the orb command would pipe the output to.

For example, you could add:

run-output:
    description: |
          Specifies an output file on the local disk to save the output from the run-task CLI command.
    type: string

And then update the run_task script to be:

if [ -n "<<params.run-output>>" ]; then
  aws ecs run-task "$@" >> <<params.run-output>>
else
  aws ecs run-task "$@" 
fi
@brivu brivu self-assigned this May 13, 2022
@brivu
Copy link
Contributor

brivu commented Jun 9, 2022

Hey @gugu,

I'm working on updating this orb at the moment and wanted to understand your request a little bit more. Right now, when running the run-task command, there's a json that's outputted like below:

    "tasks": [
        {
            "attachments": [],
            "attributes": [
                {
                    "name": "ecs.cpu-architecture",
                    "value": "x86_64"
                }
            ],
            "availabilityZone": "*********b",
            "clusterArn": "arn:aws:ecs:*********:************:cluster/*************-cluster",
            "containerInstanceArn": "arn:aws:ecs:*********:************:container-instance/*************-cluster/2c4f47871e1943479280dc1e8719eed0",
            "containers": [
                {
                    "containerArn": "arn:aws:ecs:*********:************:container/*************-cluster/164acb4a14b44e8084a6d18b851f4ff3/6dc7d919-0c9e-4a8b-9400-e442354f89eb",
                    "taskArn": "arn:aws:ecs:*********:************:task/*************-cluster/164acb4a14b44e8084a6d18b851f4ff3",
                    "name": "*****",
                    "image": "busybox",
                    "lastStatus": "PENDING",
                    "networkInterfaces": [],
                    "cpu": "0",
                    "memory": "256"
                }
            ],
            "cpu": "256",
            "createdAt": "2022-06-08T22:38:41.104000+00:00",
            "desiredStatus": "RUNNING",
            "enableExecuteCommand": false,
            "group": "family:*************-*****360",
            "lastStatus": "PENDING",
            "launchType": "EC2",
            "memory": "512",
            "overrides": {
                "containerOverrides": [
                    {
                        "name": "*****",
                        "memory": 512
                    }
                ],
                "inferenceAcceleratorOverrides": []
            },
            "tags": [],
            "taskArn": "arn:aws:ecs:*********:************:task/*************-cluster/164acb4a14b44e8084a6d18b851f4ff3",
            "taskDefinitionArn": "arn:aws:ecs:*********:************:task-definition/*************-*****360:116",
            "version": 1
        }
    ],
    "failures": []
}

Is there something in this output that you specifically need or is the goal just to check and see when this step is done so you can run the next one?

Please let me know and I'll see if we can add it for you.

Best,
Brian

@dsvensson
Copy link

dsvensson commented Jun 9, 2022

I think this is what is of interest:

aws ecs wait tasks-stopped --cluster $CLUSTER --tasks $TASK_ID
ecs-cli logs --task-id=$TASK_ID --cluster $CLUSTER | awk NF
EXIT_CODE=$(aws ecs describe-tasks --cluster $CLUSTER --tasks $TASK_ID --query "tasks[0].containers[?name=='my-container'].exitCode" --output text)
[[ $EXIT_CODE -eq 0 ]]

@brivu brivu linked a pull request Jun 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants