wmedvede commented on code in PR #447:
URL:
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/447#discussion_r1572575215
##########
controllers/profiles/preview/deployment_handler.go:
##########
@@ -44,88 +44,124 @@ func NewDeploymentReconciler(stateSupport
*common.StateSupport, ensurer *ObjectE
}
func (d *DeploymentReconciler) Reconcile(ctx context.Context, workflow
*operatorapi.SonataFlow) (reconcile.Result, []client.Object, error) {
- return d.reconcileWithBuiltImage(ctx, workflow, "")
+ return d.reconcileWithImage(ctx, workflow, "")
}
-func (d *DeploymentReconciler) reconcileWithBuiltImage(ctx context.Context,
workflow *operatorapi.SonataFlow, image string) (reconcile.Result,
[]client.Object, error) {
+func (d *DeploymentReconciler) reconcileWithImage(ctx context.Context,
workflow *operatorapi.SonataFlow, image string) (reconcile.Result,
[]client.Object, error) {
+ // Checks if we need Knative installed
+ if requires, err := d.ensureKnativeServingRequired(workflow); requires
|| err != nil {
+ return reconcile.Result{Requeue: false}, nil, err
+ }
+
+ // Ensure objects
+ result, objs, err := d.ensureObjects(ctx, workflow, image)
+ if err != nil || result.Requeue {
+ return result, objs, err
+ }
+
+ // Follow deployment status
+ result, err = common.DeploymentManager(d.C).SyncDeploymentStatus(ctx,
workflow)
+ if err != nil {
+ return reconcile.Result{Requeue: false}, nil, err
+ }
+
+ if _, err := d.PerformStatusUpdate(ctx, workflow); err != nil {
+ return reconcile.Result{Requeue: false}, nil, err
+ }
+ return result, objs, nil
+}
+
+// ensureKnativeServingRequired returns true if the SonataFlow instance
requires Knative deployment and Knative Serving is not available.
+func (d *DeploymentReconciler) ensureKnativeServingRequired(workflow
*operatorapi.SonataFlow) (bool, error) {
+ if workflow.IsKnativeDeployment() {
+ avail, err := knative.GetKnativeAvailability(d.Cfg)
Review Comment:
Nice function this GetKnativeAvailability!
##########
controllers/profiles/preview/deployment_handler.go:
##########
@@ -44,88 +44,124 @@ func NewDeploymentReconciler(stateSupport
*common.StateSupport, ensurer *ObjectE
}
func (d *DeploymentReconciler) Reconcile(ctx context.Context, workflow
*operatorapi.SonataFlow) (reconcile.Result, []client.Object, error) {
- return d.reconcileWithBuiltImage(ctx, workflow, "")
+ return d.reconcileWithImage(ctx, workflow, "")
}
-func (d *DeploymentReconciler) reconcileWithBuiltImage(ctx context.Context,
workflow *operatorapi.SonataFlow, image string) (reconcile.Result,
[]client.Object, error) {
+func (d *DeploymentReconciler) reconcileWithImage(ctx context.Context,
workflow *operatorapi.SonataFlow, image string) (reconcile.Result,
[]client.Object, error) {
+ // Checks if we need Knative installed
Review Comment:
```suggestion
// Checks if we need Knative installed and is not present.
```
##########
controllers/profiles/preview/deployment_handler.go:
##########
@@ -44,88 +44,124 @@ func NewDeploymentReconciler(stateSupport
*common.StateSupport, ensurer *ObjectE
}
func (d *DeploymentReconciler) Reconcile(ctx context.Context, workflow
*operatorapi.SonataFlow) (reconcile.Result, []client.Object, error) {
- return d.reconcileWithBuiltImage(ctx, workflow, "")
+ return d.reconcileWithImage(ctx, workflow, "")
}
-func (d *DeploymentReconciler) reconcileWithBuiltImage(ctx context.Context,
workflow *operatorapi.SonataFlow, image string) (reconcile.Result,
[]client.Object, error) {
+func (d *DeploymentReconciler) reconcileWithImage(ctx context.Context,
workflow *operatorapi.SonataFlow, image string) (reconcile.Result,
[]client.Object, error) {
+ // Checks if we need Knative installed
+ if requires, err := d.ensureKnativeServingRequired(workflow); requires
|| err != nil {
+ return reconcile.Result{Requeue: false}, nil, err
+ }
+
+ // Ensure objects
+ result, objs, err := d.ensureObjects(ctx, workflow, image)
+ if err != nil || result.Requeue {
+ return result, objs, err
+ }
+
+ // Follow deployment status
+ result, err = common.DeploymentManager(d.C).SyncDeploymentStatus(ctx,
workflow)
+ if err != nil {
+ return reconcile.Result{Requeue: false}, nil, err
+ }
+
+ if _, err := d.PerformStatusUpdate(ctx, workflow); err != nil {
+ return reconcile.Result{Requeue: false}, nil, err
+ }
+ return result, objs, nil
+}
+
+// ensureKnativeServingRequired returns true if the SonataFlow instance
requires Knative deployment and Knative Serving is not available.
+func (d *DeploymentReconciler) ensureKnativeServingRequired(workflow
*operatorapi.SonataFlow) (bool, error) {
+ if workflow.IsKnativeDeployment() {
+ avail, err := knative.GetKnativeAvailability(d.Cfg)
+ if err != nil {
+ return true, err
+ }
+ if !avail.Serving {
+ d.Recorder.Eventf(workflow, v1.EventTypeWarning,
+ "KnativeServingNotAvailable",
+ "Knative Serving is not available in this
cluster, can't deploy worflow. Please update the deployment model to %s",
Review Comment:
```suggestion
"Knative Serving is not available in this
cluster, can't deploy workflow. Please update the deployment model to %s",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]