diff --git a/pkg/apis/eventing/v1alpha1/requestreply_defaults.go b/pkg/apis/eventing/v1alpha1/requestreply_defaults.go index ee73d0d6a7c..c05f915d104 100644 --- a/pkg/apis/eventing/v1alpha1/requestreply_defaults.go +++ b/pkg/apis/eventing/v1alpha1/requestreply_defaults.go @@ -20,6 +20,7 @@ import ( "context" "k8s.io/utils/ptr" + "knative.dev/eventing/pkg/apis/feature" "knative.dev/pkg/apis" ) @@ -30,7 +31,7 @@ func (rr *RequestReply) SetDefaults(ctx context.Context) { func (rrs *RequestReplySpec) SetDefaults(ctx context.Context) { if rrs.Timeout == nil || *rrs.Timeout == "" { - rrs.Timeout = ptr.To("30s") + rrs.Timeout = ptr.To(feature.FromContextOrDefaults(ctx).RequestReplyDefaultTimeout()) } if rrs.CorrelationAttribute == "" { diff --git a/pkg/apis/feature/features.go b/pkg/apis/feature/features.go index 98eeb2907ca..db162838e05 100644 --- a/pkg/apis/feature/features.go +++ b/pkg/apis/feature/features.go @@ -67,6 +67,10 @@ const ( // DefaultOIDCDiscoveryURL is the default OIDC Discovery URL used in most Kubernetes clusters. DefaultOIDCDiscoveryBaseURL Flag = "https://kubernetes.default.svc" + + // DefaultRequestReplyTimeout is a value for RequestReplyDefaultTimeout that indicates to timeout + // a RequestReply resource after 30 seconds by default. + DefaultRequestReplyTimeout Flag = "30s" ) // Flags is a map containing all the enabled/disabled flags for the experimental features. @@ -75,16 +79,17 @@ type Flags map[string]Flag func newDefaults() Flags { return map[string]Flag{ - KReferenceGroup: Disabled, - DeliveryRetryAfter: Disabled, - DeliveryTimeout: Enabled, - KReferenceMapping: Disabled, - TransportEncryption: Disabled, - OIDCAuthentication: Disabled, - EvenTypeAutoCreate: Disabled, - NewAPIServerFilters: Disabled, - AuthorizationDefaultMode: AuthorizationAllowSameNamespace, - OIDCDiscoveryBaseURL: DefaultOIDCDiscoveryBaseURL, + KReferenceGroup: Disabled, + DeliveryRetryAfter: Disabled, + DeliveryTimeout: Enabled, + KReferenceMapping: Disabled, + TransportEncryption: Disabled, + OIDCAuthentication: Disabled, + EvenTypeAutoCreate: Disabled, + NewAPIServerFilters: Disabled, + AuthorizationDefaultMode: AuthorizationAllowSameNamespace, + OIDCDiscoveryBaseURL: DefaultOIDCDiscoveryBaseURL, + RequestReplyDefaultTimeout: DefaultRequestReplyTimeout, } } @@ -151,6 +156,19 @@ func (e Flags) OIDCDiscoveryBaseURL() string { return string(discoveryUrl) } +func (e Flags) RequestReplyDefaultTimeout() string { + if e == nil { + return string(DefaultRequestReplyTimeout) + } + + timeout, ok := e[RequestReplyDefaultTimeout] + if !ok { + return string(DefaultRequestReplyTimeout) + } + + return string(timeout) // TODO, check this, check this whole function really +} + func (e Flags) String() string { return fmt.Sprintf("%+v", map[string]Flag(e)) } diff --git a/pkg/apis/feature/flag_names.go b/pkg/apis/feature/flag_names.go index e21056eb444..b6cc1b750fc 100644 --- a/pkg/apis/feature/flag_names.go +++ b/pkg/apis/feature/flag_names.go @@ -17,16 +17,18 @@ limitations under the License. package feature const ( - KReferenceGroup = "kreference-group" - DeliveryRetryAfter = "delivery-retryafter" - DeliveryTimeout = "delivery-timeout" - KReferenceMapping = "kreference-mapping" - TransportEncryption = "transport-encryption" - EvenTypeAutoCreate = "eventtype-auto-create" - OIDCAuthentication = "authentication-oidc" - NodeSelectorLabel = "apiserversources-nodeselector-" - CrossNamespaceEventLinks = "cross-namespace-event-links" - NewAPIServerFilters = "new-apiserversource-filters" - AuthorizationDefaultMode = "default-authorization-mode" - OIDCDiscoveryBaseURL = "oidc-discovery-base-url" + KReferenceGroup = "kreference-group" + DeliveryRetryAfter = "delivery-retryafter" + DeliveryTimeout = "delivery-timeout" + KReferenceMapping = "kreference-mapping" + TransportEncryption = "transport-encryption" + EvenTypeAutoCreate = "eventtype-auto-create" + OIDCAuthentication = "authentication-oidc" + NodeSelectorLabel = "apiserversources-nodeselector-" + CrossNamespaceEventLinks = "cross-namespace-event-links" + NewAPIServerFilters = "new-apiserversource-filters" + AuthorizationDefaultMode = "default-authorization-mode" + OIDCDiscoveryBaseURL = "oidc-discovery-base-url" + RequestReplyDefaultTimeout = "requestreply-default-timeout" // TODO check this + )