Skip to content

Commit

Permalink
Add check for nil ingress_host
Browse files Browse the repository at this point in the history
From pulpcore doc https://docs.pulpproject.org/pulpcore/configuration/settings.html#content-origin
this is a required setting, so the operator will output an error if
ingress_host is not provided.
closes pulp#675
  • Loading branch information
git-hyagi authored and openshift-merge-robot committed Dec 2, 2022
1 parent 08ebb9a commit dc1687d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/675.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a check for `ingress_host` being null when `ingress_type` defined as "ingress".
16 changes: 14 additions & 2 deletions controllers/repo_manager/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,26 @@ func (r *RepoManagerReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, err
}

// If ingress_type==ingress the operator should fail in case no ingress_class provided
// To avoid errors with clusters configured without or with multiple default IngressClass we will ask users to pass an ingress_class
// in case of ingress_type == ingress.
if isIngress(pulp) {

// If ingress_type==ingress the operator should fail in case no ingress_class provided
// To avoid errors with clusters configured without or with multiple default IngressClass we will ask users to pass an ingress_class
if len(pulp.Spec.IngressClassName) == 0 {
log.Error(nil, "ingress_type defined as ingress but no ingress_class_name provided.")
return ctrl.Result{}, fmt.Errorf("please, define the ingress_class_name field (with the name of the IngressClass that the operator should use to deploy the new Ingress) to avoid unexpected errors with multiple controllers available")
}

// the operator should also fail in case no ingress_host is provided
// ingress_host is used to populate CONTENT_ORIGIN and ANSIBLE_API_HOSTNAME vars from settings.py
// https://docs.pulpproject.org/pulpcore/configuration/settings.html#content-origin
// "A required string containing the protocol, fqdn, and port where the content app is reachable by users.
// This is used by pulpcore and various plugins when referring users to the content app."
if len(pulp.Spec.IngressHost) == 0 {
log.Error(nil, "ingress_type defined as ingress but no ingress_host provided.")
return ctrl.Result{}, fmt.Errorf("please, define the ingress_host field with the fqdn where " + pulp.Spec.DeploymentType + " should be accessed. This field is required to access API and also redirect " + pulp.Spec.DeploymentType + " CONTENT requests")
}

}

// Checking if there is more than one storage type defined.
Expand Down

0 comments on commit dc1687d

Please sign in to comment.