Skip to content

Cannot create or update resource with managed fields #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olkornii opened this issue Apr 24, 2024 · 3 comments · Fixed by #756
Closed

Cannot create or update resource with managed fields #755

olkornii opened this issue Apr 24, 2024 · 3 comments · Fixed by #756
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@olkornii
Copy link
Collaborator

olkornii commented Apr 24, 2024

Steps to reproduce:

  1. start minikube cluster
  2. find "minikube" in Nodes
  3. Edit "minikube" node
  4. change name to "anything"
  5. see error notification

Expected: A new resource has been created
Actually: an error message:
metadata.managedFields must be nil. Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=metadata.managedFields must be nil, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).

@olkornii olkornii changed the title Can not create resource based on existing one. It is not possible to create a resource based on an existing one Apr 24, 2024
@adietish adietish self-assigned this Apr 24, 2024
@adietish adietish added this to the 1.4.0 milestone Apr 24, 2024
@adietish adietish moved this to 📋 Backlog in IDE Cloudaptors Apr 24, 2024
@adietish adietish added the kind/bug Something isn't working label Apr 24, 2024
@adietish
Copy link
Collaborator

adietish commented Apr 29, 2024

If you use "Remove Metadata clutter" in the editor toolbar you can successfully push the resource and it appears in the resource tree.

ps. I am astonished that you can even create a new node, would not have expected it to be possible. Nodes are running the docker containers.

@adietish
Copy link
Collaborator

adietish commented Apr 29, 2024

@olkornii: We are using a server-side patch operation to push the editor to the cluster and update it. The kubernetes docs specify that you cannot update the managed fields using a server-side patch operation which explains why we see this issue
(https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts)

It is however possible to change .metadata.managedFields through an update, or through a patch operation that does not use Server-Side Apply

One cannot create a resource with managed fields in this way, either.

Steps:

  1. EXEC: Create a file with the following content
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-cm
  namespace: default
  labels:
    test-label: test
  managedFields:
    - manager: kubectl
      operation: Apply # note capitalization: "Apply" (or "Update")
      apiVersion: v1
      time: "2010-10-10T0:00:00Z"
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:labels:
            f:test-label: {}
        f:data:
          f:key: {}
data:
  key: some value
  1. EXEC: push the editor to the cluster.

Result:
Error is displayed with the following details:

metadata.managedFields must be nil. Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=metadata.managedFields must be nil, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).

If you use kubectl apply -f <myfile.yml> the configmap is created.

@adietish
Copy link
Collaborator

We cannot simply remove the fields before sending because the user may want to set those explicitly, we cannot assume that the're not worth sending. I need to see if there's a way for us to use a different saving mechanism like client-side apply that would succeed.

@adietish adietish changed the title It is not possible to create a resource based on an existing one Cannot creeate or update resource with managed fields Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
@adietish adietish moved this from 📋 Backlog to 🏗 In progress in IDE Cloudaptors Apr 29, 2024
@adietish adietish changed the title Cannot creeate or update resource with managed fields Cannot create or update resource with managed fields Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 29, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 30, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 30, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 30, 2024
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Apr 30, 2024
adietish added a commit that referenced this issue May 6, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in IDE Cloudaptors May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Status: ✅ Done
2 participants