{"record":{"id":"d3eac37f3dc1554b","repo":"kubernetes/kops","slug":"failed-to-apply-objects-w","errorCode":null,"errorMessage":"failed to apply objects: %w","messagePattern":"failed to apply objects: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/pkg/channels/clientapplier.go","lineNumber":74,"sourceCode":"\t\tRESTMapper:   p.RESTMapper,\n\t\tClient:       p.Client,\n\t\tPatchOptions: patchOptions,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar applyableObjects []applyset.ApplyableObject\n\tfor _, object := range objects {\n\t\tapplyableObjects = append(applyableObjects, object)\n\t}\n\tif err := s.SetDesiredObjects(applyableObjects); err != nil {\n\t\treturn err\n\t}\n\n\tresults, err := s.ApplyOnce(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to apply objects: %w\", err)\n\t}\n\n\t// TODO: Implement pruning\n\n\tif !results.AllApplied() {\n\t\treturn fmt.Errorf(\"not all objects were applied\")\n\t}\n\n\t// TODO: Check object health status\n\tif !results.AllHealthy() {\n\t\treturn fmt.Errorf(\"not all objects were healthy\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":56,"sourceCodeEnd":90,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/channels/pkg/channels/clientapplier.go#L56-L90","documentation":"After filtering objects, ClientApplier.Apply delegates to an applyset (SetDesiredObjects + ApplyOnce) that applies each object server-side. If any step of ApplyOnce returns an error, it is wrapped as 'failed to apply objects'. This indicates the apply operation itself failed — API errors, RBAC, invalid objects rejected by the server — rather than a parse or health problem.","triggerScenarios":"ApplyOnce failing due to server-side apply rejection (validation errors, conflicts), RBAC denial on the target resources, API server unavailability, or CRDs not yet registered for objects in the manifest.","commonSituations":"Applying addon CRs before their CRDs are established; insufficient RBAC for kops to manage the addon resources; server-side apply field-manager conflicts; invalid field values rejected by validation.","solutions":["Read the wrapped error for the specific object/field rejected by the API server.","Ensure CRDs in the manifest are applied and Established before dependent objects.","Grant the identity RBAC for all resources in the manifest.","Retry transient failures (timeouts, 5xx, conflicts).","Run kubectl apply --server-side --field-manager=kops -f manifest.yaml to reproduce outside the library."],"exampleFix":"// before\nerr := applier.Apply(ctx, manifest) // fails: CRD not established\n// after\nensureCRDsFirst(ctx, client, manifest) // apply CRD objects and wait for Established\nerr := applier.Apply(ctx, manifest)","handlingStrategy":"retry","validationCode":"// pre-check RBAC for a representative resource\nssar, _ := k8sClient.AuthorizationV1().SelfSubjectAccessReviews().Create(ctx, &authv1.SelfSubjectAccessReview{\n    Spec: authv1.SelfSubjectAccessReviewSpec{ResourceAttributes: &authv1.ResourceAttributes{\n        Verb: \"patch\", Group: \"apps\", Resource: \"deployments\",\n    }},\n}, metav1.CreateOptions{})\n_ = ssar.Status.Allowed","typeGuard":"func isApplyFailure(err error) bool {\n    return strings.Contains(err.Error(), \"failed to apply objects\")\n}","tryCatchPattern":"if err := applier.Apply(ctx, manifest); err != nil {\n    if isApplyFailure(err) {\n        return retry.OnError(retry.DefaultBackoff, func(e error) bool {\n            return apierrors.IsTimeout(e) || apierrors.IsServerTimeout(e) || apierrors.IsConflict(e)\n        }, func() error { return applier.Apply(ctx, manifest) })\n    }\n    return err\n}","preventionTips":["Apply CRDs first and wait for Established status.","Grant full RBAC for every resource kind in the manifest.","Use consistent field-manager to reduce server-side-apply conflicts.","Dry-run server-side (kubectl apply --dry-run=server) before real applies."],"tags":["kubernetes","apply","server-side-apply","rbac"],"backgroundTag":"kubernetes-apply-failed","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"}