{"record":{"id":"28cfe5740e541fef","repo":"kubernetes/kops","slug":"error-building-containerd-flags-v","errorCode":null,"errorMessage":"error building containerd flags: %v","messagePattern":"error building containerd flags: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/containerd.go","lineNumber":297,"sourceCode":"\t\t\t// We need to restart kops-configuration service since nodeup needs to load images\n\t\t\t// into containerd with the new config. We restart in the background because\n\t\t\t// kops-configuration is of type \"one-shot\", so the restart command will wait for\n\t\t\t// nodeup to finish executing.\n\t\t\t{\"systemctl\", \"restart\", \"kops-configuration.service\", \"&\"},\n\t\t},\n\t})\n}\n\n// buildSysconfigFile is responsible for creating the containerd sysconfig file\nfunc (b *ContainerdBuilder) buildSysconfigFile(c *fi.NodeupModelBuilderContext) error {\n\tvar containerd kops.ContainerdConfig\n\tif b.NodeupConfig.ContainerdConfig != nil {\n\t\tcontainerd = *b.NodeupConfig.ContainerdConfig\n\t}\n\n\tflagsString, err := flagbuilder.BuildFlags(&containerd)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building containerd flags: %v\", err)\n\t}\n\n\tlines := []string{\n\t\t\"CONTAINERD_OPTS=\" + flagsString,\n\t}\n\tcontents := strings.Join(lines, \"\\n\")\n\n\tc.AddTask(&nodetasks.File{\n\t\tPath:     \"/etc/sysconfig/containerd\",\n\t\tContents: fi.NewStringResource(contents),\n\t\tType:     nodetasks.FileType_File,\n\t})\n\n\treturn nil\n}\n\n// buildConfigFile is responsible for creating the containerd configuration file\nfunc (b *ContainerdBuilder) buildConfigFile(c *fi.NodeupModelBuilderContext) error {","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/containerd.go#L279-L315","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the underlying error after '%v' to identify which containerd flag/field failed to build","Review spec.containerd (flags, registries, config overrides) in the cluster manifest for invalid values and correct them","Regenerate the nodeup config with `kops update cluster` so it matches the current kOps version's flag schema","If a specific new containerd option triggers it, pin containerd version or file/upgrade against kOps for flagbuilder support"],"exampleFix":"# before (cluster.yaml, invalid flag value)\ncontainerd:\n  flags:\n    log-level: trace!!\n# after\ncontainerd:\n  flags:\n    log-level: info","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := b.buildSysconfigFile(c); err != nil {\n    if strings.Contains(err.Error(), \"error building containerd flags\") {\n        return fmt.Errorf(\"invalid containerd flag configuration in nodeup config: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep containerd flag values within documented ranges (e.g. log-level: debug|info|warn|error)","Test cluster spec changes with `kops update cluster --dry-run` before applying","Avoid hand-editing generated nodeup config flag fields","Upgrade kOps when adopting new containerd options so flagbuilder supports them"],"tags":["nodeup","containerd","flagbuilder"],"backgroundTag":"flag-build-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}