Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#5652) Added TimeoutSeconds to knative-serving trait #5653

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -7619,6 +7619,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 @@ -1496,6 +1496,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 @@ -3510,6 +3517,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 @@ -1373,6 +1373,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 @@ -3270,6 +3277,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 @@ -7437,6 +7437,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 @@ -7730,6 +7730,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 @@ -7728,6 +7728,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 @@ -1496,6 +1496,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 @@ -3510,6 +3517,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 @@ -1373,6 +1373,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 @@ -3270,6 +3277,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 @@ -7437,6 +7437,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 @@ -7730,6 +7730,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 @@ -7728,6 +7728,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