kubernetes: Error updating managedFields in custom resource: failed to update ManagedFields: failed to convert old object

What happened:

  1. following https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#create-a-customresourcedefinition to create a CRD named crontabs.stable.example.com and then following https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#create-custom-objects to create a CR named my-new-cron-object in a v1.18+ cluster.
  2. clearing managedFields by following https://kubernetes.io/docs/reference/using-api/api-concepts/#clearing-managedfields using kubectl:

kubectl patch ct my-new-cron-object --type json -p ‘[{“op”: “replace”, “path”: “/metadata/managedFields”, “value”: [{}]}]’ kubectl patch ct my-new-cron-object --type merge -p ‘{“metadata”:{“managedFields”: [{}]}}’

  1. it will always fail with error messages: Error from server: failed to update object (json PATCH for stable.example.com/v1, Kind=CronTab) managed fields: failed to update ManagedFields: failed to convert old object: stable.example.com/v1, Kind=CronTab is unstructured and is not suitable for converting to ""

i tried the same on built-in resources and it works like a charm. is there a way to clear the field from CR?

/cc @kubernetes/sig-api-machinery-misc

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

@yue9944882 as a temporary workaround it just worked for me to reset the managedFields with a body like this: {"metadata":{"managedFields": [{"apiVersion": "stable.example.com/v1"}]}}