{"record":{"id":"4166dc0c3578f9d2","repo":"kubernetes/kops","slug":"clientset-is-not-initialized","errorCode":null,"errorMessage":"clientset is not initialized","messagePattern":"clientset is not initialized","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/kops-controller/main.go","lineNumber":273,"sourceCode":"\n\tif opt.EnableCloudIPAM {\n\t\tif err := setupCloudIPAM(ctx, mgr, &opt); err != nil {\n\t\t\tsetupLog.Error(err, \"unable to setup cloud IPAM\")\n\t\t\tos.Exit(1)\n\n\t\t}\n\t}\n\n\tif err := addNodeController(ctx, mgr, &opt); err != nil {\n\t\tsetupLog.Error(err, \"unable to create controller\", \"controller\", \"NodeController\")\n\t\tos.Exit(1)\n\t}\n\n\t// +kubebuilder:scaffold:builder\n\n\tif opt.CAPI.IsEnabled() {\n\t\tif clientset == nil {\n\t\t\tsetupLog.Error(fmt.Errorf(\"clientset is not initialized\"), \"registering Cluster API controllers\")\n\t\t\tos.Exit(1)\n\t\t}\n\t\tif err := clusterapi.RegisterControllers(mgr, clientset); err != nil {\n\t\t\tsetupLog.Error(err, \"registering Cluster API controllers\")\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\tsetupLog.Info(\"starting manager\")\n\tif err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {\n\t\tsetupLog.Error(err, \"problem running manager\")\n\t\tos.Exit(1)\n\t}\n}\n\nfunc buildScheme(opt *config.Options) (*runtime.Scheme, error) {\n\tscheme := runtime.NewScheme()\n\tif err := corev1.AddToScheme(scheme); err != nil {","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops-controller/main.go#L255-L291","documentation":"The kops-controller main function guards against a nil Kubernetes clientset when Cluster API (CAPI) support is enabled. If CAPI is on but clientset construction failed earlier (or was skipped), main logs this and exits with status 1.","triggerScenarios":"opt.CAPI.IsEnabled() is true while the clientset variable remains nil — the clientset creation code path failed or was not reached before controller registration.","commonSituations":"Misconfigured --cluster-api flag combined with a kubeconfig error that silently skipped clientset construction, or a code-path regression in main where clientset init is conditional.","solutions":["Check earlier startup logs for the clientset creation failure that left it nil","Verify kubeconfig/InClusterConfig is valid and mounted","If CAPI is not intended, unset the --cluster-api flag","File a bug if clientset init succeeded but the variable is still nil"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if opt.CAPI.IsEnabled() && clientset == nil {\n\tsetupLog.Error(fmt.Errorf(\"clientset is not initialized\"), \"registering Cluster API controllers\")\n\tos.Exit(1)\n}\n","typeGuard":"if clientset == nil {\n\t// fail fast before RegisterControllers\n}\n","tryCatchPattern":null,"preventionTips":["Verify kubeconfig is valid/mounted before enabling --cluster-api","Check clientset construction errors early in main and exit with a clear message","Keep the nil-check guard in place for all CAPI paths"],"tags":["kubernetes","cluster-api","startup","configuration"],"backgroundTag":"nil-clientset-at-startup","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"}