grpc/grpc-go · error

OutlierDetectionLoadBalancingConfig.base_ejection_time =

Error message

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

What it means

Per gRFC A50, OutlierDetectionLoadBalancingConfig.base_ejection_time must be a non-negative duration. ParseConfig checks lbCfg.BaseEjectionTime < 0 and rejects it (balancer.go:132-133). Should be unreachable in the xDS flow because xdsclient validates upstream.

Solutions

  1. Set base_ejection_time to a non-negative value (A50 default is 30s).
  2. Validate the duration before constructing the config.

Example fix

// before
cfg.BaseEjectionTime = iserviceconfig.Duration(-30 * time.Second)
// after
cfg.BaseEjectionTime = iserviceconfig.Duration(30 * time.Second)
Defensive patterns

Strategy: validation

Validate before calling

func validateBaseEjectionTime(d iserviceconfig.Duration) error {
    if d < 0 { return fmt.Errorf("base_ejection_time must be >= 0, got %s", d) }
    return nil
}

Prevention

When it happens

Trigger: lbCfg.BaseEjectionTime is negative after JSON unmarshaling (e.g. "base_ejection_time": "-30s").

Common situations: Hand-crafted config with a negative duration; typo; control plane misconfiguration that bypassed xdsclient validation.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/189f35a6f8b2113b. Report an issue: GitHub.

Appendix: source

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

	// Note: in the xds flow, these validations will never fail. The xdsclient
	// performs the same validations as here on the xds Outlier Detection
	// 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 0c51461d27)