hashicorp/nomad · error

MinHealthyTime is %s and must be >= 0

Error message

MinHealthyTime is %s and must be >= 0

What it means

MigrateStrategy.Validate rejects a negative MinHealthyTime. MinHealthyTime is how long an allocation must be healthy before it counts toward the healthy threshold during migration; negative durations are invalid. This is a straightforward non-negativity guard in the strategy validator.

Source

Thrown at nomad/structs/structs.go:6855

	var mErr multierror.Error

	if m.MaxParallel < 0 {
		_ = multierror.Append(&mErr, fmt.Errorf("MaxParallel must be >= 0 but found %d", m.MaxParallel))
	}

	switch m.HealthCheck {
	case MigrateStrategyHealthChecks, MigrateStrategyHealthStates:
		// ok
	case "":
		if m.MaxParallel > 0 {
			_ = multierror.Append(&mErr, fmt.Errorf("Missing HealthCheck"))
		}
	default:
		_ = multierror.Append(&mErr, fmt.Errorf("Invalid HealthCheck: %q", m.HealthCheck))
	}

	if m.MinHealthyTime < 0 {
		_ = multierror.Append(&mErr, fmt.Errorf("MinHealthyTime is %s and must be >= 0", m.MinHealthyTime))
	}

	if m.HealthyDeadline < 0 {
		_ = multierror.Append(&mErr, fmt.Errorf("HealthyDeadline is %s and must be >= 0", m.HealthyDeadline))
	}

	if m.MinHealthyTime > m.HealthyDeadline {
		_ = multierror.Append(&mErr, fmt.Errorf("MinHealthyTime must be less than HealthyDeadline"))
	}

	return mErr.ErrorOrNil()
}

// TaskGroup is an atomic unit of placement. Each task group belongs to
// a job and may contain any number of tasks. A task group support running
// in many replicas using the same configuration..
type TaskGroup struct {
	// Name of the task group

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set min_healthy_time to a non-negative duration (e.g. "30s", the common default).
  2. Fix any template expression producing a negative duration.
  3. Omit the field to rely on sane defaults if your tooling allows.
  4. Validate locally with `nomad job validate`.

Example fix

// before
update {
  min_healthy_time = "-5s"
}
// after
update {
  min_healthy_time = "30s"
}
Defensive patterns

Strategy: validation

Validate before calling

func validMinHealthyTime(m *structs.MigrateStrategy) error {
	if m.MinHealthyTime < 0 {
		return fmt.Errorf("min_healthy_time must be >= 0, got %s", m.MinHealthyTime)
	}
	return nil
}

Type guard

func hasNonNegativeMinHealthyTime(m *structs.MigrateStrategy) bool {
	return m.MinHealthyTime >= 0
}

Try / catch

if err := strategy.Validate(); err != nil {
	if strings.Contains(err.Error(), "MinHealthyTime is") {
		// reset min_healthy_time to a non-negative default like 30s
	}
}

Prevention

When it happens

Trigger: Submitting a job with update block where min_healthy_time is negative (e.g. min_healthy_time = "-5s"), typically from templating or bad parsing of durations.

Common situations: Templated durations computed from negative inputs; accidental sign in HCL; misconfigured defaults in generated job specs.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/3ceed79d93cfe186. Report an issue: GitHub.