【问题标题】:Why does AWS Copilot Task Run always return exit code 0 without --follow option?Why does AWS Copilot Task Run always return exit code 0 without --follow option?
【发布时间】:2022-12-28 08:03:52
【问题描述】:

I have a Docker image setup to run a simple script that I am running via copilot task run.

FROM node:12-alpine
RUN apk update
RUN apk add curl
RUN apk add jq
RUN apk add --no-cache aws-cli
COPY deploy-permissions.sh /usr/local/bin/deploy-permissions.sh
RUN chmod +x /usr/local/bin/deploy-permissions.sh
ENTRYPOINT ["/usr/local/bin/deploy-permissions.sh"]

When I run it via copilot task run with the --follow flag, it shows me all the log output and returns the exit code correctly.

So if I run a scenario when I know it will fail, I get

copilot task run --image %URLTOImage% --follow
echo $? (reports 1 correctly)

However, if I don't pass in --follow the command seems to complete much quicker and the exit status code is 0 regardless of whether the docker container's entrypoint script succeeds or not.

copilot task run --image %URLToImage%
echo $? (always reports 0)

The documentation says that --follow should just stream the logs, nothing about it not waiting for completion.

Am I missing something here? Why would this happen? It's causing me problems because our CI/CD pipeline is not liking the --follow option. If I could run the task without it, it'd save me some grief; however, I need the command to wait for task completion and correctly report the error code. The pipeline is currently always reporting success, which is a non-starter. If I do use --follow the Codebuild project says it the task never reaches a ready-state.

Thanks!

【问题讨论】:

    标签: docker dockerfile aws-codepipeline aws-copilot aws-copilot-cli


    【解决方案1】:

    Sorry about the delay.

    The exit code being returned when you use the --follow flag is that of the task. I believe that without the --follow flag, the exit code is that of the overarching process.

    See the request here: https://github.com/aws/copilot-cli/issues/2525 and the implementation here: https://github.com/aws/copilot-cli/pull/3620. There are some interesting ideas in the issue discussion that may help you use the command in your CI/CD pipeline.

    【讨论】:

      猜你喜欢
      • 2016-03-02
      • 2014-05-01
      • 1970-01-01
      • 2022-12-27
      • 2022-08-11
      • 1970-01-01
      • 2022-12-01
      • 2022-12-01
      • 2020-06-22
      相关资源
      最近更新 更多