grpc/grpc-go · error

OutlierDetectionLoadBalancingConfig.max_ejection_time = %s;

Error message

OutlierDetectionLoadBalancingConfig.max_ejection_time = %s; must be >= 0

What it means

Returned by outlier detection ParseConfig (internal/xds/balancer/outlierdetection/balancer.go:134) when the LBConfig `max_ejection_time` Duration field is negative. gRFC A50 requires this field to be non-negative; the default is 300s. It caps the computed ejection time so a large ejectionTimeMultiplier cannot eject an endpoint indefinitely.

Source

Thrown at internal/xds/balancer/outlierdetection/balancer.go:135

	// resource before parsing resource into JSON which this function gets
	// called with. A50 defines two separate places for these validations to
	// take place, the xdsclient and this ParseConfig method. "When parsing a
	// config from JSON, if any of these requirements is violated, that should
	// be treated as a parsing error." - A50
	switch {
	// "The google.protobuf.Duration fields interval, base_ejection_time, and
	// max_ejection_time must obey the restrictions in the
	// google.protobuf.Duration documentation and they must have non-negative
	// values." - A50
	// Approximately 290 years is the maximum time that time.Duration (int64)
	// can represent. The restrictions on the protobuf.Duration field are to be
	// within +-10000 years. Thus, just check for negative values.
	case lbCfg.Interval < 0:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.interval = %s; must be >= 0", lbCfg.Interval)
	case lbCfg.BaseEjectionTime < 0:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.base_ejection_time = %s; must be >= 0", lbCfg.BaseEjectionTime)
	case lbCfg.MaxEjectionTime < 0:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.max_ejection_time = %s; must be >= 0", lbCfg.MaxEjectionTime)

	// "The fields max_ejection_percent,
	// success_rate_ejection.enforcement_percentage,
	// failure_percentage_ejection.threshold, and
	// failure_percentage.enforcement_percentage must have values less than or
	// equal to 100." - A50
	case lbCfg.MaxEjectionPercent > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.max_ejection_percent = %v; must be <= 100", lbCfg.MaxEjectionPercent)
	case lbCfg.SuccessRateEjection != nil && lbCfg.SuccessRateEjection.EnforcementPercentage > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.SuccessRateEjection.enforcement_percentage = %v; must be <= 100", lbCfg.SuccessRateEjection.EnforcementPercentage)
	case lbCfg.FailurePercentageEjection != nil && lbCfg.FailurePercentageEjection.Threshold > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.FailurePercentageEjection.threshold = %v; must be <= 100", lbCfg.FailurePercentageEjection.Threshold)
	case lbCfg.FailurePercentageEjection != nil && lbCfg.FailurePercentageEjection.EnforcementPercentage > 100:
		return nil, fmt.Errorf("OutlierDetectionLoadBalancingConfig.FailurePercentageEjection.enforcement_percentage = %v; must be <= 100", lbCfg.FailurePercentageEjection.EnforcementPercentage)
	}
	return lbCfg, nil
}

View on GitHub (pinned to 03255a9237)

Solutions

  1. Set `max_ejection_time` to a non-negative Duration (omit to accept the 300s default)
  2. Correct the upstream xDS OutlierDetection resource
  3. Validate the policy before publishing it to the control plane

Example fix

// before
{"maxEjectionTime":"-300s"}
// after
{"maxEjectionTime":"300s"}
Defensive patterns

Strategy: validation

Validate before calling

var probe struct{ MaxEjectionTime string `json:"max_ejection_time"` }
_ = json.Unmarshal(raw, &probe)
if probe.MaxEjectionTime != "" {
    d, err := time.ParseDuration(probe.MaxEjectionTime)
    if err != nil || d < 0 {
        return fmt.Errorf("max_ejection_time must be >= 0, got %q", probe.MaxEjectionTime)
    }
}

Try / catch

lbCfg, err := outlierBB.ParseConfig(raw)
if err != nil {
    logger.Warningf("rejecting outlier detection config: %v", err)
    return fallbackLBConfig
}

Prevention

When it happens

Trigger: ParseConfig gets JSON whose `max_ejection_time` decodes to a negative Duration. Comes from hand-built configs, a buggy resolver, or a control plane emitting negative protobuf seconds.

Common situations: Control-plane typo sending a negative max ejection time; test configs with invalid durations; negative seconds from a bad Duration serialization.

Related errors


AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07). Data as JSON: /api/errors/3a9a0b3c164290b0. Report an issue: GitHub.