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

Nomad tutorial sample job file not working #13186

Closed
mly32 opened this issue May 31, 2022 · 2 comments
Closed

Nomad tutorial sample job file not working #13186

mly32 opened this issue May 31, 2022 · 2 comments
Labels

Comments

@mly32
Copy link

mly32 commented May 31, 2022

Nomad version

Nomad v1.3.1

Operating system and Environment details

macOS 12.4 arm64 (MacBookPro18)

Issue

The tutorial's sample job file generated by nomad job init has a stanza that requires Consul; however, the tutorial has no mention of Consul.

The job fails to place allocations because Constraint "${attr.consul.version} semver >= 1.7.0": 1 nodes excluded by filter.

I found two methods to resolve this:

  1. Comment out part of the generated example.nomad file. Interestingly, generating the file with nomad job init -short does not include the stanza below, so the job runs fine if the shortened version is used.
    # comment this out
    service {
      name = "redis-cache"
      tags = ["global", "cache"]
      port = "db"
    }
  1. Run Consul on the side (consul agent -dev) and restart the Nomad agent and job.

Reproduction steps

Follow the tutorial (without running on a VM generated by the provided Vagrantfile because the VM does not work on M1 Macs).

# start the agent
sudo nomad agent -dev -bind 0.0.0.0 -log-level INFO
# generate the sample job
nomad job init
# run the job
nomad job run example.nomad

Expected Result

==> 2022-05-31T11:12:50-07:00: Monitoring evaluation "0890a4fe"
    2022-05-31T11:12:50-07:00: Evaluation triggered by job "example"
    2022-05-31T11:12:50-07:00: Evaluation within deployment: "6eadb641"
    2022-05-31T11:12:50-07:00: Allocation "218ee9a1" created: node "212cb895", group "cache"
    2022-05-31T11:12:50-07:00: Evaluation status changed: "pending" -> "complete"
==> 2022-05-31T11:12:50-07:00: Evaluation "0890a4fe" finished with status "complete"
==> 2022-05-31T11:12:50-07:00: Monitoring deployment "6eadb641"

Actual Result

==> 2022-05-31T11:03:44-07:00: Monitoring evaluation "9f103bd6"
    2022-05-31T11:03:44-07:00: Evaluation triggered by job "example"
    2022-05-31T11:03:44-07:00: Evaluation within deployment: "0b39702a"
    2022-05-31T11:03:44-07:00: Evaluation status changed: "pending" -> "complete"
==> 2022-05-31T11:03:44-07:00: Evaluation "9f103bd6" finished with status "complete" but failed to place all allocations:
    2022-05-31T11:03:44-07:00: Task Group "cache" (failed to place 1 allocation):
      * Constraint "${attr.consul.version} semver >= 1.7.0": 1 nodes excluded by filter
    2022-05-31T11:03:44-07:00: Evaluation "5a3da30c" waiting for additional capacity to place remainder
==> 2022-05-31T11:03:44-07:00: Monitoring deployment "0b39702a"

Job file (if appropriate)

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

@mly32 mly32 added the type/bug label May 31, 2022
@lgfa29
Copy link
Contributor

lgfa29 commented May 31, 2022

Hi @mly32, thanks for the detailed report.

This is a known issue that was fixed in #13044. The root cause is an additional validation that was added in Nomad 1.3.0 for Consul-based service discovery where Consul is not actually present. We unfortunately missed updating the long example.nomad job then.

For now you have a few options:

  • as you noticed, you can remove the service block if that doesn't impact your work
  • start a Consul dev agent (consul agent -dev)
  • use Nomad native service discovery by adding this line to the job:
    service {
      # ...
      provider = "nomad"
    }

I'm going to close this issue since we already have a fix, but let me know if you have any other concerns 🙂

@lgfa29 lgfa29 closed this as completed May 31, 2022
@github-actions
Copy link

github-actions bot commented Oct 7, 2022

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants