cancel
Showing results for 
Search instead for 
Did you mean: 
Rajbatra
Mission Specialist
Mission Specialist
  • 9,328 Views

LAB 280 - Unable to save file through OC edit command

Jump to solution

Hi,

I am doing Lab, there i am trying to save file through OC edit command, but it is showing error.

student@workstation ~]$ oc edit deployment/hello
A copy of your changes has been stored to "/tmp/oc-edit-1fi7k.yaml"
error: Edit cancelled, no valid changes were saved.

Let us know , how to save file through oc edit command?

Thanks

Rajkumar Batra

Labels (1)
23 Replies
Chetan_Tiwary_
Moderator
Moderator
  • 3,186 Views

Hello , 

can you try with vi editor for once and see if it helps ?

 

#OC_EDITOR=vi oc edit deployment/hello

post2tr
Mission Specialist
Mission Specialist
  • 3,169 Views

Hi,

issue get resolved now !! i should have checked the error reported while it not saving and storing the file to /tmp/oc-edit-XXX ( screenshots attached ) DO280_Chapter-6_GE2_yaml_error.PNG

YAML error: found character that cannot start any token

used tab instead of Space - as Yaml dont accept tabs and expecting spaces

DO280_Chapter-6_GE3.PNG

Thanks for your support !!

 

 

Chetan_Tiwary_
Moderator
Moderator
  • 3,166 Views

Great !! All the Best !

0 Kudos
  • 1,701 Views

Hey

I had the same issue at the same lab! I would go crazy since everything seemed normal except using tab instead of space! This also resolved my issue. Thanks a lot!

0 Kudos
flozano
Moderator
Moderator
  • 3,146 Views

Clarification comment: oc edit does not save anything anywhere. You will not find a file with the oc edit contents of you last session. It reads from OpenShift and sends back to OpenShift, if OpenShift doesn't likes what it got and rejects it, you are left with no "file" to look at and make fixes.

An alternative is to export the resource to a file, edit the file, and them send it back to OpenShift:

$ oc get kind/name > resource.yaml

$ vi resource.yaml

$ oc apply resource.yaml

 

post2tr
Mission Specialist
Mission Specialist
  • 3,139 Views

hi , 

refer the screenshot for the oc edit  - which shows the change is not accepted and the file get saved /tmp/ 

 

DO280_Chapter-6_GE.PNG

 

flozano
Moderator
Moderator
  • 3,136 Views

You are correct that the file is saved on tmp (so it can be fed to vi or another editor) but oc edit will not pick that file for you and reuse it. So "conceptually" it is not saved... not to mention that any content in tmp could disappear without notice.

But you could fech the file from tmp, edit it, and feed it into oc apply.

post2tr
Mission Specialist
Mission Specialist
  • 3,123 Views

Yes , ofcourse oc edit wont pick . But i mentioned the output is save to /tmp/ by oc edit when it rejects the changes .So conceptually its save :-) anyway ..  thanks for your sharing !! cheers

Igris
Mission Specialist
Mission Specialist
  • 3,108 Views

a bit late to the patry but i hit the same issue,

the problem is with the indentation if you dont indent properly (mashing space)

it wont save so it doesnt matter if you export it as yaml or not if you dont have proper indentation openshift will not accept it .

Igris
Mission Specialist
Mission Specialist
  • 3,103 Views

since the topic is already bumped i have another question for the particular exercise 

oc delete all -l app=hello-limit

where is that label app stored ? and how can i view other labels ? I checked if it was on the node but that was not the case.

Join the discussion
You must log in to join this conversation.