Skip to content

Commit

Permalink
Added TimeoutSeconds to knative-serving trait
Browse files Browse the repository at this point in the history
  • Loading branch information
hernanDatgDev authored and squakez committed Jun 19, 2024
1 parent bf88ee6 commit 9c45e36
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7633,6 +7633,16 @@ Automatically deploy the integration as Knative service when all conditions hold
* Integration is using the Knative profile
* All routes are either starting from an HTTP based consumer or a passive consumer (e.g. `direct` is a passive consumer)
|`timeoutSeconds` +
int64
|
The maximum duration in seconds that the request instance is allowed to respond to a request.
This field propagates to the integration pod's terminationGracePeriodSeconds
Refer to the Knative documentation for more information.
|===
Expand Down
7 changes: 7 additions & 0 deletions docs/modules/traits/pages/knative-service.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ Refer to the Knative documentation for more information.
* Integration is using the Knative profile
* All routes are either starting from an HTTP based consumer or a passive consumer (e.g. `direct` is a passive consumer)

| knative-service.timeout-seconds
| int64
| The maximum duration in seconds that the request instance is allowed to respond to a request.
This field propagates to the integration pod's terminationGracePeriodSeconds

Refer to the Knative documentation for more information.

|===

// End of autogenerated code - DO NOT EDIT! (configuration)
14 changes: 14 additions & 0 deletions helm/camel-k/crds/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down Expand Up @@ -3526,6 +3533,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down
14 changes: 14 additions & 0 deletions helm/camel-k/crds/crd-integration-profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down Expand Up @@ -3286,6 +3293,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down
7 changes: 7 additions & 0 deletions helm/camel-k/crds/crd-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7445,6 +7445,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down
7 changes: 7 additions & 0 deletions helm/camel-k/crds/crd-kamelet-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7738,6 +7738,13 @@ spec:
`time.Duration` string representation, rounded to a
second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the
request instance is allowed to respond to a request.
This field propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service
becomes a private service. Specifically, this option
Expand Down
7 changes: 7 additions & 0 deletions helm/camel-k/crds/crd-pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7736,6 +7736,13 @@ spec:
`time.Duration` string representation, rounded to a
second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the
request instance is allowed to respond to a request.
This field propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service
becomes a private service. Specifically, this option
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/camel/v1/trait/knative_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ type KnativeServiceTrait struct {
// * Integration is using the Knative profile
// * All routes are either starting from an HTTP based consumer or a passive consumer (e.g. `direct` is a passive consumer)
Auto *bool `property:"auto" json:"auto,omitempty"`
// The maximum duration in seconds that the request instance is allowed to respond to a request.
// This field propagates to the integration pod's terminationGracePeriodSeconds
//
// Refer to the Knative documentation for more information.
TimeoutSeconds *int64 `property:"timeout-seconds" json:"timeoutSeconds,omitempty"`
}
5 changes: 5 additions & 0 deletions pkg/apis/camel/v1/trait/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down Expand Up @@ -3526,6 +3533,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down Expand Up @@ -3286,6 +3293,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7445,6 +7445,13 @@ spec:
default and must be expressed as a Golang `time.Duration`
string representation, rounded to a second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the request
instance is allowed to respond to a request. This field
propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service becomes
a private service. Specifically, this option applies the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7738,6 +7738,13 @@ spec:
`time.Duration` string representation, rounded to a
second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the
request instance is allowed to respond to a request.
This field propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service
becomes a private service. Specifically, this option
Expand Down
7 changes: 7 additions & 0 deletions pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7736,6 +7736,13 @@ spec:
`time.Duration` string representation, rounded to a
second precision.
type: string
timeoutSeconds:
description: "The maximum duration in seconds that the
request instance is allowed to respond to a request.
This field propagates to the integration pod's terminationGracePeriodSeconds
\n Refer to the Knative documentation for more information."
format: int64
type: integer
visibility:
description: "Setting `cluster-local`, Knative service
becomes a private service. Specifically, this option
Expand Down
3 changes: 3 additions & 0 deletions pkg/trait/knative_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ func (t *knativeServiceTrait) getServiceFor(e *Environment) (*serving.Service, e
},
}

if t.TimeoutSeconds != nil {
svc.Spec.ConfigurationSpec.Template.Spec.TimeoutSeconds = t.TimeoutSeconds
}
replicas := e.Integration.Spec.Replicas

isUpdateRequired := false
Expand Down
16 changes: 16 additions & 0 deletions pkg/trait/knative_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,22 @@ func TestKnativeServiceWithVisibility(t *testing.T) {
assert.Equal(t, ksvc.Labels[knativeServingVisibilityLabel], "cluster-local")
}

func TestKnativeServiceWithTimeoutSeconds(t *testing.T) {
timeoutSeconds := int64(44)
environment := createKnativeServiceTestEnvironment(t, &traitv1.KnativeServiceTrait{
TimeoutSeconds: &timeoutSeconds,
})
assert.NotEmpty(t, environment.ExecutedTraits)
assert.NotNil(t, environment.GetTrait("knative-service"))

ksvc := environment.Resources.GetKnativeService(func(service *serving.Service) bool {
return service.Name == KnativeServiceTestName
})
assert.NotNil(t, ksvc)

assert.Equal(t, *ksvc.Spec.Template.Spec.TimeoutSeconds, int64(44))
}

func createKnativeServiceTestEnvironment(t *testing.T, trait *traitv1.KnativeServiceTrait) *Environment {
t.Helper()

Expand Down

0 comments on commit 9c45e36

Please sign in to comment.