portainer/portainer · error

gracePeriodSeconds must be -1 or a positive number of second

Error message

gracePeriodSeconds must be -1 or a positive number of seconds

What it means

Error "gracePeriodSeconds must be -1 or a positive number of seconds" thrown in portainer/portainer.

Source

Thrown at api/http/handler/kubernetes/node.go:48

	// TimeoutSeconds is the overall time to wait for the drain to complete. Defaults to 60 when omitted.
	TimeoutSeconds *int `example:"60"`
	// GracePeriodSeconds overrides each pod's termination grace period. -1 uses the pod's own grace period.
	GracePeriodSeconds *int `example:"-1"`
	// IgnoreDaemonSets skips DaemonSet-managed pods, which would otherwise block the drain.
	IgnoreDaemonSets *bool `example:"true"`
	// DeleteEmptyDirData allows eviction of pods using emptyDir volumes, whose data is lost once the pod is deleted.
	DeleteEmptyDirData *bool `example:"true"`
	// DisableEviction forces the use of direct pod deletion instead of the eviction API, ignoring any configured PodDisruptionBudgets.
	DisableEviction *bool `example:"false"`
}

func (payload *drainNodePayload) Validate(r *http.Request) error {
	if payload.TimeoutSeconds != nil && *payload.TimeoutSeconds < 0 {
		return errors.New("timeoutSeconds must be zero or a positive number of seconds")
	}

	if payload.GracePeriodSeconds != nil && *payload.GracePeriodSeconds < -1 {
		return errors.New("gracePeriodSeconds must be -1 or a positive number of seconds")
	}

	return nil
}

func (payload *drainNodePayload) drainOptions() libkubectl.DrainOptions {
	opts := libkubectl.DefaultDrainOptions()
	if payload.Force != nil {
		opts.Force = *payload.Force
	}
	if payload.GracePeriodSeconds != nil {
		opts.GracePeriodSeconds = *payload.GracePeriodSeconds
	}
	if payload.IgnoreDaemonSets != nil {
		opts.IgnoreAllDaemonSets = *payload.IgnoreDaemonSets
	}
	if payload.DeleteEmptyDirData != nil {
		opts.DeleteEmptyDirData = *payload.DeleteEmptyDirData

View on GitHub (pinned to 17e74456ff)

When it happens

Trigger: Thrown at api/http/handler/kubernetes/node.go:48 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of portainer/portainer@17e74456ff (2026-08-26). Data as JSON: /api/errors/aada10828f70ff6d. Report an issue: GitHub.