From 77b029077d35d7e4d2881d0c67ca23f9eafac8af Mon Sep 17 00:00:00 2001 From: Gaelle Fournier Date: Mon, 2 Oct 2023 16:52:06 +0200 Subject: [PATCH] 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 04d5391742..dfcb30d37a 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 59a8fce3a2..bf8350e4b7 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 720d22f643..8a69687368 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