Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
enable a longer wait period for provision retries
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Boyd committed May 31, 2018
1 parent 2117382 commit e28d57f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/controller/controller_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ func (c *controller) setNextProvisionRetryTime(instance *v1beta1.ServiceInstance
duration := c.provisionRetryQueue.rateLimter.When(key)
c.provisionRetryQueue.mutex.Lock()
c.provisionRetryQueue.retryTime[key] = time.Now().Add(duration)
glog.V(7).Infof("provisionRetry for %s after %v", key, duration)
c.provisionRetryQueue.mutex.Unlock()
}

Expand Down
4 changes: 3 additions & 1 deletion test/integration/controller_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/url"
"reflect"
"testing"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -1006,6 +1007,7 @@ func (e TimeoutError) Error() string {
// TestCreateServiceInstanceWithProvisionFailure tests creating a ServiceInstance
// with various failure results in response to the provision request.
func TestCreateServiceInstanceWithProvisionFailure(t *testing.T) {
const longerTimeoutForBrokerRetryBackoff = time.Second * 90
cases := []struct {
name string
statusCode int
Expand Down Expand Up @@ -1150,7 +1152,7 @@ func TestCreateServiceInstanceWithProvisionFailure(t *testing.T) {
Reason: tc.conditionReason,
}
}
if err := util.WaitForInstanceCondition(ct.client, testNamespace, testInstanceName, condition); err != nil {
if err := util.WaitForInstanceConditionWithCustomTimeout(ct.client, testNamespace, testInstanceName, condition, longerTimeoutForBrokerRetryBackoff); err != nil {
t.Fatalf("error waiting for instance condition: %v", err)
}

Expand Down
18 changes: 17 additions & 1 deletion test/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ func WaitForClusterServiceClassToNotExist(client v1beta1servicecatalog.Serviceca
// WaitForInstanceCondition waits for the status of the named instance to
// contain a condition whose type and status matches the supplied one.
func WaitForInstanceCondition(client v1beta1servicecatalog.ServicecatalogV1beta1Interface, namespace, name string, condition v1beta1.ServiceInstanceCondition) error {
return wait.PollImmediate(500*time.Millisecond, wait.ForeverTestTimeout,
return WaitForInstanceConditionWithCustomTimeout(client, namespace, name, condition, wait.ForeverTestTimeout)
}

// WaitForInstanceConditionWithCustomTimeout waits for the status of the named instance to
// contain a condition whose type and status matches the supplied one.
func WaitForInstanceConditionWithCustomTimeout(client v1beta1servicecatalog.ServicecatalogV1beta1Interface, namespace, name string, condition v1beta1.ServiceInstanceCondition, wd time.Duration) error {
return wait.PollImmediate(500*time.Millisecond, wd,
func() (bool, error) {
glog.V(5).Infof("Waiting for instance %v/%v condition %#v", namespace, name, condition)
instance, err := client.ServiceInstances(namespace).Get(name, metav1.GetOptions{})
Expand All @@ -184,6 +190,16 @@ func WaitForInstanceCondition(client v1beta1servicecatalog.ServicecatalogV1beta1
)
}

// PrintInstance logs the instance details
func PrintInstance(client v1beta1servicecatalog.ServicecatalogV1beta1Interface, namespace, name string) {
instance, err := client.ServiceInstances(namespace).Get(name, metav1.GetOptions{})
if nil != err {
glog.Infof("Error getting Instance %v/%v: %v", namespace, name, err)
return
}
glog.Infof("Instance %v/%v: %+v", namespace, name, instance)
}

// WaitForInstanceToNotExist waits for the Instance with the given name to no
// longer exist.
func WaitForInstanceToNotExist(client v1beta1servicecatalog.ServicecatalogV1beta1Interface, namespace, name string) error {
Expand Down

0 comments on commit e28d57f

Please sign in to comment.