From e9b3431bc64761c42275fcae0ae6b26242aa4ce7 Mon Sep 17 00:00:00 2001 From: Akanksha Trehun Date: Wed, 16 Sep 2026 00:42:15 +0530 Subject: [PATCH] Log a warning when remote-deployments-poll-interval gets clamped The flag help text and README both document that values below 1s fall back to the default with a warning, but the code only clamped the value silently, so a misconfigured flag gave no signal at all. Signed-off-by: Akanksha Trehun --- pkg/reconciler/common/poll_interval_flag.go | 6 +++++ .../common/poll_interval_flag_test.go | 26 +++++++++++++++++++ pkg/reconciler/knativeeventing/controller.go | 3 +++ pkg/reconciler/knativeserving/controller.go | 3 +++ 4 files changed, 38 insertions(+) diff --git a/pkg/reconciler/common/poll_interval_flag.go b/pkg/reconciler/common/poll_interval_flag.go index 301ca3bb4..b4307b1da 100644 --- a/pkg/reconciler/common/poll_interval_flag.go +++ b/pkg/reconciler/common/poll_interval_flag.go @@ -40,3 +40,9 @@ func RemoteDeploymentsPollIntervalValue() time.Duration { } return remoteDeploymentsPollIntervalFlag } + +// RemoteDeploymentsPollIntervalWasClamped reports whether the configured +// remote-deployments-poll-interval value was below 1s and fell back to the default. +func RemoteDeploymentsPollIntervalWasClamped() bool { + return remoteDeploymentsPollIntervalFlag < time.Second +} diff --git a/pkg/reconciler/common/poll_interval_flag_test.go b/pkg/reconciler/common/poll_interval_flag_test.go index 142830a34..57419daa1 100644 --- a/pkg/reconciler/common/poll_interval_flag_test.go +++ b/pkg/reconciler/common/poll_interval_flag_test.go @@ -45,3 +45,29 @@ func TestRemoteDeploymentsPollIntervalValue(t *testing.T) { }) } } + +func TestRemoteDeploymentsPollIntervalWasClamped(t *testing.T) { + cases := []struct { + name string + flag time.Duration + want bool + }{ + {"default", defaultRemoteDeploymentsPollInterval, false}, + {"valid override", 30 * time.Second, false}, + {"exactly one second", time.Second, false}, + {"below threshold", 500 * time.Millisecond, true}, + {"zero", 0, true}, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + prev := remoteDeploymentsPollIntervalFlag + remoteDeploymentsPollIntervalFlag = tc.flag + t.Cleanup(func() { remoteDeploymentsPollIntervalFlag = prev }) + + if got := RemoteDeploymentsPollIntervalWasClamped(); got != tc.want { + t.Errorf("RemoteDeploymentsPollIntervalWasClamped() = %v, want %v", got, tc.want) + } + }) + } +} diff --git a/pkg/reconciler/knativeeventing/controller.go b/pkg/reconciler/knativeeventing/controller.go index e09a689b2..8d6503a1c 100644 --- a/pkg/reconciler/knativeeventing/controller.go +++ b/pkg/reconciler/knativeeventing/controller.go @@ -62,6 +62,9 @@ func NewExtendedController(generator common.ExtensionGenerator) injection.Contro kubeClient := kubeclient.Get(ctx) logger := logging.FromContext(ctx) logger.Infof("Remote deployments poll interval: %s", common.RemoteDeploymentsPollIntervalValue()) + if common.RemoteDeploymentsPollIntervalWasClamped() { + logger.Warnf("remote-deployments-poll-interval below 1s, falling back to default") + } restConfig := injection.GetConfig(ctx) mfclient, err := mfc.NewClient(restConfig) diff --git a/pkg/reconciler/knativeserving/controller.go b/pkg/reconciler/knativeserving/controller.go index dfe824eda..c3f22a81d 100644 --- a/pkg/reconciler/knativeserving/controller.go +++ b/pkg/reconciler/knativeserving/controller.go @@ -62,6 +62,9 @@ func NewExtendedController(generator common.ExtensionGenerator) injection.Contro kubeClient := kubeclient.Get(ctx) logger := logging.FromContext(ctx) logger.Infof("Remote deployments poll interval: %s", common.RemoteDeploymentsPollIntervalValue()) + if common.RemoteDeploymentsPollIntervalWasClamped() { + logger.Warnf("remote-deployments-poll-interval below 1s, falling back to default") + } restConfig := injection.GetConfig(ctx) mfclient, err := mfc.NewClient(restConfig)