kubernetes/kops · error

lifecycle set to ExistsAndValidates, but object was not foun

Error message

lifecycle set to ExistsAndValidates, but object was not found

What it means

In the generic fi task engine, Render checks lifecycle assertions: with lifecycle ExistsAndValidates, the existing (actual) object must be present and must match desired state. If the actual object `a` is nil — i.e. nothing exists in the cloud/API — the assertion cannot be satisfied and kops returns this error instead of creating the object.

Source

Thrown at upup/pkg/fi/context.go:149

	}
	return e.RunTasks(c.ctx, c.tasks)
}

// Render dispatches the creation of an object to the appropriate handler defined on the Task,
// it is typically called after we have checked the existing state of the Task and determined that is different
// from the desired state.
func (c *Context[T]) Render(a, e, changes Task[T]) error {
	typeContextPtr := reflect.TypeOf((*Context[T])(nil))
	var lifecycle Lifecycle
	if hl, ok := e.(HasLifecycle); ok {
		lifecycle = hl.GetLifecycle()
	}

	if lifecycle != "" {
		if reflect.ValueOf(a).IsNil() {
			switch lifecycle {
			case LifecycleExistsAndValidates:
				return fmt.Errorf("lifecycle set to ExistsAndValidates, but object was not found")
			case LifecycleExistsAndWarnIfChanges:
				return NewExistsAndWarnIfChangesError("Lifecycle set to ExistsAndWarnIfChanges and object was not found.")
			}
		} else {
			switch lifecycle {
			case LifecycleExistsAndValidates, LifecycleExistsAndWarnIfChanges:

				out := os.Stderr
				changeList, err := buildChangeList(a, e, changes)
				if err != nil {
					return err
				}

				b := &bytes.Buffer{}
				taskName := getTaskName(e)
				fmt.Fprintf(b, "Object from different phase did not match, problems possible:\n")
				fmt.Fprintf(b, "  %s/%s\n", taskName, "?")
				for _, change := range changeList {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Recreate the missing object (rerun the appropriate phase with a create/warn lifecycle) so the object exists before asserting ExistsAndValidates.
  2. Relax the lifecycle for that task, e.g. `--lifecycle exists-and-warn-if-changes` or the normal Sync lifecycle.
  3. Re-run `kops update cluster` to reconcile/repair the drift, then re-run the validating phase.

Example fix

# before
kops update cluster <name> --lifecycle-existence-checks  # fails: object gone
# after
kops update cluster <name>  # reconcile and recreate missing objects first
Defensive patterns

Strategy: validation

Validate before calling

// verify the object exists in the cloud before running exists-and-validates
if _, err := lookupCloudObject(name); err != nil { recreateObject() }

Try / catch

err := kopsUpdate(...)
if err != nil && strings.Contains(err.Error(), "ExistsAndValidates, but object was not found") {
    // recreate missing object with default lifecycle, then re-validate
}

Prevention

When it happens

Trigger: Running a phase/update with a task whose lifecycle is ExistsAndValidates but the underlying cloud object was deleted externally or never created, so the 'actual' Task is nil when Render is dispatched by defaultDeltaRunMethod.

Common situations: A resource was manually deleted in the cloud console between `kops update cluster --lifecycle-existence-checks` runs; targeting a cluster whose resources were partially torn down; strict existence-validation mode (used by kops-controller / phases like exists-and-validates) on a fresh cluster.

Related errors


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