Hi all, after successfully utilizing an ecs:push w...
# ask-community
m
Hi all, after successfully utilizing an ecs:push workpool with my own provisioned AWS infrastructure to deploy my flow to and run it on the ecs cluster, I was curious about the new feature to let prefect provision the infrastructure 😃 Unfortunately, it doesn't work as expected. I created the ecs: push work pool as suggested (https://github.com/PrefectHQ/prefect/pull/11267) and after that I deployed my flow to it as usually, but without job-variables (since I don't have to ingest the AWS infrastructure and role arns now). I want to push the flow image to my ecr repo, so I give this with the name of the image to my Deployment like this:
Copy code
flow.deploy(
    ...
    image=DeploymentImage(
        name=os.getenv("ECR_REPO_URL", ""),
        tag=os.getenv("IMAGE_TAG"),
        dockerfile=cfd / "Dockerfile",
    ),
    ...
)
But then I get the error: Flow run could not be submitted to infrastructure: An error occurred (ClientException) when calling the RegisterTaskDefinition operation: Fargate requires task definition to have execution role ARN to support ECR images. Why do I still have to provision the deployment with an execution role, shouldn't it (or the work pool) create one? Or is it because it is a my own ECR Repo? Where do you usually push / save the flow image to run it on the ecs cluster (especially in the frame of the ecs:push work pool with infra provisioning)? Thank you and best regards!
🤔 1
1
Just wondering: with my own aws infrastructure and prefect ecs push work pool I needed to assign the ManagedPolicyArns: "arnawsiam:awspolicy/service-role/AmazonECSTaskExecutionRolePolicy" to the iam execution role (like here ) I skimmed the source code of the current prefect infrastructure provisioning for ecs : no iam role is created, the policies are attached directly to the iam user, but the arnawsiam:awspolicy/service-role/AmazonECSTaskExecutionRolePolicy is not attached ... so in fact the following policies are missing to access the ecr: "ecr:GetAuthorizationToken", "ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", ...
Hey @justabill, since you posted this cool news about creating an ecs:push work pool which is able to create its own infrastructure (--provision-infra): What is your usual use case? Where should I push/ save the flow image through to make the approach work (if not to ecr?!)? Is it intended that you have to create and asign the execution role yourself? Sorry for bothering you, regards!
Hey all 👋, please - could someone give me a hint, how to use the new ecs:push --provision-infra feature? As stated above I created the work pool, but when I deploy my flow to it, I get the error: Error: Flow run could not be submitted to infrastructure: An error occurred (ClientException) when calling the RegisterTaskDefinition operation: Fargate requires task definition to have execution role ARN to support ECR images My Question: Where should I push the flow image through to make the approach work (if not to ecr)? Is it intended that you have to create and asign the execution role yourself? Regards!
1
j
Hi Mira! You’ll need to have the AWS CLI library downloaded and be authenticated with your AWS account. Then you can run
prefect work-pool create
with the
—provision-infra
flag and the wizard should walk you through the rest. There’s a guide here that should help: https://github.com/PrefectHQ/prefect/pull/11316/files
Then you’ll need to deploy your flow, the
prefect deploy
CLI command can walk you through that.
m
Hi @Jenny, thank you for your answer 🙂 As mentioned above, it was no problem to create the work pool, after creating it via cli, it is listed in the work pool section in prefect cloud and also the new aws credentials block which is asigned to it. I then deploy my flow to it and when I hit the quick run button, it gives me the following error : "Flow run could not be submitted to infrastructure: An error occurred (ClientException) when calling the RegisterTaskDefinition operation: Fargate requires task definition to have execution role ARN to support ECR images." All the other infrastructure components get created and I can see them in aws. So my question is: what am I doing wrong? Do I have to create and assign the execution role myself, or should I push my flow image somewhere else (with my deployment) than ecr?
j
Ah yeah I just saw your original post and (as you probably also do) suspect it’s that custom image. Provision-infra is currently aimed at helping users get started with our public docker images. I expect there’ll be work in the future that expands use cases but for now I think you’re better creating your own role or running flow.deploy without a custom image.
🙌 1
m
Ah, ok, thank you so much for taking the time to look into my question 👍 Have a nice weekend 👋
j
Thank you. You too!
And do open an issue if you think this is something it would help for us to support!
m
Hey all, it feels a bit silly, but I have to ask again, sorry 😅 I am still trying to get the --provision-infra option for ecs:push work pools to work ... What I tried: ( - pushing the docker image to ecr (private) -> Error: Fargate requires task definition to have execution role ARN to support ECR images.) • pushing the docker image to ecr public:
Copy code
Flow run could not be submitted to infrastructure: TaskFailedToStart - CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref public.ecr.aws/r1j4r6c7/prefect_ecr:my-custom-build: failed to do request: Head "<https://public.ecr.aws/v2/r1j4r6c7/prefect_ecr/manifests/my-custom-build>": dial tcp 99.83.145.10:443: i/o timeout
• pushing the image to DockerHub (public):
Copy code
Flow run could not be submitted to infrastructure: TaskFailedToStart - CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref docker.io/my-user/dataflow_test:my-custom-build: failed to do request: Head "<https://registry-1.docker.io/v2/my-user/dataflow_test/manifests/my-custom-build>": dial tcp 54.227.20.253:443: i/o timeout
what do you mean by "aimed at helping users get started with our public docker images", what am I doing wrong? I think the inet gateway should be assigned, so why does it have no access? Since the infrastructure gets created by prefect, I am not aware of what I could have done wrong ... how do you deploy your flow to the provision-infra work pool (and where do you push the image)?
d
I'm having the same issue here. Anyone have luck getting a push pool task on ECS to use an image from ECR?
From what I've read it seems like we need to use VPC Gateway in AWS if we're using a private VPC
j
Hi Mira! Sorry to hear you’re still struggling. It looks like you have a connectivity error there along with the permissions one for ECR. For using ECR, we have a PR up that’s aimed at helping: https://github.com/PrefectHQ/prefect/pull/11382 That’s only available on main for now but look out for more details in upcoming releases. I’d love to have you come back and tell us if it helps you.
a
@mira Support for creating an ECR registry is available in 2.14.11! You can run
prefect work-pool provision-infra
for your existing work pool and it will create an ECR repository that is fully set up to use with a ECS push work pool. Let me know if you run into any issues with it!
🙏 1
m
Hey @alex, very cool 👍, thank you for notifying me ! I found also the new docs on this, thanks a lot!
267 Views