{"record":{"id":"827f5f1ebcc43757","repo":"kubernetes/kops","slug":"error-pre-creating-dns-records-v","errorCode":null,"errorMessage":"error pre-creating DNS records: %v","messagePattern":"error pre-creating DNS records: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/dns.go","lineNumber":236,"sourceCode":"\t\t}\n\t\tif !foundTXT {\n\t\t\tif cluster.Spec.ExternalDNS != nil && cluster.Spec.ExternalDNS.Provider == kops.ExternalDNSProviderExternalDNS {\n\t\t\t\tdomain := recordKey.hostname\n\t\t\t\tif ip == kopsdns.PlaceholderIPv6 {\n\t\t\t\t\tdomain = \"aaaa-\" + domain\n\t\t\t\t}\n\t\t\t\tchangeset.Add(rrs.New(domain, []string{fmt.Sprintf(\"\\\"heritage=external-dns,external-dns/owner=kops-%s\\\"\", cluster.ObjectMeta.Name)}, PlaceholderTTL, rrstype.TXT))\n\t\t\t}\n\t\t}\n\t\tcreated = append(created, recordKey)\n\t}\n\n\tif len(created) != 0 {\n\t\tklog.Infof(\"Pre-creating DNS records\")\n\n\t\terr := changeset.Apply(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error pre-creating DNS records: %v\", err)\n\t\t}\n\t\tklog.V(2).Infof(\"Pre-created DNS names: %v\", created)\n\t}\n\n\treturn nil\n}\n\n// buildPrecreateDNSHostnames returns the hostnames we should precreate\nfunc buildPrecreateDNSHostnames(cluster *kops.Cluster) []recordKey {\n\tvar recordKeys []recordKey\n\tinternalType := rrstype.A\n\tif cluster.Spec.IsIPv6Only() {\n\t\tinternalType = rrstype.AAAA\n\t}\n\n\thasAPILoadbalancer := cluster.Spec.API.LoadBalancer != nil\n\tuseLBForInternalAPI := hasAPILoadbalancer && cluster.Spec.API.LoadBalancer.UseForInternalAPI\n","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/dns.go#L218-L254","documentation":"precreateDNS batches the DNS changes needed to pre-create records (e.g. api, api.internal, bastion names) and applies them via changeset.Apply(ctx). If the provider rejects or fails the change, the underlying error is wrapped as 'error pre-creating DNS records'. This happens late in cluster provisioning after the model is built.","triggerScenarios":"changeset.Apply fails while running `kops create cluster`: insufficient DNS permissions (route53:ChangeResourceRecordSets), duplicate/conflicting records in the zone, zone state changed concurrently, or provider API errors.","commonSituations":"Records already exist from a previous cluster with the same name (CNAME conflict with existing alias records); AWS credentials without write access; hosted zone deleted mid-run; Route53 throttling.","solutions":["Inspect the wrapped %v cause for the provider-specific reason (e.g. InvalidChangeBatch, AccessDenied)","Delete stale records for the same cluster name in the hosted zone from previous attempts","Grant route53:ChangeResourceRecordSets / Cloud DNS write permissions to the credentials kOps uses","Re-run kops — DNS pre-creation is idempotent for records already created"],"exampleFix":"// before\nkops create cluster --name api.example.com ...  # stale CNAME for api.example.com exists\n// after\n# remove conflicting record, then rerun\naws route53 list-resource-record-sets --hosted-zone-id Z...\naws route53 change-resource-record-sets ... --change-batch '{\"Changes\":[{\"Action\":\"DELETE\",...}]}'","handlingStrategy":"try-catch","validationCode":"aws route53 list-resource-record-sets --hosted-zone-id Z... | grep -F 'api.<cluster>'\n# remove stale records for the cluster name before creating","typeGuard":null,"tryCatchPattern":"err := changeset.Apply(ctx)\nif err != nil {\n    klog.Warningf(\"DNS apply failed: %v; check permissions (route53:ChangeResourceRecordSets) and conflicting records\", err)\n    return err\n}","preventionTips":["Grant DNS write permissions to kops credentials","Delete leftover records from previous clusters with the same name","Avoid concurrent kops runs against the same hosted zone","Retry idempotently — already-created records are skipped"],"tags":["dns","api-error","cluster-creation"],"backgroundTag":"dns-record-apply-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"}