Rajbatra
Mission Specialist
Mission Specialist
  • 3,143 Views

LAB 280 - Unable to save file through OC edit command

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)
0 Kudos
20 Replies
chetan_tiwary
Flight Engineer Flight Engineer
Flight Engineer
  • 1,162 Views

Hello , 

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

 

#OC_EDITOR=vi oc edit deployment/hello

0 Kudos
post2tr
Mission Specialist
Mission Specialist
  • 1,145 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
Flight Engineer Flight Engineer
Flight Engineer
  • 1,142 Views

Great !! All the Best !

0 Kudos
flozano
Moderator
Moderator
  • 1,122 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
  • 1,115 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
  • 1,112 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
  • 1,099 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
  • 1,084 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 .

0 Kudos
Igris
Mission Specialist
Mission Specialist
  • 1,079 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.

0 Kudos
flozano
Moderator
Moderator
  • 1,071 Views

All Kubernetes resources store labels as part of their metadata. You can use "oc get kind name -o yaml" to see a complete, raw resource definition and "oc get kind name --show-labels" to see just labels

The app label used to be standard in apps created by oc new-app but with recent releases of OpenShift it might not be created for all scenarios. Developers are free to add as many labels they wish for their resources and it is common practice to add a common label to all resources related to an application or service to make it easier to track them.

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