mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +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
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
|
||||
|
Reference in New Issue
Block a user