kubectl: kubectl edit fails with Edit cancelled, no changes made even when file has modifications

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:

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

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’ve had the same problem and the reason was the key I was try to configure was already somewhere else in the same file but I didn’t notice it.

This is happening probably because you have some mistake in the format of the changes you are making. Hence the changes are being rejected. Please double check that there is no tabs, spacing, extra char, format etc issue in the file changes you just made. Because that was the issue with me, and was getting the same error.

The funny thing is that I’m trying to edit the comments and it just doesn’t see a change so I just get “Edit cancelled, no changes made.”

@i-Apoorva is spot on with this. I changed the image tag and noticed the file was auto-formatting on me.

containers:
- image: thing

became

containers:
  -  image: thing:1.1

fun little gotcha.