mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update kubernetes to 1.30
updating kubernetes to 1.30 release Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
62ddcf715b
commit
e727bd351e
74
vendor/k8s.io/component-base/featuregate/feature_gate.go
generated
vendored
74
vendor/k8s.io/component-base/featuregate/feature_gate.go
generated
vendored
@ -115,6 +115,17 @@ type MutableFeatureGate interface {
|
||||
GetAll() map[Feature]FeatureSpec
|
||||
// AddMetrics adds feature enablement metrics
|
||||
AddMetrics()
|
||||
// OverrideDefault sets a local override for the registered default value of a named
|
||||
// feature. If the feature has not been previously registered (e.g. by a call to Add), has a
|
||||
// locked default, or if the gate has already registered itself with a FlagSet, a non-nil
|
||||
// error is returned.
|
||||
//
|
||||
// When two or more components consume a common feature, one component can override its
|
||||
// default at runtime in order to adopt new defaults before or after the other
|
||||
// components. For example, a new feature can be evaluated with a limited blast radius by
|
||||
// overriding its default to true for a limited number of components without simultaneously
|
||||
// changing its default for all consuming components.
|
||||
OverrideDefault(name Feature, override bool) error
|
||||
}
|
||||
|
||||
// featureGate implements FeatureGate as well as pflag.Value for flag parsing.
|
||||
@ -126,9 +137,9 @@ type featureGate struct {
|
||||
// lock guards writes to known, enabled, and reads/writes of closed
|
||||
lock sync.Mutex
|
||||
// known holds a map[Feature]FeatureSpec
|
||||
known *atomic.Value
|
||||
known atomic.Value
|
||||
// enabled holds a map[Feature]bool
|
||||
enabled *atomic.Value
|
||||
enabled atomic.Value
|
||||
// closed is set to true when AddFlag is called, and prevents subsequent calls to Add
|
||||
closed bool
|
||||
}
|
||||
@ -166,19 +177,13 @@ func NewFeatureGate() *featureGate {
|
||||
known[k] = v
|
||||
}
|
||||
|
||||
knownValue := &atomic.Value{}
|
||||
knownValue.Store(known)
|
||||
|
||||
enabled := map[Feature]bool{}
|
||||
enabledValue := &atomic.Value{}
|
||||
enabledValue.Store(enabled)
|
||||
|
||||
f := &featureGate{
|
||||
featureGateName: naming.GetNameFromCallsite(internalPackages...),
|
||||
known: knownValue,
|
||||
special: specialFeatures,
|
||||
enabled: enabledValue,
|
||||
}
|
||||
f.known.Store(known)
|
||||
f.enabled.Store(map[Feature]bool{})
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
@ -296,6 +301,38 @@ func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *featureGate) OverrideDefault(name Feature, override bool) error {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
if f.closed {
|
||||
return fmt.Errorf("cannot override default for feature %q: gates already added to a flag set", name)
|
||||
}
|
||||
|
||||
known := map[Feature]FeatureSpec{}
|
||||
for name, spec := range f.known.Load().(map[Feature]FeatureSpec) {
|
||||
known[name] = spec
|
||||
}
|
||||
|
||||
spec, ok := known[name]
|
||||
switch {
|
||||
case !ok:
|
||||
return fmt.Errorf("cannot override default: feature %q is not registered", name)
|
||||
case spec.LockToDefault:
|
||||
return fmt.Errorf("cannot override default: feature %q default is locked to %t", name, spec.Default)
|
||||
case spec.PreRelease == Deprecated:
|
||||
klog.Warningf("Overriding default of deprecated feature gate %s=%t. It will be removed in a future release.", name, override)
|
||||
case spec.PreRelease == GA:
|
||||
klog.Warningf("Overriding default of GA feature gate %s=%t. It will be removed in a future release.", name, override)
|
||||
}
|
||||
|
||||
spec.Default = override
|
||||
known[name] = spec
|
||||
f.known.Store(known)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAll returns a copy of the map of known feature names to feature specs.
|
||||
func (f *featureGate) GetAll() map[Feature]FeatureSpec {
|
||||
retval := map[Feature]FeatureSpec{}
|
||||
@ -367,19 +404,16 @@ func (f *featureGate) DeepCopy() MutableFeatureGate {
|
||||
enabled[k] = v
|
||||
}
|
||||
|
||||
// Store copied state in new atomics.
|
||||
knownValue := &atomic.Value{}
|
||||
knownValue.Store(known)
|
||||
enabledValue := &atomic.Value{}
|
||||
enabledValue.Store(enabled)
|
||||
|
||||
// Construct a new featureGate around the copied state.
|
||||
// Note that specialFeatures is treated as immutable by convention,
|
||||
// and we maintain the value of f.closed across the copy.
|
||||
return &featureGate{
|
||||
fg := &featureGate{
|
||||
special: specialFeatures,
|
||||
known: knownValue,
|
||||
enabled: enabledValue,
|
||||
closed: f.closed,
|
||||
}
|
||||
|
||||
fg.known.Store(known)
|
||||
fg.enabled.Store(enabled)
|
||||
|
||||
return fg
|
||||
}
|
||||
|
10
vendor/k8s.io/component-base/logs/api/v1/kube_features.go
generated
vendored
10
vendor/k8s.io/component-base/logs/api/v1/kube_features.go
generated
vendored
@ -24,15 +24,17 @@ const (
|
||||
// owner: @pohly
|
||||
// kep: https://kep.k8s.io/3077
|
||||
// alpha: v1.24
|
||||
// beta: v1.30
|
||||
//
|
||||
// Enables looking up a logger from a context.Context instead of using
|
||||
// the global fallback logger and manipulating the logger that is
|
||||
// used by a call chain.
|
||||
ContextualLogging featuregate.Feature = "ContextualLogging"
|
||||
|
||||
// contextualLoggingDefault must remain false while in alpha. It can
|
||||
// become true in beta.
|
||||
contextualLoggingDefault = false
|
||||
// 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.
|
||||
//
|
||||
@ -57,7 +59,7 @@ const (
|
||||
|
||||
func featureGates() map[featuregate.Feature]featuregate.FeatureSpec {
|
||||
return map[featuregate.Feature]featuregate.FeatureSpec{
|
||||
ContextualLogging: {Default: contextualLoggingDefault, PreRelease: featuregate.Alpha},
|
||||
ContextualLogging: {Default: contextualLoggingDefault, PreRelease: featuregate.Beta},
|
||||
|
||||
LoggingAlphaOptions: {Default: false, PreRelease: featuregate.Alpha},
|
||||
LoggingBetaOptions: {Default: true, PreRelease: featuregate.Beta},
|
||||
|
36
vendor/k8s.io/component-base/logs/api/v1/options.go
generated
vendored
36
vendor/k8s.io/component-base/logs/api/v1/options.go
generated
vendored
@ -31,6 +31,7 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/klog/v2/textlogger"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
@ -188,10 +189,22 @@ func Validate(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldP
|
||||
|
||||
func validateFormatOptions(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList {
|
||||
errs := field.ErrorList{}
|
||||
errs = append(errs, validateTextOptions(c, featureGate, fldPath.Child("text"))...)
|
||||
errs = append(errs, validateJSONOptions(c, featureGate, fldPath.Child("json"))...)
|
||||
return errs
|
||||
}
|
||||
|
||||
func validateTextOptions(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList {
|
||||
errs := field.ErrorList{}
|
||||
if gate := LoggingAlphaOptions; c.Options.Text.SplitStream && !featureEnabled(featureGate, gate) {
|
||||
errs = append(errs, field.Forbidden(fldPath.Child("splitStream"), fmt.Sprintf("Feature %s is disabled", gate)))
|
||||
}
|
||||
if gate := LoggingAlphaOptions; c.Options.Text.InfoBufferSize.Value() != 0 && !featureEnabled(featureGate, gate) {
|
||||
errs = append(errs, field.Forbidden(fldPath.Child("infoBufferSize"), fmt.Sprintf("Feature %s is disabled", gate)))
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
||||
func validateJSONOptions(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList {
|
||||
errs := field.ErrorList{}
|
||||
if gate := LoggingAlphaOptions; c.Options.JSON.SplitStream && !featureEnabled(featureGate, gate) {
|
||||
@ -254,7 +267,14 @@ func apply(c *LoggingConfiguration, options *LoggingOptions, featureGate feature
|
||||
defer setverbositylevel.Mutex.Unlock()
|
||||
setverbositylevel.Callbacks = append(setverbositylevel.Callbacks, control.SetVerbosityLevel)
|
||||
}
|
||||
klog.SetLoggerWithOptions(log, klog.ContextualLogger(p.ContextualLoggingEnabled), klog.FlushLogger(control.Flush))
|
||||
opts := []klog.LoggerOption{
|
||||
klog.ContextualLogger(p.ContextualLoggingEnabled),
|
||||
klog.FlushLogger(control.Flush),
|
||||
}
|
||||
if writer, ok := log.GetSink().(textlogger.KlogBufferWriter); ok {
|
||||
opts = append(opts, klog.WriteKlogBuffer(writer.WriteKlogBuffer))
|
||||
}
|
||||
klog.SetLoggerWithOptions(log, opts...)
|
||||
}
|
||||
if err := loggingFlags.Lookup("v").Value.Set(VerbosityLevelPflag(&c.Verbosity).String()); err != nil {
|
||||
return fmt.Errorf("internal error while setting klog verbosity: %v", err)
|
||||
@ -346,6 +366,9 @@ func addFlags(c *LoggingConfiguration, fs flagSet) {
|
||||
fs.VarP(VerbosityLevelPflag(&c.Verbosity), "v", "v", "number for the log level verbosity")
|
||||
fs.Var(VModuleConfigurationPflag(&c.VModule), "vmodule", "comma-separated list of pattern=N settings for file-filtered logging (only works for text log format)")
|
||||
|
||||
fs.BoolVar(&c.Options.Text.SplitStream, "log-text-split-stream", false, "[Alpha] In text format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout. Enable the LoggingAlphaOptions feature gate to use this.")
|
||||
fs.Var(&c.Options.Text.InfoBufferSize, "log-text-info-buffer-size", "[Alpha] In text format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi). Enable the LoggingAlphaOptions feature gate to use this.")
|
||||
|
||||
// JSON options. We only register them if "json" is a valid format. The
|
||||
// config file API however always has them.
|
||||
if _, err := logRegistry.get("json"); err == nil {
|
||||
@ -368,16 +391,21 @@ func SetRecommendedLoggingConfiguration(c *LoggingConfiguration) {
|
||||
c.FlushFrequency.Duration.Duration = LogFlushFreqDefault
|
||||
c.FlushFrequency.SerializeAsString = true
|
||||
}
|
||||
setRecommendedOutputRouting(&c.Options.Text.OutputRoutingOptions)
|
||||
setRecommendedOutputRouting(&c.Options.JSON.OutputRoutingOptions)
|
||||
}
|
||||
|
||||
func setRecommendedOutputRouting(o *OutputRoutingOptions) {
|
||||
var empty resource.QuantityValue
|
||||
if c.Options.JSON.InfoBufferSize == empty {
|
||||
c.Options.JSON.InfoBufferSize = resource.QuantityValue{
|
||||
if o.InfoBufferSize == empty {
|
||||
o.InfoBufferSize = resource.QuantityValue{
|
||||
// This is similar, but not quite the same as a default
|
||||
// constructed instance.
|
||||
Quantity: *resource.NewQuantity(0, resource.DecimalSI),
|
||||
}
|
||||
// This sets the unexported Quantity.s which will be compared
|
||||
// by reflect.DeepEqual in some tests.
|
||||
_ = c.Options.JSON.InfoBufferSize.String()
|
||||
_ = o.InfoBufferSize.String()
|
||||
}
|
||||
}
|
||||
|
||||
|
2
vendor/k8s.io/component-base/logs/api/v1/registry.go
generated
vendored
2
vendor/k8s.io/component-base/logs/api/v1/registry.go
generated
vendored
@ -79,7 +79,7 @@ func newLogFormatRegistry() *logFormatRegistry {
|
||||
registry: make(map[string]logFormat),
|
||||
frozen: false,
|
||||
}
|
||||
registry.register("text", logFormat{feature: LoggingStableOptions})
|
||||
_ = registry.register(DefaultLogFormat, logFormat{factory: textFactory{}, feature: LoggingStableOptions})
|
||||
return registry
|
||||
}
|
||||
|
||||
|
142
vendor/k8s.io/component-base/logs/api/v1/text.go
generated
vendored
Normal file
142
vendor/k8s.io/component-base/logs/api/v1/text.go
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
Copyright 2022 The Kubernetes 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 v1
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/klog/v2/textlogger"
|
||||
)
|
||||
|
||||
// textFactory produces klog text logger instances.
|
||||
type textFactory struct{}
|
||||
|
||||
var _ LogFormatFactory = textFactory{}
|
||||
|
||||
func (f textFactory) Feature() featuregate.Feature {
|
||||
return LoggingStableOptions
|
||||
}
|
||||
|
||||
func (f textFactory) Create(c LoggingConfiguration, o LoggingOptions) (logr.Logger, RuntimeControl) {
|
||||
output := o.ErrorStream
|
||||
var flush func()
|
||||
if c.Options.Text.SplitStream {
|
||||
r := &klogMsgRouter{
|
||||
info: o.InfoStream,
|
||||
error: o.ErrorStream,
|
||||
}
|
||||
size := c.Options.Text.InfoBufferSize.Value()
|
||||
if size > 0 {
|
||||
// Prevent integer overflow.
|
||||
if size > 2*1024*1024*1024 {
|
||||
size = 2 * 1024 * 1024 * 1024
|
||||
}
|
||||
info := newBufferedWriter(r.info, int(size))
|
||||
flush = info.Flush
|
||||
r.info = info
|
||||
}
|
||||
output = r
|
||||
}
|
||||
|
||||
options := []textlogger.ConfigOption{
|
||||
textlogger.Verbosity(int(c.Verbosity)),
|
||||
textlogger.Output(output),
|
||||
}
|
||||
loggerConfig := textlogger.NewConfig(options...)
|
||||
|
||||
// This should never fail, we produce a valid string here.
|
||||
_ = loggerConfig.VModule().Set(VModuleConfigurationPflag(&c.VModule).String())
|
||||
|
||||
return textlogger.NewLogger(loggerConfig),
|
||||
RuntimeControl{
|
||||
SetVerbosityLevel: func(v uint32) error {
|
||||
return loggerConfig.Verbosity().Set(fmt.Sprintf("%d", v))
|
||||
},
|
||||
Flush: flush,
|
||||
}
|
||||
}
|
||||
|
||||
type klogMsgRouter struct {
|
||||
info, error io.Writer
|
||||
}
|
||||
|
||||
var _ io.Writer = &klogMsgRouter{}
|
||||
|
||||
// Write redirects the message into either the info or error
|
||||
// stream, depending on its type as indicated in text format
|
||||
// by the first byte.
|
||||
func (r *klogMsgRouter) Write(p []byte) (int, error) {
|
||||
if len(p) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
if p[0] == 'I' {
|
||||
return r.info.Write(p)
|
||||
}
|
||||
return r.error.Write(p)
|
||||
}
|
||||
|
||||
// bufferedWriter is an io.Writer that buffers writes in-memory before
|
||||
// flushing them to a wrapped io.Writer after reaching some limit
|
||||
// or getting flushed.
|
||||
type bufferedWriter struct {
|
||||
mu sync.Mutex
|
||||
writer *bufio.Writer
|
||||
out io.Writer
|
||||
}
|
||||
|
||||
func newBufferedWriter(out io.Writer, size int) *bufferedWriter {
|
||||
return &bufferedWriter{
|
||||
writer: bufio.NewWriterSize(out, size),
|
||||
out: out,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *bufferedWriter) Write(p []byte) (int, error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
// To avoid partial writes into the underlying writer, we ensure that
|
||||
// the entire new data fits into the buffer or flush first.
|
||||
if len(p) > b.writer.Available() && b.writer.Buffered() > 0 {
|
||||
if err := b.writer.Flush(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
// If it still doesn't fit, then we bypass the now empty buffer
|
||||
// and write directly.
|
||||
if len(p) > b.writer.Available() {
|
||||
return b.out.Write(p)
|
||||
}
|
||||
|
||||
// This goes into the buffer.
|
||||
return b.writer.Write(p)
|
||||
}
|
||||
|
||||
func (b *bufferedWriter) Flush() {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
_ = b.writer.Flush()
|
||||
}
|
13
vendor/k8s.io/component-base/logs/api/v1/types.go
generated
vendored
13
vendor/k8s.io/component-base/logs/api/v1/types.go
generated
vendored
@ -94,13 +94,26 @@ func (t *TimeOrMetaDuration) UnmarshalJSON(b []byte) error {
|
||||
|
||||
// FormatOptions contains options for the different logging formats.
|
||||
type FormatOptions struct {
|
||||
// [Alpha] Text contains options for logging format "text".
|
||||
// Only available when the LoggingAlphaOptions feature gate is enabled.
|
||||
Text TextOptions `json:"text,omitempty"`
|
||||
// [Alpha] JSON contains options for logging format "json".
|
||||
// Only available when the LoggingAlphaOptions feature gate is enabled.
|
||||
JSON JSONOptions `json:"json,omitempty"`
|
||||
}
|
||||
|
||||
// TextOptions contains options for logging format "text".
|
||||
type TextOptions struct {
|
||||
OutputRoutingOptions `json:",inline"`
|
||||
}
|
||||
|
||||
// JSONOptions contains options for logging format "json".
|
||||
type JSONOptions struct {
|
||||
OutputRoutingOptions `json:",inline"`
|
||||
}
|
||||
|
||||
// OutputRoutingOptions contains options that are supported by both "text" and "json".
|
||||
type OutputRoutingOptions struct {
|
||||
// [Alpha] SplitStream redirects error messages to stderr while
|
||||
// info messages go to stdout, with buffering. The default is to write
|
||||
// both to stdout, without buffering. Only available when
|
||||
|
37
vendor/k8s.io/component-base/logs/api/v1/zz_generated.deepcopy.go
generated
vendored
37
vendor/k8s.io/component-base/logs/api/v1/zz_generated.deepcopy.go
generated
vendored
@ -24,6 +24,7 @@ package v1
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FormatOptions) DeepCopyInto(out *FormatOptions) {
|
||||
*out = *in
|
||||
in.Text.DeepCopyInto(&out.Text)
|
||||
in.JSON.DeepCopyInto(&out.JSON)
|
||||
return
|
||||
}
|
||||
@ -41,7 +42,7 @@ func (in *FormatOptions) DeepCopy() *FormatOptions {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *JSONOptions) DeepCopyInto(out *JSONOptions) {
|
||||
*out = *in
|
||||
in.InfoBufferSize.DeepCopyInto(&out.InfoBufferSize)
|
||||
in.OutputRoutingOptions.DeepCopyInto(&out.OutputRoutingOptions)
|
||||
return
|
||||
}
|
||||
|
||||
@ -78,6 +79,40 @@ func (in *LoggingConfiguration) DeepCopy() *LoggingConfiguration {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *OutputRoutingOptions) DeepCopyInto(out *OutputRoutingOptions) {
|
||||
*out = *in
|
||||
in.InfoBufferSize.DeepCopyInto(&out.InfoBufferSize)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutputRoutingOptions.
|
||||
func (in *OutputRoutingOptions) DeepCopy() *OutputRoutingOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(OutputRoutingOptions)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TextOptions) DeepCopyInto(out *TextOptions) {
|
||||
*out = *in
|
||||
in.OutputRoutingOptions.DeepCopyInto(&out.OutputRoutingOptions)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TextOptions.
|
||||
func (in *TextOptions) DeepCopy() *TextOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TextOptions)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TimeOrMetaDuration) DeepCopyInto(out *TimeOrMetaDuration) {
|
||||
*out = *in
|
||||
|
32
vendor/k8s.io/component-base/logs/testinit/testinit.go
generated
vendored
Normal file
32
vendor/k8s.io/component-base/logs/testinit/testinit.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2021 The Kubernetes 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 testinit adds logging flags to a Ginkgo or Go test program during
|
||||
// initialization, something that the logs package itself no longer does.
|
||||
//
|
||||
// Normal commands should not use this and instead manage logging flags with
|
||||
// logs.Options and/or cli.Run.
|
||||
package testinit
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"k8s.io/component-base/logs"
|
||||
)
|
||||
|
||||
func init() {
|
||||
logs.AddGoFlags(flag.CommandLine)
|
||||
}
|
2
vendor/k8s.io/component-base/metrics/prometheus/slis/metrics.go
generated
vendored
2
vendor/k8s.io/component-base/metrics/prometheus/slis/metrics.go
generated
vendored
@ -28,8 +28,6 @@ const (
|
||||
Error HealthcheckStatus = "error"
|
||||
)
|
||||
|
||||
type HealthcheckType string
|
||||
|
||||
var (
|
||||
// healthcheck is a Prometheus Gauge metrics used for recording the results of a k8s healthcheck.
|
||||
healthcheck = k8smetrics.NewGaugeVec(
|
||||
|
6
vendor/k8s.io/component-base/metrics/testutil/promlint.go
generated
vendored
6
vendor/k8s.io/component-base/metrics/testutil/promlint.go
generated
vendored
@ -30,13 +30,13 @@ import (
|
||||
// We setup this list for allow and not fail on the current violations.
|
||||
// Generally speaking, you need to fix the problem for a new metric rather than add it into the list.
|
||||
var exceptionMetrics = []string{
|
||||
// k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/egressselector
|
||||
// k8s.io/apiserver/pkg/server/egressselector
|
||||
"apiserver_egress_dialer_dial_failure_count", // counter metrics should have "_total" suffix
|
||||
|
||||
// k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/healthz
|
||||
// k8s.io/apiserver/pkg/server/healthz
|
||||
"apiserver_request_total", // label names should be written in 'snake_case' not 'camelCase'
|
||||
|
||||
// k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/endpoints/filters
|
||||
// k8s.io/apiserver/pkg/endpoints/filters
|
||||
"authenticated_user_requests", // counter metrics should have "_total" suffix
|
||||
"authentication_attempts", // counter metrics should have "_total" suffix
|
||||
|
||||
|
11
vendor/k8s.io/component-base/metrics/testutil/testutil.go
generated
vendored
11
vendor/k8s.io/component-base/metrics/testutil/testutil.go
generated
vendored
@ -19,7 +19,6 @@ package testutil
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/testutil"
|
||||
|
||||
@ -28,6 +27,12 @@ import (
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
)
|
||||
|
||||
type TB interface {
|
||||
Logf(format string, args ...any)
|
||||
Errorf(format string, args ...any)
|
||||
Fatalf(format string, args ...any)
|
||||
}
|
||||
|
||||
// CollectAndCompare registers the provided Collector with a newly created
|
||||
// pedantic Registry. It then does the same as GatherAndCompare, gathering the
|
||||
// metrics from the pedantic Registry.
|
||||
@ -94,7 +99,7 @@ func NewFakeKubeRegistry(ver string) metrics.KubeRegistry {
|
||||
return metrics.NewKubeRegistry()
|
||||
}
|
||||
|
||||
func AssertVectorCount(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
|
||||
func AssertVectorCount(t TB, name string, labelFilter map[string]string, wantCount int) {
|
||||
metrics, err := legacyregistry.DefaultGatherer.Gather()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to gather metrics: %s", err)
|
||||
@ -124,7 +129,7 @@ func AssertVectorCount(t *testing.T, name string, labelFilter map[string]string,
|
||||
}
|
||||
}
|
||||
|
||||
func AssertHistogramTotalCount(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
|
||||
func AssertHistogramTotalCount(t TB, name string, labelFilter map[string]string, wantCount int) {
|
||||
metrics, err := legacyregistry.DefaultGatherer.Gather()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to gather metrics: %s", err)
|
||||
|
4
vendor/k8s.io/component-base/tracing/utils.go
generated
vendored
4
vendor/k8s.io/component-base/tracing/utils.go
generated
vendored
@ -91,7 +91,7 @@ func NewProvider(ctx context.Context,
|
||||
}
|
||||
|
||||
// WithTracing adds tracing to requests if the incoming request is sampled
|
||||
func WithTracing(handler http.Handler, tp oteltrace.TracerProvider, serviceName string) http.Handler {
|
||||
func WithTracing(handler http.Handler, tp oteltrace.TracerProvider, spanName string) http.Handler {
|
||||
opts := []otelhttp.Option{
|
||||
otelhttp.WithPropagators(Propagators()),
|
||||
otelhttp.WithTracerProvider(tp),
|
||||
@ -106,7 +106,7 @@ func WithTracing(handler http.Handler, tp oteltrace.TracerProvider, serviceName
|
||||
})
|
||||
// With Noop TracerProvider, the otelhttp still handles context propagation.
|
||||
// See https://github.com/open-telemetry/opentelemetry-go/tree/main/example/passthrough
|
||||
return otelhttp.NewHandler(wrappedHandler, serviceName, opts...)
|
||||
return otelhttp.NewHandler(wrappedHandler, spanName, opts...)
|
||||
}
|
||||
|
||||
// WrapperFor can be used to add tracing to a *rest.Config.
|
||||
|
Reference in New Issue
Block a user