Make test harness and comments match Kubernetes behaviour on conflict error

Kubernetes always returns nil on error; somehow I had the wrong idea
here.
This commit is contained in:
Bryan Boreham committed 2019-03-26 17:19:22 +00:00
1 parent b248e021ec
commit bd24dd7dae
2 files changed
+3 -7

No files matched your search

+3 -3
View File
@@ -100,7 +100,7 @@ func (cml *configMapAnnotations) UpdateAnnotation(key, value string) (err error)
return errors.New("endpoint not initialized, call Init first")
}
// speculatively change the state, then replace with whatever comes back
// from Update(), which will be the latest on the server whatever happened
// from Update(), which will be the latest on the server, or nil if error
cml.cm.Annotations[cleanKey(key)] = value
cml.cm, err = cml.Client.ConfigMaps(cml.Namespace).Update(cml.cm)
return err
@@ -111,7 +111,7 @@ func (cml *configMapAnnotations) RemoveAnnotation(key string) (err error) {
return errors.New("endpoint not initialized, call Init first")
}
// speculatively change the state, then replace with whatever comes back
// from Update(), which will be the latest on the server whatever happened
// from Update(), which will be the latest on the server, or nil if error
delete(cml.cm.Annotations, cleanKey(key))
cml.cm, err = cml.Client.ConfigMaps(cml.Namespace).Update(cml.cm)
return err
@@ -122,7 +122,7 @@ func (cml *configMapAnnotations) RemoveAnnotationsWithValue(valueToRemove string
return errors.New("endpoint not initialized, call Init first")
}
// speculatively change the state, then replace with whatever comes back
// from Update(), which will be the latest on the server whatever happened
// from Update(), which will be the latest on the server, or nil if error
for key, value := range cml.cm.Annotations {
if value == valueToRemove {
delete(cml.cm.Annotations, key) // don't need to clean this key as it came from the map
-4
View File
@@ -110,10 +110,6 @@ func ObjectReaction(tracker ObjectTracker) testing.ReactionFunc {
}
err = tracker.Update(gvr, action.GetObject(), ns)
if err != nil {
if errors.IsConflict(err) { // return the currently-stored version of the object
obj, _ := tracker.Get(gvr, ns, objMeta.GetName())
return true, obj, err
}
return true, nil, err
}
obj, err := tracker.Get(gvr, ns, objMeta.GetName())