e2e/framework: Deflake cleanup of RCs in service_util.

The previous Get/Update pattern with no retry on resource version mismatch
would flake with the following error:

"the object has been modified; please apply your changes to the latest
version and try again"
This commit is contained in:
Anthony Yeh 2017-03-02 16:51:14 -08:00
parent a94c67d66b
commit bdc4540e92

View File

@ -844,15 +844,11 @@ func (t *ServiceTestFixture) Cleanup() []error {
for rcName := range t.rcs {
By("stopping RC " + rcName + " in namespace " + t.Namespace)
// First, resize the RC to 0.
old, err := t.Client.Core().ReplicationControllers(t.Namespace).Get(rcName, metav1.GetOptions{})
patch := `{"spec":{"replicas":0}}`
_, err := t.Client.Core().ReplicationControllers(t.Namespace).Patch(rcName, types.StrategicMergePatchType, []byte(patch))
if err != nil {
errs = append(errs, err)
}
x := int32(0)
old.Spec.Replicas = &x
if _, err := t.Client.Core().ReplicationControllers(t.Namespace).Update(old); err != nil {
errs = append(errs, err)
}
// TODO(mikedanese): Wait.
// Then, delete the RC altogether.
if err := t.Client.Core().ReplicationControllers(t.Namespace).Delete(rcName, nil); err != nil {