1

I'm working on some scripts for modifying configmaps, but while I'm working on that, I need a way to restore the configmap from a backup. In my script, I first write out the configmap to a file, in case the modification doesn't work properly, which is presently the case.

I'm basically just doing this:

cat /tmp/tmpfile | kubectl replace <configmapname> -f -".

However, this fails with:

Error from server (Conflict): error when replacing "STDIN": Operation cannot be fulfilled on configmaps "<configmapname>": the object has been modified; please apply your changes to the latest version and try again"

I don't understand what I need to do here.

David M. Karr
  • 14,317
  • 20
  • 94
  • 199
  • 1
    I did an Internet search for the error message "the object has been modified; please apply your changes to the latest version and try again" and [this](https://stackoverflow.com/questions/51297136/the-object-has-been-modified-please-apply-your-changes-to-the-latest-version-an) was the first result I found. Does the advice in that answer help in your case too? – Amit Kumar Gupta Aug 02 '19 at 00:30
  • What about `kubectl apply -f /tmp/tmpfile`? – FL3SH Aug 06 '19 at 08:35
  • I thought I had replied to this already, but the link to the other solution did help. I had to remove several of the metadata properties. Concerning replace vs. apply, from what I understand of the difference, that wouldn't have helped. – David M. Karr Aug 06 '19 at 19:36

0 Answers0