mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +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
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/util/version"
|
||||||
"k8s.io/component-base/featuregate"
|
"k8s.io/component-base/featuregate"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,17 +32,16 @@ const (
|
|||||||
// used by a call chain.
|
// used by a call chain.
|
||||||
ContextualLogging featuregate.Feature = "ContextualLogging"
|
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.
|
// Allow fine-tuning of experimental, alpha-quality logging options.
|
||||||
//
|
//
|
||||||
// Per https://groups.google.com/g/kubernetes-sig-architecture/c/Nxsc7pfe5rw/m/vF2djJh0BAAJ
|
// 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:
|
// 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 guard *a group* of logging options whose quality level is alpha.
|
||||||
// - will never graduate to beta or stable.
|
// - 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"
|
LoggingAlphaOptions featuregate.Feature = "LoggingAlphaOptions"
|
||||||
|
|
||||||
// Allow fine-tuning of experimental, beta-quality logging options.
|
// 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.
|
// - will guard *a group* of logging options whose quality level is beta.
|
||||||
// - is thus *introduced* as beta
|
// - is thus *introduced* as beta
|
||||||
// - will never graduate to stable.
|
// - 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"
|
LoggingBetaOptions featuregate.Feature = "LoggingBetaOptions"
|
||||||
|
|
||||||
// Stable logging options. Always enabled.
|
// Stable logging options. Always enabled.
|
||||||
LoggingStableOptions featuregate.Feature = "LoggingStableOptions"
|
LoggingStableOptions featuregate.Feature = "LoggingStableOptions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func featureGates() map[featuregate.Feature]featuregate.FeatureSpec {
|
func featureGates() map[featuregate.Feature]featuregate.VersionedSpecs {
|
||||||
return map[featuregate.Feature]featuregate.FeatureSpec{
|
return map[featuregate.Feature]featuregate.VersionedSpecs{
|
||||||
ContextualLogging: {Default: contextualLoggingDefault, PreRelease: featuregate.Beta},
|
ContextualLogging: {
|
||||||
|
{Version: version.MustParse("1.24"), Default: false, PreRelease: featuregate.Alpha},
|
||||||
LoggingAlphaOptions: {Default: false, PreRelease: featuregate.Alpha},
|
{Version: version.MustParse("1.30"), Default: true, PreRelease: featuregate.Beta},
|
||||||
LoggingBetaOptions: {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.
|
// AddFeatureGates adds all feature gates used by this package.
|
||||||
func AddFeatureGates(mutableFeatureGate featuregate.MutableFeatureGate) error {
|
func AddFeatureGates(mutableFeatureGate featuregate.MutableVersionedFeatureGate) error {
|
||||||
return mutableFeatureGate.Add(featureGates()) //nolint:forbidigo // The logging feature gates are by design unversioned (perpetual alpha/beta).
|
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"))
|
errs = append(errs, field.Invalid(fldPath.Child("format"), c.Format, "Unsupported log format"))
|
||||||
} else if format != nil {
|
} else if format != nil {
|
||||||
if format.feature != LoggingStableOptions {
|
if format.feature != LoggingStableOptions {
|
||||||
enabled := featureGates()[format.feature].Default
|
enabled := featureGates()[format.feature][len(featureGates()[format.feature])-1].Default
|
||||||
if featureGate != nil {
|
if featureGate != nil {
|
||||||
enabled = featureGate.Enabled(format.feature)
|
enabled = featureGate.Enabled(format.feature)
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ func apply(c *LoggingConfiguration, options *LoggingOptions, featureGate feature
|
|||||||
p := ¶meters{
|
p := ¶meters{
|
||||||
C: c,
|
C: c,
|
||||||
Options: options,
|
Options: options,
|
||||||
ContextualLoggingEnabled: contextualLoggingDefault,
|
ContextualLoggingEnabled: true,
|
||||||
}
|
}
|
||||||
if featureGate != nil {
|
if featureGate != nil {
|
||||||
p.ContextualLoggingEnabled = featureGate.Enabled(ContextualLogging)
|
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
|
lockToDefault: false
|
||||||
preRelease: Beta
|
preRelease: Beta
|
||||||
version: "1.30"
|
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
|
- name: CoordinatedLeaderElection
|
||||||
versionedSpecs:
|
versionedSpecs:
|
||||||
- default: false
|
- default: false
|
||||||
@ -732,6 +742,18 @@
|
|||||||
lockToDefault: true
|
lockToDefault: true
|
||||||
preRelease: GA
|
preRelease: GA
|
||||||
version: "1.31"
|
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
|
- name: MatchLabelKeysInPodAffinity
|
||||||
versionedSpecs:
|
versionedSpecs:
|
||||||
- default: false
|
- default: false
|
||||||
|
Loading…
Reference in New Issue
Block a user