squakez commented on code in PR #5245:
URL: https://github.com/apache/camel-k/pull/5245#discussion_r1522631293
##########
pkg/controller/pipe/integration.go:
##########
@@ -120,6 +122,12 @@ func CreateIntegrationFor(ctx context.Context, c
client.Client, binding *v1.Pipe
return nil, fmt.Errorf("could not determine error handler: %w",
err)
}
+ if errorHandler != nil && shouldHandleNoErrorHandler(ctx, c, &it) {
Review Comment:
This piece of code, if any, has to go to the error handler trait. It does
not belong to the Controlller IMO.
##########
pkg/controller/pipe/integration_test.go:
##########
@@ -54,6 +55,78 @@ func TestCreateIntegrationForPipe(t *testing.T) {
assert.Equal(t, expectedNominalRoute(), string(dsl))
}
+func TestCreateIntegrationForPipeWithSinkErrorHandler(t *testing.T) {
+ client, err := test.NewFakeClient()
+ require.NoError(t, err)
+
+ pipe := nominalPipe("my-error-handler-pipe")
+ pipe.Spec.Integration = &v1.IntegrationSpec{
+ Traits: v1.Traits{
+ Camel: &trait.CamelTrait{
+ RuntimeVersion: "3.8.0-SNAPSHOT", // forces
noErrorHandler=false property
Review Comment:
Probably you want to put `defaults.RuntimeVersion` here.
##########
pkg/controller/pipe/integration.go:
##########
@@ -210,6 +218,27 @@ func CreateIntegrationFor(ctx context.Context, c
client.Client, binding *v1.Pipe
return &it, nil
}
+// shouldHandleNoErrorHandler determines the runtime version and checks on
noErrorHandler that is configured for this version.
+func shouldHandleNoErrorHandler(ctx context.Context, c client.Client, it
*v1.Integration) bool {
+ var runtimeVersion string
+ if it.Spec.Traits.Camel != nil && it.Spec.Traits.Camel.RuntimeVersion
!= "" {
+ runtimeVersion = it.Spec.Traits.Camel.RuntimeVersion
+ } else if pl, err := platform.GetForResource(ctx, c, it); err == nil &&
pl != nil {
Review Comment:
No need to peek the platform. At trait level stage, we must have already set
the Integration.Status.RuntimeVersion.
##########
pkg/controller/pipe/integration.go:
##########
@@ -210,6 +218,27 @@ func CreateIntegrationFor(ctx context.Context, c
client.Client, binding *v1.Pipe
return &it, nil
}
+// shouldHandleNoErrorHandler determines the runtime version and checks on
noErrorHandler that is configured for this version.
+func shouldHandleNoErrorHandler(ctx context.Context, c client.Client, it
*v1.Integration) bool {
+ var runtimeVersion string
+ if it.Spec.Traits.Camel != nil && it.Spec.Traits.Camel.RuntimeVersion
!= "" {
+ runtimeVersion = it.Spec.Traits.Camel.RuntimeVersion
+ } else if pl, err := platform.GetForResource(ctx, c, it); err == nil &&
pl != nil {
+ runtimeVersion = pl.Status.Build.RuntimeVersion
+ }
+
+ if runtimeVersion != "" {
+ runtimeVersion, _ = strings.CutSuffix(runtimeVersion,
"-SNAPSHOT")
+ if versionNumber, err :=
strconv.Atoi(strings.ReplaceAll(runtimeVersion, ".", "")); err == nil {
Review Comment:
this would fail for those version that have suffix, ie,
`3.8.0-my-companytag`.
--
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]