From 37c2cfe92c61f4a1ea9404bb017ddad95dd95e36 Mon Sep 17 00:00:00 2001 From: Maciej Pytel Date: Wed, 28 Jun 2017 16:10:41 +0200 Subject: [PATCH] Add retry to RC creation in autoscaler e2e --- .../autoscaling/cluster_size_autoscaling.go | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/test/e2e/autoscaling/cluster_size_autoscaling.go b/test/e2e/autoscaling/cluster_size_autoscaling.go index 8f5cc40e6a1..6128f426382 100644 --- a/test/e2e/autoscaling/cluster_size_autoscaling.go +++ b/test/e2e/autoscaling/cluster_size_autoscaling.go @@ -48,13 +48,15 @@ import ( ) const ( - defaultTimeout = 3 * time.Minute - resizeTimeout = 5 * time.Minute - scaleUpTimeout = 5 * time.Minute - scaleUpTriggerTimeout = 2 * time.Minute - scaleDownTimeout = 20 * time.Minute - podTimeout = 2 * time.Minute - nodesRecoverTimeout = 5 * time.Minute + defaultTimeout = 3 * time.Minute + resizeTimeout = 5 * time.Minute + scaleUpTimeout = 5 * time.Minute + scaleUpTriggerTimeout = 2 * time.Minute + scaleDownTimeout = 20 * time.Minute + podTimeout = 2 * time.Minute + nodesRecoverTimeout = 5 * time.Minute + rcCreationRetryTimeout = 4 * time.Minute + rcCreationRetryDelay = 20 * time.Second gkeEndpoint = "https://test-container.sandbox.googleapis.com" gkeUpdateTimeout = 15 * time.Minute @@ -771,10 +773,18 @@ func ReserveMemory(f *framework.Framework, id string, replicas, megabytes int, e Replicas: replicas, MemRequest: request, } - err := framework.RunRC(*config) - if expectRunning { - framework.ExpectNoError(err) + for start := time.Now(); time.Since(start) < rcCreationRetryTimeout; time.Sleep(rcCreationRetryDelay) { + err := framework.RunRC(*config) + if err != nil && strings.Contains(err.Error(), "Error creating replication controller") { + glog.Warningf("Failed to create memory reservation: %v", err) + continue + } + if expectRunning { + framework.ExpectNoError(err) + } + return } + framework.Failf("Failed to reserve memory within timeout") } // WaitForClusterSize waits until the cluster size matches the given function.