mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
chore: migrate logging featuregates to versioned
This commit is contained in:
parent
01ed8ed4ff
commit
4f7ce7513e
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
"k8s.io/component-base/featuregate"
|
||||
)
|
||||
|
||||
@ -31,17 +32,16 @@ const (
|
||||
// used by a call chain.
|
||||
ContextualLogging featuregate.Feature = "ContextualLogging"
|
||||
|
||||
// contextualLoggingDefault is now true because the feature reached beta
|
||||
// and performance comparisons showed no relevant degradation when
|
||||
// enabling it.
|
||||
contextualLoggingDefault = true
|
||||
|
||||
// Allow fine-tuning of experimental, alpha-quality logging options.
|
||||
//
|
||||
// Per https://groups.google.com/g/kubernetes-sig-architecture/c/Nxsc7pfe5rw/m/vF2djJh0BAAJ
|
||||
// we want to avoid a proliferation of feature gates. This feature gate:
|
||||
// - will guard *a group* of logging options whose quality level is alpha.
|
||||
// - will never graduate to beta or stable.
|
||||
//
|
||||
// IMPORTANT: Unlike typical feature gates, LoggingAlphaOptions is NOT affected by
|
||||
// emulation version changes. Its behavior remains constant regardless of the
|
||||
// emulation version being used.
|
||||
LoggingAlphaOptions featuregate.Feature = "LoggingAlphaOptions"
|
||||
|
||||
// Allow fine-tuning of experimental, beta-quality logging options.
|
||||
@ -51,22 +51,32 @@ const (
|
||||
// - will guard *a group* of logging options whose quality level is beta.
|
||||
// - is thus *introduced* as beta
|
||||
// - will never graduate to stable.
|
||||
//
|
||||
// IMPORTANT: Unlike typical feature gates, LoggingBetaOptions is NOT affected by
|
||||
// emulation version changes. Its behavior remains constant regardless of the
|
||||
// emulation version being used.
|
||||
LoggingBetaOptions featuregate.Feature = "LoggingBetaOptions"
|
||||
|
||||
// Stable logging options. Always enabled.
|
||||
LoggingStableOptions featuregate.Feature = "LoggingStableOptions"
|
||||
)
|
||||
|
||||
func featureGates() map[featuregate.Feature]featuregate.FeatureSpec {
|
||||
return map[featuregate.Feature]featuregate.FeatureSpec{
|
||||
ContextualLogging: {Default: contextualLoggingDefault, PreRelease: featuregate.Beta},
|
||||
|
||||
LoggingAlphaOptions: {Default: false, PreRelease: featuregate.Alpha},
|
||||
LoggingBetaOptions: {Default: true, PreRelease: featuregate.Beta},
|
||||
func featureGates() map[featuregate.Feature]featuregate.VersionedSpecs {
|
||||
return map[featuregate.Feature]featuregate.VersionedSpecs{
|
||||
ContextualLogging: {
|
||||
{Version: version.MustParse("1.24"), Default: false, PreRelease: featuregate.Alpha},
|
||||
{Version: version.MustParse("1.30"), Default: true, PreRelease: featuregate.Beta},
|
||||
},
|
||||
LoggingAlphaOptions: {
|
||||
{Version: version.MustParse("1.24"), Default: false, PreRelease: featuregate.Alpha},
|
||||
},
|
||||
LoggingBetaOptions: {
|
||||
{Version: version.MustParse("1.24"), Default: true, PreRelease: featuregate.Beta},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// AddFeatureGates adds all feature gates used by this package.
|
||||
func AddFeatureGates(mutableFeatureGate featuregate.MutableFeatureGate) error {
|
||||
return mutableFeatureGate.Add(featureGates()) //nolint:forbidigo // The logging feature gates are by design unversioned (perpetual alpha/beta).
|
||||
func AddFeatureGates(mutableFeatureGate featuregate.MutableVersionedFeatureGate) error {
|
||||
return mutableFeatureGate.AddVersioned(featureGates())
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ func Validate(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldP
|
||||
errs = append(errs, field.Invalid(fldPath.Child("format"), c.Format, "Unsupported log format"))
|
||||
} else if format != nil {
|
||||
if format.feature != LoggingStableOptions {
|
||||
enabled := featureGates()[format.feature].Default
|
||||
enabled := featureGates()[format.feature][len(featureGates()[format.feature])-1].Default
|
||||
if featureGate != nil {
|
||||
enabled = featureGate.Enabled(format.feature)
|
||||
}
|
||||
@ -228,7 +228,7 @@ func apply(c *LoggingConfiguration, options *LoggingOptions, featureGate feature
|
||||
p := ¶meters{
|
||||
C: c,
|
||||
Options: options,
|
||||
ContextualLoggingEnabled: contextualLoggingDefault,
|
||||
ContextualLoggingEnabled: true,
|
||||
}
|
||||
if featureGate != nil {
|
||||
p.ContextualLoggingEnabled = featureGate.Enabled(ContextualLogging)
|
||||
|
@ -1,18 +1 @@
|
||||
- name: ContextualLogging
|
||||
versionedSpecs:
|
||||
- default: true
|
||||
lockToDefault: false
|
||||
preRelease: Beta
|
||||
version: ""
|
||||
- name: LoggingAlphaOptions
|
||||
versionedSpecs:
|
||||
- default: false
|
||||
lockToDefault: false
|
||||
preRelease: Alpha
|
||||
version: ""
|
||||
- name: LoggingBetaOptions
|
||||
versionedSpecs:
|
||||
- default: true
|
||||
lockToDefault: false
|
||||
preRelease: Beta
|
||||
version: ""
|
||||
[]
|
||||
|
@ -258,6 +258,16 @@
|
||||
lockToDefault: false
|
||||
preRelease: Beta
|
||||
version: "1.30"
|
||||
- name: ContextualLogging
|
||||
versionedSpecs:
|
||||
- default: false
|
||||
lockToDefault: false
|
||||
preRelease: Alpha
|
||||
version: "1.24"
|
||||
- default: true
|
||||
lockToDefault: false
|
||||
preRelease: Beta
|
||||
version: "1.30"
|
||||
- name: CoordinatedLeaderElection
|
||||
versionedSpecs:
|
||||
- default: false
|
||||
@ -732,6 +742,18 @@
|
||||
lockToDefault: true
|
||||
preRelease: GA
|
||||
version: "1.31"
|
||||
- name: LoggingAlphaOptions
|
||||
versionedSpecs:
|
||||
- default: false
|
||||
lockToDefault: false
|
||||
preRelease: Alpha
|
||||
version: "1.24"
|
||||
- name: LoggingBetaOptions
|
||||
versionedSpecs:
|
||||
- default: true
|
||||
lockToDefault: false
|
||||
preRelease: Beta
|
||||
version: "1.24"
|
||||
- name: MatchLabelKeysInPodAffinity
|
||||
versionedSpecs:
|
||||
- default: false
|
||||
|
Loading…
Reference in New Issue
Block a user