Skip to content

Commit

Permalink
fix(ctrl): Change reconciliation of int in error
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
gansheer authored and squakez committed Oct 17, 2023
1 parent 183dd91 commit 77b0290
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pkg/controller/integration/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions pkg/trait/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package trait

import (
"fmt"
"sort"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/trait/jvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77b0290

Please sign in to comment.