Skip to content

Commit 61c7bca

Browse files
Return error message if IngressDomain configuration not set
1 parent 26be493 commit 61c7bca

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func main() {
115115
},
116116
KubeRay: &config.KubeRayConfiguration{
117117
RayDashboardOAuthEnabled: pointer.Bool(true),
118-
IngressDomain: "fake.domain",
118+
IngressDomain: "",
119119
},
120120
}
121121

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type CodeFlareOperatorConfiguration struct {
3434
type KubeRayConfiguration struct {
3535
RayDashboardOAuthEnabled *bool `json:"rayDashboardOAuthEnabled,omitempty"`
3636

37-
IngressDomain string `json:"ingressDomain,omitempty"`
37+
IngressDomain string `json:"ingressDomain"`
3838
}
3939

4040
type ControllerManager struct {

pkg/controllers/raycluster_controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,23 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
187187
logger.Info("We detected being on Vanilla Kubernetes!")
188188
logger.Info("Creating Dashboard Ingress")
189189
dashboardName := dashboardNameFromCluster(&cluster)
190-
_, err := r.kubeClient.NetworkingV1().Ingresses(cluster.Namespace).Apply(ctx, desiredClusterIngress(&cluster, r.getIngressHost(ctx, r.kubeClient, &cluster, dashboardName)), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
190+
dashboardIngressHost, err := r.getIngressHost(ctx, r.kubeClient, &cluster, dashboardName)
191+
if err != nil {
192+
return ctrl.Result{RequeueAfter: requeueTime}, err
193+
}
194+
_, err = r.kubeClient.NetworkingV1().Ingresses(cluster.Namespace).Apply(ctx, desiredClusterIngress(&cluster, dashboardIngressHost), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
191195
if err != nil {
192196
// This log is info level since errors are not fatal and are expected
193197
logger.Info("WARN: Failed to update Dashboard Ingress", "error", err.Error(), logRequeueing, true)
194198
return ctrl.Result{RequeueAfter: requeueTime}, err
195199
}
196200
logger.Info("Creating RayClient Ingress")
197201
rayClientName := rayClientNameFromCluster(&cluster)
198-
_, err = r.kubeClient.NetworkingV1().Ingresses(cluster.Namespace).Apply(ctx, desiredRayClientIngress(&cluster, r.getIngressHost(ctx, r.kubeClient, &cluster, rayClientName)), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
202+
rayClientIngressHost, err := r.getIngressHost(ctx, r.kubeClient, &cluster, rayClientName)
203+
if err != nil {
204+
return ctrl.Result{RequeueAfter: requeueTime}, err
205+
}
206+
_, err = r.kubeClient.NetworkingV1().Ingresses(cluster.Namespace).Apply(ctx, desiredRayClientIngress(&cluster, rayClientIngressHost), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
199207
if err != nil {
200208
logger.Error(err, "Failed to update RayClient Ingress")
201209
return ctrl.Result{RequeueAfter: requeueTime}, err

pkg/controllers/support.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,17 @@ func isOpenShift(ctx context.Context, clientset *kubernetes.Clientset, cluster *
139139
}
140140

141141
// getIngressHost generates the cluster URL string based on the cluster type, RayCluster, and ingress domain.
142-
func (r *RayClusterReconciler) getIngressHost(ctx context.Context, clientset *kubernetes.Clientset, cluster *rayv1.RayCluster, ingressNameFromCluster string) string {
143-
ingressDomain := "fake.domain"
142+
func (r *RayClusterReconciler) getIngressHost(ctx context.Context, clientset *kubernetes.Clientset, cluster *rayv1.RayCluster, ingressNameFromCluster string) (string, error) {
143+
ingressDomain := ""
144144
if r.Config != nil && r.Config.IngressDomain != "" {
145145
ingressDomain = r.Config.IngressDomain
146+
} else {
147+
return "", fmt.Errorf("missing IngressDomain configuration in ConfigMap 'codeflare-operator-config'")
146148
}
147149
if ingressDomain == "kind" {
148-
return ingressDomain
150+
return ingressDomain, nil
149151
}
150-
return fmt.Sprintf("%s-%s.%s", ingressNameFromCluster, cluster.Namespace, ingressDomain)
152+
return fmt.Sprintf("%s-%s.%s", ingressNameFromCluster, cluster.Namespace, ingressDomain), nil
151153
}
152154

153155
func (r *RayClusterReconciler) isRayDashboardOAuthEnabled() bool {

0 commit comments

Comments
 (0)