kubectl edit <resource> fails with Edit cancelled, no changes made even when file has modifications

Created on 11 Sep 2017  路  9Comments  路  Source: kubernetes/kubectl

What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.):

  • edit ingress
  • edit cancelled

also Google search on error message and kubectls editing


Is this a BUG REPORT or FEATURE REQUEST? (choose one):

BUG REPORT

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.4", GitCommit:"793658f2d7ca7f064d2bdf606519f9fe1229c381", GitTreeState:"clean", BuildDate:"2017-08-17T08:48:23Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.3", GitCommit:"2c2fe6e8278a5db2d15a013987b53968c743f2a1", GitTreeState:"clean", BuildDate:"2017-08-03T06:43:48Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration:
    GCE
  • OS (e.g. from /etc/os-release):

NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"

  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:

What happened:

  1. Open ingress file for editing
    kubectl --namespace=<myspace> edit ingress <myingressname>
    This opened up vim as expected. I made changes and saved them.
  2. Close vim.
  3. See message
    "Edit cancelled, no changes made"
    Tried this multiple times and made sure I always did a colon-w to write and same result everytime.
    When I reopen the file, the changes have not been saved.

What you expected to happen:
Changes to ingress saved correctly.

How to reproduce it (as minimally and precisely as possible):
Seems like an intermittent problem (steps are detailed in the What happened section"), because I have been previous able to edit ingress entries correctly.

Anything else we need to know:

Most helpful comment

I have similar issue.

error: pods "busybox-55f4f894ff-2pwkm" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-b98rx.yaml"
error: Edit cancelled, no valid changes were saved.

Kubectl version:

[root@Ateiv-kubemaster ~]# kc version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:37:52Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:30:26Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}

I'm new to K8s. How to fix this issue ?

All 9 comments

Can paste your manifest here?

hi @mengqiy - could you please clarify what you mean by manifest? the YAML file I used to create the ingress?
Original ingress yaml

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/backends: '{"REDACTED":"HEALTHY","REDACTED":"HEALTHY"}'
    ingress.kubernetes.io/forwarding-rule: REDACTED
    ingress.kubernetes.io/ingress.class: gce 
    ingress.kubernetes.io/target-proxy: REDACTED
    ingress.kubernetes.io/url-map: REDACTED
    kubernetes.io/tls-acme: "true"
    kubernetes.io/url-map: REDACTED
  creationTimestamp: 2017-09-12T21:08:39Z
  generation: 2
  name: flasktestingress
  namespace: ingresstest
  resourceVersion: "somenumber"
  selfLink: /apis/extensions/v1beta1/namespaces/ingresstest/ingresses/flasktestingress
  uid: REDACTED
spec:
  rules:
  - host: redacted.host.io
  - http:
      paths:
      - backend:
          serviceName: flaskservice
          servicePort: redacted
        path: /
  tls:
  - hosts:
    - redacted.host.io
    secretName: somename-tls
status:
  loadBalancer:
    ingress:
    - ip: someip

I am trying to edit

  tls:
  - hosts:
    - redacted.host.io
    secretName: somename-tls

to be

  tls:
   - secretName: somename-tls
     hosts:
      - redacted.host.io

(context: comment by @NiclasHedam in this thread on kube-lego
https://github.com/jetstack/kube-lego/issues/18 )

I have now been able to reproduce this issue twice.

could you please clarify what you mean by manifest?

Yes, yaml file

  tls:
  - hosts:
    - redacted.host.io
    secretName: somename-tls

to be

  tls:
   - secretName: somename-tls
     hosts:
      - redacted.host.io

There is no change between these two.
The order between hosts and secretName doesn't matter here, it's a map.
I think this is WAI. Closing.

Feel free to reopen if I miss something.

I have also faced same issue.

kubectl edit pod k8s-master-ag1 -n kube-system
error: pods "k8s-master-ag1gr1icp2m01" is invalid
error: pods "k8s-master-ag1gr1icp2m01" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-oh43e.yaml"
error: Edit cancelled, no valid changes were saved.

Here is kubectl version
kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.1", GitCommit:"3a1c9449a956b6026f075fa3134ff92f7d55f812", GitTreeState:"clean", BuildDate:"2018-01-04T11:52:23Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0+icp-ee", GitCommit:"9cb64de4ca4d039c35f4a29721aa5cf787648a15", GitTreeState:"clean", BuildDate:"2018-04-27T06:32:18Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

I have similar issue.

error: pods "busybox-55f4f894ff-2pwkm" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-b98rx.yaml"
error: Edit cancelled, no valid changes were saved.

Kubectl version:

[root@Ateiv-kubemaster ~]# kc version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:37:52Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:30:26Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}

I'm new to K8s. How to fix this issue ?

Hey Guys!
Could you please check if you are using Tabs instead of spaces to indent the block or spaces instead of tabs?

You can also see the error when the file opens again for retry:

# configmaps "coredns" was not valid:
# * : Invalid value: "The edited file failed validation": [yaml: line 8: found a tab character where an indentation space is expected, invalid character 'a' looking for beginning of value]
#

I ran into this when specifying a key earlier on in the configuration which already existed later in the configuration. The second instance of the key overrode the first. I believe this results in the configuration which K8s receives being identical and no changes being made.

Perhaps it would make sense to put a check in here for modification of the text contents (maybe a quick hash check) in addition to the configuration? The current failure makes sense once the solution is found, but is quite nonsensical to someone encountering it for the first time who knows that they obviously made changes, even though kubectl isn't seeing any difference.

I have also faced same issue.

[root@VM_2_105_centos tmp]# kubectl edit pods swift-b58c45f5c-5xlz4 -n kube-system
error: pods "swift-b58c45f5c-5xlz4" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-1cec3.yaml"
error: Edit cancelled, no valid changes were saved.
Was this page helpful?
0 / 5 - 0 ratings