hashicorp / hashicorp/nomad

Allow extra/unknown fields in the job definition

Open
#6,943 2 comments 0 reactions 0 assignees View on GitHub
theme/jobspec type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

Hi folks,

This is a feature request.

We're looking into building on top of Nomad and one the challenges we're having is not having the open to pass extra fields we want the HCL definitions **besides** `meta` (which only takes strings).

I remember it was possible as [Libra](https://github.com/underarmour/libra) made heavy use of it. Here's an example of what we mean:

```hcl
job "nginx-prod" {
// For group "nginx"
group "nginx" {
// (required) The minimum nuber of tasks to run for this job
min_count = 1

// (required) The maximum number of tasks to run for this job
max_count = 3

// Scale by a rule
rule "cloudwatch asg cpu usage upper bound" {
// (required) What backend to use, this will define which configuration
// is valid and which checks you can execute
backend = "test-backend"

// (required) The CloudWatch dimension name and value
dimension_name = "AutoScalingGroupName"
dimension_value = "infra-httpapi-asg"

// (required) The CloudWatch metric name and namespace
metric_namespace = "AWS/EC2"
metric_name = "CPUUtilization"
[..]
}
}

We're currently "stuck" with `meta` only allowing strings which is not great for the DSL:

```hcl
meta {
"rule.cloudwatch_asg_cpu_usage_upper_bound.backend = "test-backend"
"rule.cloudwatch_asg_cpu_usage_upper_bound.dimension_name = "AutoScalingGroupName"
"rule.cloudwatch_asg_cpu_usage_upper_bound.dimension_value = "infra-httpapi-asg"
"rule.cloudwatch_asg_cpu_usage_upper_bound.metric_namespace = "AWS/EC2"
"rule.cloudwatch_asg_cpu_usage_upper_bound.metric_name = "CPUUtilization"
}
```

Could a flag on the server endpoints allowing unknown fields to be passed possibly be added?

Hopefully it makes sense,

Let us know, thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing Nomad's server endpoints and the HCL job-definition handling described in the issue, including how meta fields are currently represented. Determine where unknown fields are rejected and how a server-side option could control that behavior. Done means the requested extra fields can be passed through without requiring the meta workaround, with the behavior covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.