Skip to content

Commit

Permalink
Added feature flag for default timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMamoukarys committed Dec 1, 2024
1 parent 7176ce6 commit 65929f1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
3 changes: 2 additions & 1 deletion pkg/apis/eventing/v1alpha1/requestreply_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"

"k8s.io/utils/ptr"
"knative.dev/eventing/pkg/apis/feature"
"knative.dev/pkg/apis"
)

Expand All @@ -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 == "" {
Expand Down
38 changes: 28 additions & 10 deletions pkg/apis/feature/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
}
}

Expand Down Expand Up @@ -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))
}
Expand Down
26 changes: 14 additions & 12 deletions pkg/apis/feature/flag_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

)

0 comments on commit 65929f1

Please sign in to comment.