Separate thread from the one above but the same er...
# deployment-ecs
m
Separate thread from the one above but the same error ^^ I have multiple code locations, defined by separate compose files. One deployment of docker-compose.shared.yaml • Dagit and Daemon
N
deployments of docker-compose.sandbox.yaml • User Code dagster.yaml
Copy code
run_launcher:
  module: dagster_aws.ecs
  class: EcsRunLauncher
  config:
    container_name: "user_code"
Task definition defined by docker-compose.sandbox.yaml
Copy code
{
    "taskDefinitionArn": "arn:aws:ecs:ca-central-1:<ACCOUNT>:task-definition/dagster-mitch-user_code:7",
    "containerDefinitions": [
        {
            "name": "Usercode_Secrets_InitContainer",
            "image": "docker/ecs-secrets-sidecar:1.0",
            ...
        },
        {
            "name": "Usercode_ResolvConf_InitContainer",
            "image": "docker/ecs-searchdomain-sidecar:1.0",
            ...
        },
        {
            "name": "user_code",
            "image": "<ACCOUNT>.dkr.ecr.<REGION>.<http://amazonaws.com/deploy_ecs/user_code:latest@sha256:<HASH|amazonaws.com/deploy_ecs/user_code:latest@sha256:<HASH>>",
            ...
        },
    ]
}
Everything works fine! But when I try to launch a run I get this:
Copy code
dagster._check.ParameterCheckError: Param "image" is not a str. Got None which is type <class 'NoneType'>.
  File "/usr/local/lib/python3.10/site-packages/dagster/_daemon/run_coordinator/queued_run_coordinator_daemon.py", line 335, in _dequeue_run
    instance.run_launcher.launch_run(
  File "/usr/local/lib/python3.10/site-packages/dagster_aws/ecs/launcher.py", line 330, in launch_run
    run_task_kwargs = self._run_task_kwargs(run, image, container_context)
  File "/usr/local/lib/python3.10/site-packages/dagster_aws/ecs/launcher.py", line 513, in _run_task_kwargs
    task_definition_config = DagsterEcsTaskDefinitionConfig.from_task_definition_dict(
  File "/usr/local/lib/python3.10/site-packages/dagster_aws/ecs/tasks.py", line 120, in from_task_definition_dict
    return DagsterEcsTaskDefinitionConfig(
  File "/usr/local/lib/python3.10/site-packages/dagster_aws/ecs/tasks.py", line 53, in __new__
    check.str_param(image, "image"),
  File "/usr/local/lib/python3.10/site-packages/dagster/_check/__init__.py", line 1363, in str_param
    raise _param_type_mismatch_exception(obj, str, param_name, additional_message)
s
We have a similar setup and (dagit + daemon shared and several separate code repos) and here’s how it was solved for us: https://dagster.slack.com/archives/C014UDS8LAV/p1673453399422949?thread_ts=1673033125.274559&amp;cid=C014UDS8LAV
m
Lovely!! Thanks. I’ll give that a try. Out of curiosity, how do you setup your
workspace.yaml
, is it manual?
s
Almost manual. We just pass code repo names + their ports as comma-separated env vars and a small script takes those env vars, breaks them down and pushes them into a template of
workspace.yaml
to create the final
workspace.yaml
(before dagster is run)
m
Are you using CloudMap via docker compose?
s
No, we aren’t.
👍 1
m
I’ve got really scuff service discovery working that generates the workspace.yaml from services that are announced there, then DNS takes care of it and I wondered if you’d like the code. I might make a gist for it later when it’s done
❤️ 1
In my Dockerfile’s entrypoint for `user_code`:
Copy code
export DAGSTER_CONTAINER_CONTEXT='{"ecs":{"task_definition_arn":"arn:aws:ecs:ca-central-1:<ACCOUNT>:task-definition/dagster-mitch-user_code:8","container_name":"user_code"}}'
My dagster.yaml:
Copy code
run_launcher:
  module: dagster_aws.ecs
  class: "EcsRunLauncher"
  config:
    include_sidecars: true
    run_task_kwargs:
      launchType: "FARGATE"
      networkConfiguration:
        awsvpcConfiguration:
          securityGroups:
            - <SEC GROUP>
          subnets:
            - <PRIVATE SUBNET>
            - <PRIVATE SUBNET>
And this in my task definition:
Copy code
{
    "taskDefinitionArn": "arn:aws:ecs:ca-central-1:<ACCOUNT>:task-definition/dagster-mitch-user_code:8",
    "containerDefinitions": [
        {
            "name": "user_code",
            "image": "<ACCOUNT>.<http://dkr.ecr.ca-central-1.amazonaws.com/deploy_ecs/user_code:latest@sha256:<HASH|dkr.ecr.ca-central-1.amazonaws.com/deploy_ecs/user_code:latest@sha256:<HASH>>",
But when I try to materialize an asset I still get
Param "image" is not a str.
. Any advice?
If it helps at all, it looks like it’s reading the task definition of the daemon in cloudtrail? Not sure why.
c
Solved the above error by setting
DAGSTER_CURRENT_IMAGE
on my code location task.
Thanks for the code on service discovery. That's next on my list.
m
Haha! That did it! Thanks!