feat: add deprecation warning for legacy_stderr_threshold_behavior#437
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pierluigilenoci The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
This issue is currently awaiting triage. If klog contributors determine this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/hold Let's discuss in #436. |
Add a one-time deprecation warning when -stderrthreshold is explicitly set but silently ignored because -legacy_stderr_threshold_behavior=true (the current default). This alerts users that their threshold setting has no effect and guides them to opt in to the corrected behavior. The warning is emitted via fmt.Fprintf to stderr exactly once per process lifetime, only when both conditions are met: 1. -legacy_stderr_threshold_behavior=true (the default) 2. -stderrthreshold was explicitly set by the user Flag descriptions and package documentation are updated to mark the legacy behavior as deprecated, with a note that the default will change to false in a future release. This is the first step in a deprecation timeline: - This release: deprecation warning when legacy mode ignores threshold - Future release: flip legacy_stderr_threshold_behavior default to false Ref: kubernetes-sigs/metrics-server#1782 Ref: kubernetes#436 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
8e36f36 to
9bd6211
Compare
Summary
Add a one-time deprecation warning when
-stderrthresholdis explicitly set but silently ignored because-legacy_stderr_threshold_behavior=true(the current default).This is the first step in a deprecation timeline, as discussed in #436 and kubernetes-sigs/metrics-server#1782:
-stderrthresholdlegacy_stderr_threshold_behaviordefault tofalseWhat changed
stderrThresholdValuewrapper type: wrapsseverityValueand tracks whether-stderrthresholdwas explicitly set by the user via flag parsing orflagset.Set()fmt.Fprintf(os.Stderr, ...)on the first log call when both conditions are met:legacy_stderr_threshold_behavior=true(the current default)-stderrthresholdwas explicitly set by the userWhat did NOT change
legacy_stderr_threshold_behaviorstill defaults totrue,stderrthresholdstill defaults toERROR-stderrthresholdsee no difference at allWarning output
When triggered, the warning looks like:
Historical context
A previous attempt to flip the defaults directly was reverted in #50 (2019) because it violated the Kubernetes deprecation policy. This PR takes the gradual approach: warn first, flip later.
Test plan
TestLegacyBehaviorDeprecationWarning— verifies warning fires only whenlegacy=trueANDstderrthresholdexplicitly setTestCommandLine— updated to match new flag descriptionsTestHeaderWithDirfails due to clone directory name)Ref #436