{"record":{"id":"55cf9f955b9bbee5","repo":"tailscale/tailscale","slug":"failed-to-add-finalizer-w-55cf9f","errorCode":null,"errorMessage":"failed to add finalizer: %w","messagePattern":"failed to add finalizer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/k8s-operator/svc.go","lineNumber":254,"sourceCode":"\t\t\ttsoperator.SetServiceCondition(svc, tsapi.ProxyReady, metav1.ConditionFalse, reasonProxyFailed, errMsg.Error(), a.clock, logger)\n\t\t\treturn errMsg\n\t\t} else if !ready {\n\t\t\tmsg := fmt.Sprintf(\"ProxyClass %s specified for the Service, but is not (yet) Ready, waiting..\", proxyClass)\n\t\t\ttsoperator.SetServiceCondition(svc, tsapi.ProxyReady, metav1.ConditionFalse, reasonProxyPending, msg, a.clock, logger)\n\t\t\tlogger.Info(msg)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif !slices.Contains(svc.Finalizers, FinalizerName) {\n\t\t// This log line is printed exactly once during initial provisioning,\n\t\t// because once the finalizer is in place this block gets skipped. So,\n\t\t// this is a nice place to tell the operator that the high level,\n\t\t// multi-reconcile operation is underway.\n\t\tlogger.Infof(\"exposing service over tailscale\")\n\t\tsvc.Finalizers = append(svc.Finalizers, FinalizerName)\n\t\tif err := a.Update(ctx, svc); err != nil {\n\t\t\terrMsg := fmt.Errorf(\"failed to add finalizer: %w\", err)\n\t\t\ttsoperator.SetServiceCondition(svc, tsapi.ProxyReady, metav1.ConditionFalse, reasonProxyFailed, errMsg.Error(), a.clock, logger)\n\t\t\treturn errMsg\n\t\t}\n\t}\n\tcrl := childResourceLabels(svc.Name, svc.Namespace, \"svc\")\n\tvar tags []string\n\tif tstr, ok := svc.Annotations[AnnotationTags]; ok {\n\t\ttags = strings.Split(tstr, \",\")\n\t}\n\n\tsts := &tailscaleSTSConfig{\n\t\tReplicas:            1,\n\t\tParentResourceName:  svc.Name,\n\t\tParentResourceUID:   string(svc.UID),\n\t\tHostname:            nameForService(svc),\n\t\tTags:                tags,\n\t\tChildResourceLabels: crl,\n\t\tProxyClassName:      proxyClass,","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/tailscale/tailscale/blob/cfe32b8be6a33f8e24fbc369cbfbf7c729d9e042/cmd/k8s-operator/svc.go#L236-L272","documentation":"Error \"failed to add finalizer: %w\" thrown in tailscale/tailscale.","triggerScenarios":"Thrown at cmd/k8s-operator/svc.go:254 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cfe32b8be6a33f8e24fbc369cbfbf7c729d9e042","analyzedAt":"2026-08-15T19:58:31.583Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}