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

Commit

Permalink
Check for no-op status update in resolveClusterReferences & resolveNa…
Browse files Browse the repository at this point in the history
…mespacedReferences
  • Loading branch information
luksa committed Dec 18, 2018
1 parent 3e398aa commit 8f9e2fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions pkg/controller/controller_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1216,15 +1216,15 @@ func (c *controller) resolveClusterReferences(instance *v1beta1.ServiceInstance)
if err != nil {
pcb := pretty.NewInstanceContextBuilder(instance)
glog.Warning(pcb.Message(err.Error()))
c.updateServiceInstanceCondition(
updatedInstance, _ := c.updateServiceInstanceCondition(
instance,
v1beta1.ServiceInstanceConditionReady,
v1beta1.ConditionFalse,
errorNonexistentClusterServiceClassReason,
"The instance references a ClusterServiceClass that does not exist. "+err.Error(),
)
c.recorder.Event(instance, corev1.EventTypeWarning, errorNonexistentClusterServiceClassReason, err.Error())
return false, err
return updatedInstance.ResourceVersion != instance.ResourceVersion, err
}
}

Expand All @@ -1240,19 +1240,19 @@ func (c *controller) resolveClusterReferences(instance *v1beta1.ServiceInstance)
if err != nil {
pcb := pretty.NewInstanceContextBuilder(instance)
glog.Warning(pcb.Message(err.Error()))
c.updateServiceInstanceCondition(
updatedInstance, _ := c.updateServiceInstanceCondition(
instance,
v1beta1.ServiceInstanceConditionReady,
v1beta1.ConditionFalse,
errorNonexistentClusterServicePlanReason,
"The instance references a ClusterServicePlan that does not exist. "+err.Error(),
)
c.recorder.Event(instance, corev1.EventTypeWarning, errorNonexistentClusterServicePlanReason, err.Error())
return false, err
return updatedInstance.ResourceVersion != instance.ResourceVersion, err
}
}
_, err = c.updateServiceInstanceReferences(instance)
return err == nil, err
updatedInstance, err := c.updateServiceInstanceReferences(instance)
return updatedInstance.ResourceVersion != instance.ResourceVersion, err
}

func (c *controller) resolveNamespacedReferences(instance *v1beta1.ServiceInstance) (bool, error) {
Expand All @@ -1267,15 +1267,15 @@ func (c *controller) resolveNamespacedReferences(instance *v1beta1.ServiceInstan
if err != nil {
pcb := pretty.NewInstanceContextBuilder(instance)
glog.Warning(pcb.Message(err.Error()))
c.updateServiceInstanceCondition(
updatedInstance, _ := c.updateServiceInstanceCondition(
instance,
v1beta1.ServiceInstanceConditionReady,
v1beta1.ConditionFalse,
errorNonexistentServiceClassReason,
"The instance references a ServiceClass that does not exist. "+err.Error(),
)
c.recorder.Event(instance, corev1.EventTypeWarning, errorNonexistentServiceClassReason, err.Error())
return false, err
return updatedInstance.ResourceVersion != instance.ResourceVersion, err
}
}

Expand All @@ -1291,19 +1291,19 @@ func (c *controller) resolveNamespacedReferences(instance *v1beta1.ServiceInstan
if err != nil {
pcb := pretty.NewInstanceContextBuilder(instance)
glog.Warning(pcb.Message(err.Error()))
c.updateServiceInstanceCondition(
updatedInstance, _ := c.updateServiceInstanceCondition(
instance,
v1beta1.ServiceInstanceConditionReady,
v1beta1.ConditionFalse,
errorNonexistentServicePlanReason,
"The instance references a ServicePlan that does not exist. "+err.Error(),
)
c.recorder.Event(instance, corev1.EventTypeWarning, errorNonexistentServicePlanReason, err.Error())
return false, err
return updatedInstance.ResourceVersion != instance.ResourceVersion, err
}
}
_, err = c.updateServiceInstanceReferences(instance)
return err == nil, err
updatedInstance, err := c.updateServiceInstanceReferences(instance)
return updatedInstance.ResourceVersion != instance.ResourceVersion, err
}

// resolveClusterServiceClassRef resolves a reference to a ClusterServiceClass
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/controller_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4542,8 +4542,8 @@ func TestResolveReferencesNoClusterServiceClass(t *testing.T) {
t.Fatalf("Did not get the expected error message %q got %q", e, a)
}

if modified {
t.Fatalf("Should have returned false")
if !modified {
t.Fatalf("Should have returned true")
}

// We should get the following actions:
Expand Down Expand Up @@ -4828,8 +4828,8 @@ func TestResolveReferencesNoClusterServicePlan(t *testing.T) {
t.Fatalf("Did not get the expected error message %q got %q", e, a)
}

if modified {
t.Fatalf("Should have returned false")
if !modified {
t.Fatalf("Should have returned true")
}

// We should get the following actions:
Expand Down

0 comments on commit 8f9e2fc

Please sign in to comment.