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

Problem with multiservice task #455

Open
perrfect opened this issue Jun 20, 2022 · 1 comment
Open

Problem with multiservice task #455

perrfect opened this issue Jun 20, 2022 · 1 comment

Comments

@perrfect
Copy link

perrfect commented Jun 20, 2022

Hello.
I use Levant v0.3.1 and test multiservice task via var-file.

My var-file for multiservice task looks like:

"tasks": [
      {
        "first_task_name": {
          "config": {
            "image": "test"
          },
          "resources": {
            "cpu": 100,
            "memory": 256
          }
        },
        "second_task_name": {
          "config": {
            "image": "test"
          },
          "resources": {
            "cpu": 100,
            "memory": 256
          }
        }
      }
    ]

job.nomad looks like:

    task "[[ .job.tasks ]]" {
      driver = "docker"

      resources {
        cpu = [[ .job.tasks.resources.cpu ]]
        memory = [[ .job.tasks.resources.memory ]]
      }

And I run my job.nomad file:

levant plan -log-level=debug -var-file=vars.json -address='${env.NOMAD_URL}' job.nomad

But getting the error:

[ERROR] levant/command: template: jobTemplate:113:21: executing "jobTemplate" at <.job.tasks.resources.cpu>: can't evaluate field resources in type interface {}

I don't understand where is a mistake and why json doesn't parse correctly.
Please help me.
Thank you.

@hiddewie
Copy link

.job.tasks is an array, so you cannot call a field on an array.

You can loop over the array with range .job.tasks and then use .resources.cpu within the range.

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

No branches or pull requests

2 participants