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

Duplicate job block error when using nomad-pack plan for cron jobs #579

Open
FirstPiterSky opened this issue Sep 30, 2024 · 1 comment
Open

Comments

@FirstPiterSky
Copy link

Description: We are encountering a 400 error when attempting to create tasks in Nomad using the nomad-pack plan command. The error is related to duplicate job blocks in the rendered job file.

Steps to Reproduce:

  • use any template to generate the job file:
[[ range $key, $ObjAll := var "jobs" . ]]
job "[[ var "job_prefix" $ ]]_cron_[[ $ObjAll.name ]]" {
~~~~~
[ [- end ]]
  • render command works successfully
./nomad-pack render ./cron --var-file="./cron/cron.hcl" --to-dir ./out
  • Run the following command:
./nomad-pack plan ./cron --var-file="./cron/cron.hcl"
  • Error message is as follows:
! Failed To Parse Job Specification

    Error:   Unexpected response code: 400 (Failed to parse job: input.hcl:164,1-48: Duplicate job block; Only one block of type "job" is allowed. Previous definition was at input.hcl:2,1-32.
input.hcl:326,1-59: Duplicate job block; Only one block of type "job" is allowed. Previous definition was at input.hcl:2,1-32.
input.hcl:488,1-34: Duplicate job block; Only one block of type "job" is allowed. Previous definition was at input.hcl:2,1-32.
~~~~~
input.hcl:3890,1-45: Duplicate job block; Only one block of type "job" is allowed. Previous definition was at input.hcl:2,1-32.
input.hcl:4052,1-45: Duplicate job block; Only one block of type "job" is allowed. Previous definition was at input.hcl:2,1-32.)
    Context: 
        - Template Name: fita_cron/templates/cron.nomad.tpl
        - Registry Name: <<local folder>>
        - Pack Name: cron
        - Pack Ref: <<none>>
        - Pack Path: /worckflow/fita/deploy/nomad/packs/cron
        - Deployment Name: cron

Expected Behavior: The job specification should be parsed and tasks should be created successfully in Nomad.

Actual Behavior: The command fails with a 400 error due to multiple "job" blocks in the generated file.

@pkazmierczak
Copy link
Contributor

Hi @FirstPiterSky, thanks for reporting this issue. We'll look into it!

@pkazmierczak pkazmierczak moved this from Needs Triage to Triaging in Nomad - Community Issues Triage Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants