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

Make distinct_hosts as a variable not working #13861

Closed
panjiang opened this issue Jul 20, 2022 · 1 comment · Fixed by #16907
Closed

Make distinct_hosts as a variable not working #13861

panjiang opened this issue Jul 20, 2022 · 1 comment · Fixed by #16907

Comments

@panjiang
Copy link

I want to disable distinct_hosts in certain env, but it not working as expected.

  • Template
job "" {
  constraint {
    operator  = "distinct_hosts"
    value     = var.distinct_hosts
  }
}

variable "distinct_hosts" {
  description = "This job should be scheduled on different hosts"
  type        = string
  default     = "true"
}
  • Usage
distinct_hosts = "false"

Then I find the source code, is not reading the value config.

func (iter *DistinctHostsIterator) hasDistinctHostsConstraint(constraints []*structs.Constraint) bool {
	for _, con := range constraints {
		if con.Operand == structs.ConstraintDistinctHosts {
			return true
		}
	}

	return false
}
@Amier3 Amier3 added this to Needs Triage in Nomad - Community Issues Triage via automation Jul 21, 2022
@angrycub angrycub self-assigned this Jul 22, 2022
@angrycub
Copy link
Contributor

@panjiang Thanks for the report. I'm looking into the issue. It appears that in the original jobspec parser in the CLI would filter out cases where the distinct_hosts constraint was set to false. This could explain why the feasibility check does not consult the value passed.

However, as you noted, when using jobspec2—the HCL2 version of the jobspec—the value is not being dropped from the parsed JSON and is being incorrectly observed by the feasibility check. This also would appear to impact users who are submitting jobs to the cluster using the JSON-jobspec directly.

I'm still looking into the issue and will add more to the issue as I learn more.

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

Successfully merging a pull request may close this issue.

2 participants