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 config validate doesn't include command line flags in validation #25205

Open
gautamg795 opened this issue Feb 24, 2025 · 3 comments
Open

Comments

@gautamg795
Copy link

Nomad version

Output from nomad version
Nomad v1.8.4
BuildDate 2024-09-17T20:18:34Z
Revision 22ab32e

Operating system and Environment details

macOS 15.3.1 (though issue is not OS-specific)

Issue

Running nomad config validate doesn't work on a config.hcl file that contains both client {} and server {} blocks.
My understanding is that this is a valid configuration (we use it in production), and just launch the agent with the -client or -server flag as appropriate for the machine.

Reproduction steps

Expected Result

Config is validated

Actual Result

Must specify either server, client or dev mode for the agent.
Configuration is invalid

Job file (if appropriate)

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

@tgross
Copy link
Member

tgross commented Feb 25, 2025

Hi @gautamg795! I double checked this with a minimal configuration and I think what might be happening is you're missing the enabled = true flag on your server and client blocks. This configuration file passes config validate, but if I comment those lines out I get the error you're seeing:

data_dir = "/tmp"

server {
  enabled = true
}

client {
  enabled = true
}

Using the -server or -client flag enables those blocks in the same way that setting enabled = true does.

As an aside, we generally don't recommend having the server and client together, because the server uses resources your workloads will need, and the server doesn't have any way of capping resources it uses.

@gautamg795
Copy link
Author

Ah so we're not actually running server and client on the same machine -- we distribute this config file to every machine, then a startup script runs nomad with -client or -server based on machine tags

But I'm realizing this is actually pretty hard to solve, as any number of command line args to nomad can make or break the config file.

So maybe this is a feature request for nomad config validate to take an arbitrary number of arguments after a -- and then validate the config file in conjunction with those arguments?
So my config file with both server and client blocks (and no enabled) fails as-is, but would pass with nomad config validate config.hcl -- -server

@tgross tgross changed the title nomad config validate doesn't allow client and server config to coexist nomad config validate doesn't include command line flags in validation Feb 26, 2025
@tgross
Copy link
Member

tgross commented Feb 26, 2025

Ah, ok, I understand what you're trying to do now. Note that nomad config validate can accept multiple configuration files, just like nomad agent -config does. These files get merged together as described in configuration file load order and merging.

So typically what folks do is have multiple config files. Ex. base.hcl, server.hcl, and client.hcl. Then you can run:

  • nomad config validate base.hcl server.hcl and nomad agent -config base.hcl -config server.hcl for the instances where you're running a server
  • nomad config validate base.hcl client.hcl and nomad agent -config base.hcl -config client.hcl where you're running a client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants