// Reconcile expects request to refer to a ingresscontroller in the operator
// namespace, and will do all the work to ensure the ingresscontroller is in the
// desired state.
Reconcile expects request to refer to a ingresscontroller in the operator
namespace, and will do all the work to ensure the ingresscontroller is in the
desired state.
// Reconcile expects request to refer to a ingresscontroller in the operator // namespace and will do all the work to ensure the ingresscontroller is in the // desired state .
func (r *reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) {
	errs := []error{}
	result := reconcile.Result{}
	log.Info("reconciling", "request", request)
	ingress := &operatorv1.IngressController{}
	if err := r.client.Get(context.TODO(), request.NamespacedName, ingress); err != nil {
		if errors.IsNotFound(err) {
			log.Info("ingresscontroller not found; reconciliation will be skipped", "request", request)
		} else {
			errs = append(errs, fmt.Errorf("failed to get ingresscontroller %q: %v", request, err))
		}
		ingress = nil
	}
	if ingress != nil {
		dnsConfig := &configv1.DNS{}
		if err := r.client.Get(context.TODO(), types.NamespacedName{Name: "cluster"}, dnsConfig); err != nil {
			errs = append(errs, fmt.Errorf("failed to get dns 'cluster': %v", err))
			dnsConfig = nil
		}
		infraConfig := &configv1.Infrastructure{}
		if err := r.client.Get(context.TODO(), types.NamespacedName{Name: "cluster"}, infraConfig); err != nil {
			errs = append(errs, fmt.Errorf("failed to get infrastructure 'cluster': %v", err))
			infraConfig = nil
		}
		ingressConfig := &configv1.Ingress{}
		if err := r.client.Get(context.TODO(), types.NamespacedName{Name: "cluster"}, ingressConfig); err != nil {
			errs = append(errs, fmt.Errorf("failed to get ingress 'cluster': %v", err))
			ingressConfig = nil
		}
		if dnsConfig != nil && infraConfig != nil && ingressConfig != nil {
			if err := r.ensureRouterNamespace(); err != nil {
				errs = append(errs, fmt.Errorf("failed to ensure router namespace: %v", err))
			}
			if err := r.enforceEffectiveIngressDomain(ingress, ingressConfig); err != nil {
				errs = append(errs, fmt.Errorf("failed to enforce the effective ingress domain for ingresscontroller %s: %v", ingress.Name, err))
			} else if IsStatusDomainSet(ingress) {
				if err := r.enforceEffectiveEndpointPublishingStrategy(ingress, infraConfig); err != nil {
					errs = append(errs, fmt.Errorf("failed to enforce the effective HA configuration for ingresscontroller %s: %v", ingress.Name, err))
				} else if ingress.DeletionTimestamp != nil {
					if err := r.ensureIngressDeleted(ingress, dnsConfig, infraConfig); err != nil {
						errs = append(errs, fmt.Errorf("failed to ensure ingress deletion: %v", err))
					}
				} else if err := r.enforceIngressFinalizer(ingress); err != nil {
					errs = append(errs, fmt.Errorf("failed to enforce ingress finalizer %s/%s: %v", ingress.Namespace, ingress.Name, err))
				} else {
					if err := r.ensureIngressController(ingress, dnsConfig, infraConfig); err != nil {
						errs = append(errs, fmt.Errorf("failed to ensure ingresscontroller: %v", err))
					}
				}
			}
		}
	}
	if err := r.syncOperatorStatus(); err != nil {
		errs = append(errs, fmt.Errorf("failed to sync operator status: %v", err))
	}
	return result, utilerrors.NewAggregate(errs)
}
func ( r * reconciler ) Reconcile ( request reconcile . Request ) ( reconcile . Result , error ) { errs := [ ] error { } result := reconcile . Result { } log . Info ( " " , " " , request ) ingress := & operatorv1 . IngressController { } if err := r . client . Get ( context . TODO ( ) , request . NamespacedName , ingress ) ; err != nil { if errors . IsNotFound ( err ) { log . Info ( " " , " " , request ) } else { errs = append ( errs , fmt . Errorf ( " " , request , err ) ) } ingress = nil } if ingress != nil { dnsConfig := & configv1 . DNS { } if err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : " " } , dnsConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) dnsConfig = nil } infraConfig := & configv1 . Infrastructure { } if err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : " " } , infraConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) infraConfig = nil } ingressConfig := & configv1 . Ingress { } if err := r . client . Get ( context . TODO ( ) , types . NamespacedName { Name : " " } , ingressConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) ingressConfig = nil } if dnsConfig != nil && infraConfig != nil && ingressConfig != nil { if err := r . ensureRouterNamespace ( ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) } if err := r . enforceEffectiveIngressDomain ( ingress , ingressConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , ingress . Name , err ) ) } else if IsStatusDomainSet ( ingress ) { if err := r . enforceEffectiveEndpointPublishingStrategy ( ingress , infraConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , ingress . Name , err ) ) } else if ingress . DeletionTimestamp != nil { if err := r . ensureIngressDeleted ( ingress , dnsConfig , infraConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) } } else if err := r . enforceIngressFinalizer ( ingress ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , ingress . Namespace , ingress . Name , err ) ) } else { if err := r . ensureIngressController ( ingress , dnsConfig , infraConfig ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) } } } } } if err := r . syncOperatorStatus ( ) ; err != nil { errs = append ( errs , fmt . Errorf ( " " , err ) ) } return result , utilerrors . NewAggregate ( errs ) }
Reconcile expects request to refer to a ingresscontroller in the operator
namespace, and will do all the work to ensure the ingresscontroller is in the
desired state.
Reconcile expects request to refer to a ingresscontroller in the operator namespace and will do all the work to ensure the ingresscontroller is in the desired state .
// Get the current ingress state. // This means the ingress was already deleted/finalized and there are // stale queue entries (or something edge triggering from a related // resource that got deleted async). // For now, if the cluster configs are unavailable, defer reconciliation // because weaving conditionals everywhere to deal with various nil states // is too complicated. It doesn't seem too risky to rely on the invariant // of the cluster config being available. // Ensure we have all the necessary scaffolding on which to place router instances. // Handle deletion. // Handle everything else. // TODO: Should this be another controller?