{"record":{"id":"4855ec586b9adcdd","repo":"kubernetes/kops","slug":"error-building-dns-scope-v-4855ec","errorCode":null,"errorMessage":"error building dns scope: %v","messagePattern":"error building dns scope: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns-controller/pkg/watchers/pod.go","lineNumber":47,"sourceCode":"\t\"k8s.io/klog/v2\"\n\t\"k8s.io/kops/dns-controller/pkg/dns\"\n\t\"k8s.io/kops/dns-controller/pkg/util\"\n\t\"k8s.io/kops/upup/pkg/fi/utils\"\n)\n\n// PodController watches for Pods with dns annotations\ntype PodController struct {\n\tutil.Stoppable\n\tclient    kubernetes.Interface\n\tnamespace string\n\tscope     dns.Scope\n}\n\n// NewPodController creates a podController\nfunc NewPodController(client kubernetes.Interface, dns dns.Context, namespace string) (*PodController, error) {\n\tscope, err := dns.CreateScope(\"pod\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error building dns scope: %v\", err)\n\t}\n\tc := &PodController{\n\t\tclient:    client,\n\t\tscope:     scope,\n\t\tnamespace: namespace,\n\t}\n\n\treturn c, nil\n}\n\n// Run starts the PodController.\nfunc (c *PodController) Run() {\n\tklog.Infof(\"starting pod controller\")\n\n\tstopCh := c.StopChannel()\n\tgo c.runWatcher(stopCh)\n\n\t<-stopCh","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/dns-controller/pkg/watchers/pod.go#L29-L65","documentation":"NewPodController returns \"error building dns scope: %v\" when dns.CreateScope(\"pod\") fails while constructing the PodController. The DNS scope is the per-resource namespace in the backing DNS provider context used to track pod alias records; if the provider cannot create it, the controller cannot be built at all. The wrapped error comes from the dnsprovider implementation (e.g. route53/weave provider) when initializing its zone/scope state.","triggerScenarios":"Calling NewPodController(client, dnsContext, namespace) where dns.Context.CreateScope(\"pod\") returns an error - typically because the DNS provider was not initialized correctly, the hosted zone/record set cannot be listed, or the provider returns an error from its CreateScope implementation.","commonSituations":"dns-controller started before the DNS provider is ready; AWS credentials missing/insufficient for Route53; the --dns flag points to a provider whose configuration is invalid; zone not yet provisioned in a freshly created cluster.","solutions":["Read the wrapped error after '%v' to identify the provider-level failure (auth, zone not found, etc.).","Verify --dns and --dns-gossip/zone configuration flags match a valid, existing hosted zone.","Check cloud DNS credentials (e.g. AWS Route53 permissions) available to the controller.","Ensure dnsproviders are initialized (InitDnsProvider succeeded) before watchers are created in initializeWatchers."],"exampleFix":"// before: starting controller with uninitialized dns context\npodController, err := NewPodController(client, nil, ns)\n// after: init provider first\ndnsProvider, err := dnsprovider.InitDnsProvider(providerName, configPath)\ndnsContext, err := dns.NewContext(dnsProvider)\npodController, err := NewPodController(client, dnsContext, ns)","handlingStrategy":"validation","validationCode":"// Go: validate the dns context before constructing the controller\nif dnsContext == nil {\n    return nil, errors.New(\"dns context must be initialized (InitDnsProvider + dns.NewContext) before NewPodController\")\n}","typeGuard":null,"tryCatchPattern":"pc, err := NewPodController(client, dnsContext, namespace)\nif err != nil {\n    if strings.Contains(err.Error(), \"error building dns scope\") {\n        klog.Errorf(\"DNS provider unavailable or misconfigured: %v\", err)\n        // fix provider config, then retry construction\n    }\n    return err\n}","preventionTips":["Initialize the DNS provider and context before creating watchers.","Validate --dns provider flags and cloud DNS credentials at startup.","Confirm the hosted zone exists before deploying dns-controller."],"tags":["dns-controller","dns-provider","configuration"],"backgroundTag":"dns-scope-init-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}