Skip to content

Commit

Permalink
Remove Failed condition if there was no terminal failure (openshift#1788
Browse files Browse the repository at this point in the history
)
  • Loading branch information
nilebox committed Mar 5, 2018
1 parent cd831de commit 1f60676
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions pkg/controller/controller_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ const (
deprovisioningInFlightMessage string = "Deprovision request for ServiceInstance in-flight to Broker"
startingInstanceOrphanMitigationReason string = "StartingInstanceOrphanMitigation"
startingInstanceOrphanMitigationMessage string = "The instance provision call failed with an ambiguous error; attempting to deprovision the instance in order to mitigate an orphaned resource"
observedNewGenerationReason string = "ObservedNewGeneration"
observedNewGenerationMessage string = "Observed a new generation of the instance"
)

// ServiceInstance handlers and control-loop
Expand Down Expand Up @@ -1003,6 +1001,28 @@ func newServiceInstanceFailedCondition(status v1beta1.ConditionStatus, reason, m
}
}

// removeServiceInstanceCondition removes a condition of a given type from an
// instance's status if it exists.
func removeServiceInstanceCondition(toUpdate *v1beta1.ServiceInstance,
conditionType v1beta1.ServiceInstanceConditionType) {
pcb := pretty.NewContextBuilder(pretty.ServiceInstance, toUpdate.Namespace, toUpdate.Name)
glog.V(5).Info(pcb.Messagef(
"Removing condition %q", conditionType,
))

newStatusConditions := make([]v1beta1.ServiceInstanceCondition, 0, len(toUpdate.Status.Conditions))
for _, cond := range toUpdate.Status.Conditions {
if cond.Type == conditionType {
glog.V(5).Info(pcb.Messagef("Found existing condition %q: %q; removing it",
conditionType, cond.Status,
))
continue
}
newStatusConditions = append(newStatusConditions, cond)
}
toUpdate.Status.Conditions = newStatusConditions
}

// setServiceInstanceCondition sets a single condition on an Instance's status: if
// the condition already exists in the status, it is mutated; if the condition
// does not already exist in the status, it is added. Other conditions in the
Expand Down Expand Up @@ -1134,22 +1154,9 @@ func (c *controller) updateServiceInstanceCondition(
// It doesn't send the update request to server.
func (c *controller) prepareObservedGeneration(toUpdate *v1beta1.ServiceInstance) {
toUpdate.Status.ObservedGeneration = toUpdate.Generation
reason := observedNewGenerationReason
message := observedNewGenerationMessage
setServiceInstanceCondition(
removeServiceInstanceCondition(
toUpdate,
v1beta1.ServiceInstanceConditionReady,
v1beta1.ConditionFalse,
reason,
message,
)
setServiceInstanceCondition(
toUpdate,
v1beta1.ServiceInstanceConditionFailed,
v1beta1.ConditionFalse,
reason,
message,
)
v1beta1.ServiceInstanceConditionFailed)
}

// recordStartOfServiceInstanceOperation updates the instance to indicate that
Expand Down

0 comments on commit 1f60676

Please sign in to comment.