diff --git a/go.mod b/go.mod index ab82f9ad026..d1e1d87753c 100644 --- a/go.mod +++ b/go.mod @@ -47,8 +47,8 @@ require ( k8s.io/utils v0.0.0-20230209194617-a36077c30491 knative.dev/hack v0.0.0-20231102183416-0d99b7ee9d63 knative.dev/hack/schema v0.0.0-20231102183416-0d99b7ee9d63 - knative.dev/pkg v0.0.0-20231106073528-acf0a2d2dea9 - knative.dev/reconciler-test v0.0.0-20231103063332-212f3db95925 + knative.dev/pkg v0.0.0-20231107094615-5c9b7a8d8265 + knative.dev/reconciler-test v0.0.0-20231107120858-d2429fb0b545 sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index ec32df80ae8..96b9e08b86a 100644 --- a/go.sum +++ b/go.sum @@ -849,10 +849,10 @@ knative.dev/hack v0.0.0-20231102183416-0d99b7ee9d63 h1:QNbIbsep8jreNCXj3EFrsw0Rt knative.dev/hack v0.0.0-20231102183416-0d99b7ee9d63/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= knative.dev/hack/schema v0.0.0-20231102183416-0d99b7ee9d63 h1:Kya5aD2/qIvQJBJv+ckrQfIBFLZ99gFr8ow+V6i4ZZY= knative.dev/hack/schema v0.0.0-20231102183416-0d99b7ee9d63/go.mod h1:3pWwBLnTZSM9psSgCAvhKOHIPTzqfEMlWRpDu6IYhK0= -knative.dev/pkg v0.0.0-20231106073528-acf0a2d2dea9 h1:9JQb0ETlOXxtXb6zeJuvjcdsI5BQ83Rv1PEzIzC8B8U= -knative.dev/pkg v0.0.0-20231106073528-acf0a2d2dea9/go.mod h1:jCNm6Y66ArM8uDqpHwRwW7LuMFn79Q3KIn5L1R/WfI4= -knative.dev/reconciler-test v0.0.0-20231103063332-212f3db95925 h1:Iz7vRfFWMK2nu1znle0uXHg5bRPwCTAVFVwKir0tBl0= -knative.dev/reconciler-test v0.0.0-20231103063332-212f3db95925/go.mod h1:Ok0TfApVs8qkbytYq70Q7aetM21J3L41x9c3HKI/U1I= +knative.dev/pkg v0.0.0-20231107094615-5c9b7a8d8265 h1:wFDUSmvSQF48tUCIUIFKMOxq9jpV+vXf5l+RZYxYyt4= +knative.dev/pkg v0.0.0-20231107094615-5c9b7a8d8265/go.mod h1:P3m1Mg/FJjmr9oFHfWcoUbJLSlBi/hgwakobPxyqrZ4= +knative.dev/reconciler-test v0.0.0-20231107120858-d2429fb0b545 h1:0F0E77IbX5XxCxZ19Gopygwy+b6pVktrYAzMcFnVhK4= +knative.dev/reconciler-test v0.0.0-20231107120858-d2429fb0b545/go.mod h1:R7GebYEQbys4NXZJa0EzYx6+Hw3LZduuDkvp8FdBPU8= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/vendor/knative.dev/reconciler-test/pkg/environment/timings.go b/vendor/knative.dev/reconciler-test/pkg/environment/timings.go index aac96e82813..bf4409b06c4 100644 --- a/vendor/knative.dev/reconciler-test/pkg/environment/timings.go +++ b/vendor/knative.dev/reconciler-test/pkg/environment/timings.go @@ -19,37 +19,26 @@ package environment import ( "context" "time" + + "knative.dev/reconciler-test/pkg/state" ) +// this has been moved to state pkg to break cycle between environment and feature package, +// keeping the consts here for backwards API compatibility const ( DefaultPollInterval = 3 * time.Second DefaultPollTimeout = 2 * time.Minute ) -type timingsKey struct{} -type timingsType struct { - interval time.Duration - timeout time.Duration -} - -// PollTimingsFromContext will get the previously set poll timing from context, -// or return the defaults if not found. -// - values from from context. -// - defaults. +// ContextWithPollTimings returns a context with poll timings set func ContextWithPollTimings(ctx context.Context, interval, timeout time.Duration) context.Context { - return context.WithValue(ctx, timingsKey{}, timingsType{ - interval: interval, - timeout: timeout, - }) + return state.ContextWithPollTimings(ctx, interval, timeout) } // PollTimingsFromContext will get the previously set poll timing from context, // or return the defaults if not found. -// - values from from context. +// - values from context. // - defaults. func PollTimingsFromContext(ctx context.Context) (time.Duration, time.Duration) { - if t, ok := ctx.Value(timingsKey{}).(timingsType); ok { - return t.interval, t.timeout - } - return DefaultPollInterval, DefaultPollTimeout + return state.PollTimingsFromContext(ctx) } diff --git a/vendor/knative.dev/reconciler-test/pkg/feature/feature.go b/vendor/knative.dev/reconciler-test/pkg/feature/feature.go index 4113bc3d0d4..0d454c51723 100644 --- a/vendor/knative.dev/reconciler-test/pkg/feature/feature.go +++ b/vendor/knative.dev/reconciler-test/pkg/feature/feature.go @@ -23,7 +23,6 @@ import ( "runtime" "strings" "sync" - "time" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -32,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "knative.dev/pkg/apis" "knative.dev/pkg/injection/clients/dynamicclient" - "knative.dev/reconciler-test/pkg/state" ) @@ -229,7 +227,8 @@ func DeleteResources(ctx context.Context, t T, refs []corev1.ObjectReference) er var lastResource corev1.ObjectReference // One still present resource - err := wait.Poll(time.Second, 4*time.Minute, func() (bool, error) { + interval, timeout := state.PollTimingsFromContext(ctx) + err := wait.Poll(interval, timeout, func() (bool, error) { for _, ref := range refs { gv, err := schema.ParseGroupVersion(ref.APIVersion) if err != nil { diff --git a/vendor/knative.dev/reconciler-test/pkg/state/timings.go b/vendor/knative.dev/reconciler-test/pkg/state/timings.go new file mode 100644 index 00000000000..88a3dc1e6d2 --- /dev/null +++ b/vendor/knative.dev/reconciler-test/pkg/state/timings.go @@ -0,0 +1,52 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package state + +import ( + "context" + "time" +) + +const ( + DefaultPollInterval = 3 * time.Second + DefaultPollTimeout = 2 * time.Minute +) + +type timingsKey struct{} +type timingsType struct { + interval time.Duration + timeout time.Duration +} + +// ContextWithPollTimings returns a context with poll timings set +func ContextWithPollTimings(ctx context.Context, interval, timeout time.Duration) context.Context { + return context.WithValue(ctx, timingsKey{}, timingsType{ + interval: interval, + timeout: timeout, + }) +} + +// PollTimingsFromContext will get the previously set poll timing from context, +// or return the defaults if not found. +// - values from context. +// - defaults. +func PollTimingsFromContext(ctx context.Context) (time.Duration, time.Duration) { + if t, ok := ctx.Value(timingsKey{}).(timingsType); ok { + return t.interval, t.timeout + } + return DefaultPollInterval, DefaultPollTimeout +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1ef2249c97a..5de92e19427 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1211,7 +1211,7 @@ knative.dev/hack/schema/commands knative.dev/hack/schema/docs knative.dev/hack/schema/registry knative.dev/hack/schema/schema -# knative.dev/pkg v0.0.0-20231106073528-acf0a2d2dea9 +# knative.dev/pkg v0.0.0-20231107094615-5c9b7a8d8265 ## explicit; go 1.18 knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate @@ -1350,7 +1350,7 @@ knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/conversion knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/reconciler-test v0.0.0-20231103063332-212f3db95925 +# knative.dev/reconciler-test v0.0.0-20231107120858-d2429fb0b545 ## explicit; go 1.20 knative.dev/reconciler-test/cmd/eventshub knative.dev/reconciler-test/pkg/environment