You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/10/17 07:13:36 UTC

[camel-k] branch main updated: fix(ctrl): Change reconciliation of int in error

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 77b029077 fix(ctrl): Change reconciliation of int in error
77b029077 is described below

commit 77b029077d35d7e4d2881d0c67ca23f9eafac8af
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Mon Oct 2 16:52:06 2023 +0200

    fix(ctrl): Change reconciliation of int in error
    
    * When the integration is in Error with the Kit condition in error, then if the integration kit referenced is still in error then finish the reconciliation process without any change to the integration.
---
 pkg/controller/integration/monitor.go | 17 +++++++++++++++++
 pkg/trait/health.go                   |  4 ++++
 pkg/trait/jvm.go                      |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index 04d539174..dfcb30d37 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -81,6 +81,12 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
 			integration.Status.IntegrationKit.Namespace, integration.Status.IntegrationKit.Name, err)
 	}
 
+	// If integration is in error and its kit is also in error then integration does not change
+	if isInIntegrationKitFailed(integration.Status) &&
+		kit.Status.Phase == v1.IntegrationKitPhaseError {
+		return nil, nil
+	}
+
 	// Check if the Integration requires a rebuild
 	if changed, err := action.checkDigestAndRebuild(ctx, integration, kit); err != nil {
 		return nil, err
@@ -177,6 +183,17 @@ func isInInitializationFailed(status v1.IntegrationStatus) bool {
 	return false
 }
 
+func isInIntegrationKitFailed(status v1.IntegrationStatus) bool {
+	if cond := status.GetCondition(v1.IntegrationConditionKitAvailable); cond != nil {
+		if cond.Status == corev1.ConditionFalse &&
+			status.Phase != v1.IntegrationPhaseError {
+			return true
+		}
+	}
+
+	return false
+}
+
 func (action *monitorAction) checkDigestAndRebuild(ctx context.Context, integration *v1.Integration, kit *v1.IntegrationKit) (*v1.Integration, error) {
 	secrets, configmaps := getIntegrationSecretsAndConfigmaps(ctx, action.client, integration)
 	hash, err := digest.ComputeForIntegration(integration, configmaps, secrets)
diff --git a/pkg/trait/health.go b/pkg/trait/health.go
index 59a8fce3a..bf8350e4b 100644
--- a/pkg/trait/health.go
+++ b/pkg/trait/health.go
@@ -18,6 +18,7 @@ limitations under the License.
 package trait
 
 import (
+	"fmt"
 	"sort"
 
 	corev1 "k8s.io/api/core/v1"
@@ -81,6 +82,9 @@ func (t *healthTrait) Apply(e *Environment) error {
 	}
 
 	container := e.GetIntegrationContainer()
+	if container == nil {
+		return fmt.Errorf("unable to find integration container: %s", e.Integration.Name)
+	}
 	var port *intstr.IntOrString
 	// Use the default named HTTP container port if it exists.
 	// For Knative, the Serving webhook is responsible for setting the user-land port,
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 720d22f64..8a6968736 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -124,7 +124,7 @@ func (t *jvmTrait) Apply(e *Environment) error {
 
 	container := e.GetIntegrationContainer()
 	if container == nil {
-		return fmt.Errorf("unable to find integration container")
+		return fmt.Errorf("unable to find integration container: %s", e.Integration.Name)
 	}
 
 	// Build the container command