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:
1 parent
b248e021ec
commit
bd24dd7dae
2 files changed
+3
-7
No files matched your search
@@ -100,7 +100,7 @@ func (cml *configMapAnnotations) UpdateAnnotation(key, value string) (err error)
|
|||||||
return errors.New("endpoint not initialized, call Init first")
|
return errors.New("endpoint not initialized, call Init first")
|
||||||
}
|
}
|
||||||
// speculatively change the state, then replace with whatever comes back
|
// 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.Annotations[cleanKey(key)] = value
|
||||||
cml.cm, err = cml.Client.ConfigMaps(cml.Namespace).Update(cml.cm)
|
cml.cm, err = cml.Client.ConfigMaps(cml.Namespace).Update(cml.cm)
|
||||||
return err
|
return err
|
||||||
@@ -111,7 +111,7 @@ func (cml *configMapAnnotations) RemoveAnnotation(key string) (err error) {
|
|||||||
return errors.New("endpoint not initialized, call Init first")
|
return errors.New("endpoint not initialized, call Init first")
|
||||||
}
|
}
|
||||||
// speculatively change the state, then replace with whatever comes back
|
// 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))
|
delete(cml.cm.Annotations, cleanKey(key))
|
||||||
cml.cm, err = cml.Client.ConfigMaps(cml.Namespace).Update(cml.cm)
|
cml.cm, err = cml.Client.ConfigMaps(cml.Namespace).Update(cml.cm)
|
||||||
return err
|
return err
|
||||||
@@ -122,7 +122,7 @@ func (cml *configMapAnnotations) RemoveAnnotationsWithValue(valueToRemove string
|
|||||||
return errors.New("endpoint not initialized, call Init first")
|
return errors.New("endpoint not initialized, call Init first")
|
||||||
}
|
}
|
||||||
// speculatively change the state, then replace with whatever comes back
|
// 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 {
|
for key, value := range cml.cm.Annotations {
|
||||||
if value == valueToRemove {
|
if value == valueToRemove {
|
||||||
delete(cml.cm.Annotations, key) // don't need to clean this key as it came from the map
|
delete(cml.cm.Annotations, key) // don't need to clean this key as it came from the map
|
||||||
|
|||||||
@@ -110,10 +110,6 @@ func ObjectReaction(tracker ObjectTracker) testing.ReactionFunc {
|
|||||||
}
|
}
|
||||||
err = tracker.Update(gvr, action.GetObject(), ns)
|
err = tracker.Update(gvr, action.GetObject(), ns)
|
||||||
if err != nil {
|
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
|
return true, nil, err
|
||||||
}
|
}
|
||||||
obj, err := tracker.Get(gvr, ns, objMeta.GetName())
|
obj, err := tracker.Get(gvr, ns, objMeta.GetName())
|
||||||
|
|||||||
Reference in new issue
Block a user