kubernetes/kops · error

error building context: %w

Error message

error building context: %w

What it means

After building the target, Run() constructs a fi.NodeupContext holding the target, keystore, boot config, nodeup config, and task map. If NewNodeupContext fails (invalid or inconsistent inputs, nil/invalid keystore, bad config structure), the error is wrapped as "error building context". Bootstrap cannot proceed without a valid context.

Source

Thrown at upup/pkg/fi/nodeup/command.go:379

	var target fi.NodeupTarget

	switch c.Target {
	case "direct":
		target = &local.LocalTarget{
			CacheDir: c.CacheDir,
			Cloud:    cloud,
		}
	case "dryrun":
		assetBuilder := assets.NewAssetBuilder(vfs.Context, nil, false)
		target = fi.NewNodeupDryRunTarget(assetBuilder, out)
	default:
		return fmt.Errorf("unsupported target type %q", c.Target)
	}

	context, err := fi.NewNodeupContext(ctx, target, keyStore, &bootConfig, &nodeupConfig, taskMap)
	if err != nil {
		return fmt.Errorf("error building context: %w", err)
	}

	var options fi.RunTasksOptions
	options.InitDefaults()

	// Return rather than exit, so that the retry loop in cmd/nodeup gets to run:
	// kops-configuration.service is Type=oneshot, so a bootstrap that exits here is never
	// retried and the node never joins the cluster.
	err = context.RunTasks(options)
	if err != nil {
		return fmt.Errorf("error running tasks: %w", err)
	}

	err = target.Finish(taskMap)
	if err != nil {
		return fmt.Errorf("error closing target: %w", err)
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the wrapped error (%w) for the specific validation that failed
  2. Verify the nodeup bootstrap and nodeup config files on the node are complete and freshly rendered (`kops update cluster --yes` then re-provision)
  3. Ensure ConfigStore.Keypairs points to a valid keystore VFS path readable from the node
  4. Match nodeup binary version to the kops version that generated the config
Defensive patterns

Strategy: try-catch

Try / catch

if err := nodeupCmd.Run(ctx); err != nil {
    if strings.Contains(err.Error(), "error building context") {
        log.Fatalf("NodeupContext build failed: %v — verify nodeup.conf and keystore paths", err)
    }
    return err
}

Prevention

When it happens

Trigger: fi.NewNodeupContext(ctx, target, keyStore, &bootConfig, &nodeupConfig, taskMap) returns an error — e.g. invalid boot/nodeup config fields, a nil or unusable KeyStore, or an inconsistent combination of the passed objects.

Common situations: Truncated or corrupt nodeup.conf / boot config dropped on the node by kops; keyStore never set because ConfigStore.Keypairs was empty in an unexpected code path; version mismatch where a newer nodeup expects config fields absent in an older-rendered config.

Related errors


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