kubernetes/kops · error

error building containerd flags: %v

Error message

error building containerd flags: %v

What it means

buildSysconfigFile renders /etc/sysconfig/containerd (or /etc/default/containerd) by serializing the containerd command-line flags with flagbuilder.BuildFlags. If flag building fails (e.g. a field value cannot be converted to a flag), the error is wrapped as 'error building containerd flags: %v' at nodeup/pkg/model/containerd.go:297. It propagates up from installContainerd to Build.

Source

Thrown at nodeup/pkg/model/containerd.go:297

			// We need to restart kops-configuration service since nodeup needs to load images
			// into containerd with the new config. We restart in the background because
			// kops-configuration is of type "one-shot", so the restart command will wait for
			// nodeup to finish executing.
			{"systemctl", "restart", "kops-configuration.service", "&"},
		},
	})
}

// buildSysconfigFile is responsible for creating the containerd sysconfig file
func (b *ContainerdBuilder) buildSysconfigFile(c *fi.NodeupModelBuilderContext) error {
	var containerd kops.ContainerdConfig
	if b.NodeupConfig.ContainerdConfig != nil {
		containerd = *b.NodeupConfig.ContainerdConfig
	}

	flagsString, err := flagbuilder.BuildFlags(&containerd)
	if err != nil {
		return fmt.Errorf("error building containerd flags: %v", err)
	}

	lines := []string{
		"CONTAINERD_OPTS=" + flagsString,
	}
	contents := strings.Join(lines, "\n")

	c.AddTask(&nodetasks.File{
		Path:     "/etc/sysconfig/containerd",
		Contents: fi.NewStringResource(contents),
		Type:     nodetasks.FileType_File,
	})

	return nil
}

// buildConfigFile is responsible for creating the containerd configuration file
func (b *ContainerdBuilder) buildConfigFile(c *fi.NodeupModelBuilderContext) error {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the underlying error after '%v' to identify which containerd flag/field failed to build
  2. Review spec.containerd (flags, registries, config overrides) in the cluster manifest for invalid values and correct them
  3. Regenerate the nodeup config with `kops update cluster` so it matches the current kOps version's flag schema
  4. If a specific new containerd option triggers it, pin containerd version or file/upgrade against kOps for flagbuilder support

Example fix

# before (cluster.yaml, invalid flag value)
containerd:
  flags:
    log-level: trace!!
# after
containerd:
  flags:
    log-level: info
Defensive patterns

Strategy: try-catch

Try / catch

if err := b.buildSysconfigFile(c); err != nil {
    if strings.Contains(err.Error(), "error building containerd flags") {
        return fmt.Errorf("invalid containerd flag configuration in nodeup config: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: flagbuilder.BuildFlags fails on the ContainerdConfig struct copied from NodeupConfig — practically this occurs when a user-supplied containerd flag/option value (e.g. a custom flag added via containerd flags configuration) cannot be rendered into the flags string by the flagbuilder library.

Common situations: Unusual or invalid values in containerd config/flags fields in the cluster spec, kOps/flagbuilder incompatibility with a newly introduced containerd option, or a corrupted/stale nodeup config where a flag field holds an unexpected value.

Related errors


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