Skip to content

Commit

Permalink
fix(e2e): adding failure on catalog error
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Oct 4, 2023
1 parent e4ae42e commit 301bacd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/camel/v1/integration_types_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (in *Integration) SetIntegrationKit(kit *IntegrationKit) {
message = "creating a new integration kit"
} else {
message = fmt.Sprintf("integration kit %s/%s is in state %q", kit.Namespace, kit.Name, kit.Status.Phase)
if kit.Status.Phase == IntegrationKitPhaseError {
if kit.Status.Phase == IntegrationKitPhaseError && kit.Status.Failure != nil {
// Append specific reason for the failure
message = message + ". Failure: " + kit.Status.Failure.Reason
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/controller/integrationkit/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/apache/camel-k/v2/pkg/util/defaults"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NewInitializeAction creates a new initialization handling action for the kit.
Expand Down Expand Up @@ -76,12 +77,18 @@ func (action *initializeAction) Handle(ctx context.Context, kit *v1.IntegrationK
}

if catalog.Status.Phase == v1.CamelCatalogPhaseError {
errorReason := fmt.Sprintf("Camel Catalog %s error", catalog.Spec.Runtime.Version)
kit.Status.Phase = v1.IntegrationKitPhaseError
kit.Status.SetErrorCondition(
v1.IntegrationKitConditionCatalogAvailable,
fmt.Sprintf("Camel Catalog %s error", catalog.Spec.Runtime.Version),
errorReason,
fmt.Errorf("%s", catalog.Status.GetCondition(v1.CamelCatalogConditionReady).Reason),
)
// Adding the failure in order to include this info in the Integration as well
kit.Status.Failure = &v1.Failure{
Reason: errorReason,
Time: metav1.Now(),
}
return kit, nil
}

Expand Down

0 comments on commit 301bacd

Please sign in to comment.