{"record":{"id":"a9f82ab258e737ff","repo":"tailscale/tailscale","slug":"error-cleaning-up-serviceaccounts-w","errorCode":null,"errorMessage":"error cleaning up ServiceAccounts: %w","messagePattern":"error cleaning up ServiceAccounts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/k8s-operator/tsrecorder.go","lineNumber":250,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating RoleBinding: %w\", err)\n\t}\n\n\tss := tsrStatefulSet(tsr, r.tsNamespace, tsClient.LoginURL())\n\t_, err = createOrUpdate(ctx, r.Client, r.tsNamespace, ss, func(s *appsv1.StatefulSet) {\n\t\ts.ObjectMeta.Labels = ss.ObjectMeta.Labels\n\t\ts.ObjectMeta.Annotations = ss.ObjectMeta.Annotations\n\t\ts.Spec = ss.Spec\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating StatefulSet: %w\", err)\n\t}\n\n\t// ServiceAccount name may have changed, in which case we need to clean up\n\t// the previous ServiceAccount. RoleBinding will already be updated to point\n\t// to the new ServiceAccount.\n\tif err = r.maybeCleanupServiceAccounts(ctx, tsr, sa.Name); err != nil {\n\t\treturn fmt.Errorf(\"error cleaning up ServiceAccounts: %w\", err)\n\t}\n\n\t// If we have scaled the recorder down, we will have dangling state secrets\n\t// that we need to clean up.\n\tif err = r.maybeCleanupSecrets(ctx, tsClient, tsr); err != nil {\n\t\treturn fmt.Errorf(\"error cleaning up Secrets: %w\", err)\n\t}\n\n\tvar devices []tsapi.RecorderTailnetDevice\n\tfor replica := range replicas {\n\t\tdev, ok, err := r.getDeviceInfo(ctx, tsClient, tsr.Name, replica)\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\treturn fmt.Errorf(\"failed to get device info: %w\", err)\n\t\tcase !ok:\n\t\t\tlogger.Debugf(\"no Tailscale hostname known yet, waiting for Recorder pod to finish auth\")\n\t\t\tcontinue\n\t\t}","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/tailscale/tailscale/blob/cfe32b8be6a33f8e24fbc369cbfbf7c729d9e042/cmd/k8s-operator/tsrecorder.go#L232-L268","documentation":"Error \"error cleaning up ServiceAccounts: %w\" thrown in tailscale/tailscale.","triggerScenarios":"Thrown at cmd/k8s-operator/tsrecorder.go:250 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"}