mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
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:
parent
a94c67d66b
commit
bdc4540e92
@ -844,15 +844,11 @@ func (t *ServiceTestFixture) Cleanup() []error {
|
|||||||
for rcName := range t.rcs {
|
for rcName := range t.rcs {
|
||||||
By("stopping RC " + rcName + " in namespace " + t.Namespace)
|
By("stopping RC " + rcName + " in namespace " + t.Namespace)
|
||||||
// First, resize the RC to 0.
|
// 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 {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
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.
|
// TODO(mikedanese): Wait.
|
||||||
// Then, delete the RC altogether.
|
// Then, delete the RC altogether.
|
||||||
if err := t.Client.Core().ReplicationControllers(t.Namespace).Delete(rcName, nil); err != nil {
|
if err := t.Client.Core().ReplicationControllers(t.Namespace).Delete(rcName, nil); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user