Skip to content

Commit

Permalink
Merge pull request #526 from rfredette/bz-1905778
Browse files Browse the repository at this point in the history
Bug 1905778: Fix inconsistent ingress operator status after upgrade
  • Loading branch information
openshift-merge-robot committed Jan 26, 2021
2 parents eea3761 + 1495ae7 commit 1a96d0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/operator/controller/ingress/controller.go
Expand Up @@ -230,6 +230,18 @@ func (r *reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err
return reconcile.Result{Requeue: true}, nil
}

// TODO: remove this fix-up logic in 4.8
if ingress.Status.EndpointPublishingStrategy != nil && ingress.Status.EndpointPublishingStrategy.Type == operatorv1.LoadBalancerServiceStrategyType && ingress.Status.EndpointPublishingStrategy.LoadBalancer == nil {
log.Info("Setting default value for empty status.endpointPublishingStrategy.loadBalancer field", "ingresscontroller", ingress)
ingress.Status.EndpointPublishingStrategy.LoadBalancer = &operatorv1.LoadBalancerStrategy{
Scope: operatorv1.ExternalLoadBalancer,
}
if err := r.client.Status().Update(context.TODO(), ingress); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to update status: %v", err)
}
return reconcile.Result{Requeue: true}, nil
}

// The ingresscontroller is safe to process, so ensure it.
if err := r.ensureIngressController(ingress, dnsConfig, infraConfig, ingressConfig, apiConfig, networkConfig); err != nil {
switch e := err.(type) {
Expand Down
14 changes: 14 additions & 0 deletions pkg/operator/controller/ingress/status.go
Expand Up @@ -66,6 +66,7 @@ func (r *reconciler) syncIngressControllerStatus(ic *operatorv1.IngressControlle
degradedCondition, err := computeIngressDegradedCondition(updated.Status.Conditions, updated.Name)
errs = append(errs, err)
updated.Status.Conditions = MergeConditions(updated.Status.Conditions, degradedCondition)
updated.Status.Conditions = PruneConditions(updated.Status.Conditions)

if !IngressStatusesEqual(updated.Status, ic.Status) {
if err := r.client.Status().Update(context.TODO(), updated); err != nil {
Expand Down Expand Up @@ -105,6 +106,19 @@ func MergeConditions(conditions []operatorv1.OperatorCondition, updates ...opera
return conditions
}

// PruneConditions removes any conditions that are not currently supported.
// Returns the updated condition array.
func PruneConditions(conditions []operatorv1.OperatorCondition) []operatorv1.OperatorCondition {
for i, condition := range conditions {
// TODO: Remove this fix-up logic in 4.8
if condition.Type == "DeploymentDegraded" {
// DeploymentDegraded was removed in 4.6.0
conditions = append(conditions[:i], conditions[i+1:]...)
}
}
return conditions
}

// computeIngressTLSProfile computes the ingresscontroller's current TLS
// profile. If the deployment is ready, then the TLS profile is inferred from
// deployment's pod template spec. Otherwise the previous TLS profile is used.
Expand Down

0 comments on commit 1a96d0a

Please sign in to comment.