kubernetes/kops · error

operation must not be nil

Error message

operation must not be nil

What it means

Defensive nil-check sentinel in waitForOp: a nil *compute.Operation was passed to the wait helper, meaning a caller received no operation object to wait on. This is a programming-error guard — GCE API calls that return operations should never hand nil here on the success path.

Source

Thrown at upup/pkg/fi/cloudup/gce/op.go:93

func waitForGlobalOp(client *compute.Service, op *compute.Operation) error {
	u, err := ParseGoogleCloudURL(op.SelfLink)
	if err != nil {
		return fmt.Errorf("error parsing operation URL %q: %v", op.SelfLink, err)
	}

	return waitForOp(op, func(operationName string) (*compute.Operation, error) {
		return client.GlobalOperations.Wait(u.Project, operationName).Do()
	})
}

func opIsDone(op *compute.Operation) bool {
	return op != nil && op.Status == "DONE"
}

func waitForOp(op *compute.Operation, getOperation func(operationName string) (*compute.Operation, error)) error {
	if op == nil {
		return fmt.Errorf("operation must not be nil")
	}

	if opIsDone(op) {
		return getErrorFromOp(op)
	}

	opStart := time.Now()
	opName := op.Name
	return wait.Poll(operationPollInterval, operationPollTimeoutDuration, func() (bool, error) {
		start := time.Now()
		// gce.operationPollRateLimiter.Accept()
		duration := time.Since(start)
		if duration > 5*time.Second {
			klog.Infof("pollOperation: throttled %v for %v", duration, opName)
		}
		pollOp, err := getOperation(opName)
		if err != nil {
			klog.Warningf("GCE poll operation %s failed: pollOp: [%v] err: [%v]", opName, pollOp, err)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the caller that produced the operation for a swallowed error
  2. Report as a kOps bug if triggered by a normal API flow
  3. Verify the preceding GCE API call actually succeeded
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gce/op.go:93 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/28b176617118e654. Report an issue: GitHub.