code
stringlengths
12
335k
docstring
stringlengths
20
20.8k
func_name
stringlengths
1
105
language
stringclasses
1 value
repo
stringclasses
498 values
path
stringlengths
5
172
url
stringlengths
43
235
license
stringclasses
4 values
func EventAggregatorByReasonFunc(event *v1.Event) (string, string) { return strings.Join([]string{ event.Source.Component, event.Source.Host, event.InvolvedObject.Kind, event.InvolvedObject.Namespace, event.InvolvedObject.Name, string(event.InvolvedObject.UID), event.InvolvedObject.APIVersion, event.Type, event.Reason, event.ReportingController, event.ReportingInstance, }, ""), event.Message }
EventAggregatorByReasonFunc aggregates events by exact match on event.Source, event.InvolvedObject, event.Type, event.Reason, event.ReportingController and event.ReportingInstance
EventAggregatorByReasonFunc
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func EventAggregatorByReasonMessageFunc(event *v1.Event) string { return "(combined from similar events): " + event.Message }
EventAggregatorByReasonMessageFunc returns an aggregate message by prefixing the incoming message
EventAggregatorByReasonMessageFunc
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func NewEventAggregator(lruCacheSize int, keyFunc EventAggregatorKeyFunc, messageFunc EventAggregatorMessageFunc, maxEvents int, maxIntervalInSeconds int, clock clock.PassiveClock) *EventAggregator { return &EventAggregator{ cache: lru.New(lruCacheSize), keyFunc: keyFunc, messageFunc: messageFunc, maxEvents: uint(maxEvents), maxIntervalInSeconds: uint(maxIntervalInSeconds), clock: clock, } }
NewEventAggregator returns a new instance of an EventAggregator
NewEventAggregator
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func (e *EventAggregator) EventAggregate(newEvent *v1.Event) (*v1.Event, string) { now := metav1.NewTime(e.clock.Now()) var record aggregateRecord // eventKey is the full cache key for this event eventKey := getEventKey(newEvent) // aggregateKey is for the aggregate event, if one is needed. aggregateKey, localKey := e.keyFunc(newEvent) // Do we have a record of similar events in our cache? e.Lock() defer e.Unlock() value, found := e.cache.Get(aggregateKey) if found { record = value.(aggregateRecord) } // Is the previous record too old? If so, make a fresh one. Note: if we didn't // find a similar record, its lastTimestamp will be the zero value, so we // create a new one in that case. maxInterval := time.Duration(e.maxIntervalInSeconds) * time.Second interval := now.Time.Sub(record.lastTimestamp.Time) if interval > maxInterval { record = aggregateRecord{localKeys: sets.NewString()} } // Write the new event into the aggregation record and put it on the cache record.localKeys.Insert(localKey) record.lastTimestamp = now e.cache.Add(aggregateKey, record) // If we are not yet over the threshold for unique events, don't correlate them if uint(record.localKeys.Len()) < e.maxEvents { return newEvent, eventKey } // do not grow our local key set any larger than max record.localKeys.PopAny() // create a new aggregate event, and return the aggregateKey as the cache key // (so that it can be overwritten.) eventCopy := &v1.Event{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("%v.%x", newEvent.InvolvedObject.Name, now.UnixNano()), Namespace: newEvent.Namespace, }, Count: 1, FirstTimestamp: now, InvolvedObject: newEvent.InvolvedObject, LastTimestamp: now, Message: e.messageFunc(newEvent), Type: newEvent.Type, Reason: newEvent.Reason, Source: newEvent.Source, } return eventCopy, aggregateKey }
EventAggregate checks if a similar event has been seen according to the aggregation configuration (max events, max interval, etc) and returns: - The (potentially modified) event that should be created - The cache key for the event, for correlation purposes. This will be set to the full key for normal events, and to the result of EventAggregatorMessageFunc for aggregate events.
EventAggregate
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func newEventLogger(lruCacheEntries int, clock clock.PassiveClock) *eventLogger { return &eventLogger{cache: lru.New(lruCacheEntries), clock: clock} }
newEventLogger observes events and counts their frequencies
newEventLogger
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func (e *eventLogger) eventObserve(newEvent *v1.Event, key string) (*v1.Event, []byte, error) { var ( patch []byte err error ) eventCopy := *newEvent event := &eventCopy e.Lock() defer e.Unlock() // Check if there is an existing event we should update lastObservation := e.lastEventObservationFromCache(key) // If we found a result, prepare a patch if lastObservation.count > 0 { // update the event based on the last observation so patch will work as desired event.Name = lastObservation.name event.ResourceVersion = lastObservation.resourceVersion event.FirstTimestamp = lastObservation.firstTimestamp event.Count = int32(lastObservation.count) + 1 eventCopy2 := *event eventCopy2.Count = 0 eventCopy2.LastTimestamp = metav1.NewTime(time.Unix(0, 0)) eventCopy2.Message = "" newData, _ := json.Marshal(event) oldData, _ := json.Marshal(eventCopy2) patch, err = strategicpatch.CreateTwoWayMergePatch(oldData, newData, event) } // record our new observation e.cache.Add( key, eventLog{ count: uint(event.Count), firstTimestamp: event.FirstTimestamp, name: event.Name, resourceVersion: event.ResourceVersion, }, ) return event, patch, err }
eventObserve records an event, or updates an existing one if key is a cache hit
eventObserve
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func (e *eventLogger) updateState(event *v1.Event) { key := getEventKey(event) e.Lock() defer e.Unlock() // record our new observation e.cache.Add( key, eventLog{ count: uint(event.Count), firstTimestamp: event.FirstTimestamp, name: event.Name, resourceVersion: event.ResourceVersion, }, ) }
updateState updates its internal tracking information based on latest server state
updateState
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func (e *eventLogger) lastEventObservationFromCache(key string) eventLog { value, ok := e.cache.Get(key) if ok { observationValue, ok := value.(eventLog) if ok { return observationValue } } return eventLog{} }
lastEventObservationFromCache returns the event from the cache, reads must be protected via external lock
lastEventObservationFromCache
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func NewEventCorrelator(clock clock.PassiveClock) *EventCorrelator { cacheSize := maxLruCacheEntries spamFilter := NewEventSourceObjectSpamFilter(cacheSize, defaultSpamBurst, defaultSpamQPS, clock, getSpamKey) return &EventCorrelator{ filterFunc: spamFilter.Filter, aggregator: NewEventAggregator( cacheSize, EventAggregatorByReasonFunc, EventAggregatorByReasonMessageFunc, defaultAggregateMaxEvents, defaultAggregateIntervalInSeconds, clock), logger: newEventLogger(cacheSize, clock), } }
NewEventCorrelator returns an EventCorrelator configured with default values. The EventCorrelator is responsible for event filtering, aggregating, and counting prior to interacting with the API server to record the event. The default behavior is as follows: - Aggregation is performed if a similar event is recorded 10 times in a 10 minute rolling interval. A similar event is an event that varies only by the Event.Message field. Rather than recording the precise event, aggregation will create a new event whose message reports that it has combined events with the same reason. - Events are incrementally counted if the exact same event is encountered multiple times. - A source may burst 25 events about an object, but has a refill rate budget per object of 1 event every 5 minutes to control long-tail of spam.
NewEventCorrelator
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func populateDefaults(options CorrelatorOptions) CorrelatorOptions { if options.LRUCacheSize == 0 { options.LRUCacheSize = maxLruCacheEntries } if options.BurstSize == 0 { options.BurstSize = defaultSpamBurst } if options.QPS == 0 { options.QPS = defaultSpamQPS } if options.KeyFunc == nil { options.KeyFunc = EventAggregatorByReasonFunc } if options.MessageFunc == nil { options.MessageFunc = EventAggregatorByReasonMessageFunc } if options.MaxEvents == 0 { options.MaxEvents = defaultAggregateMaxEvents } if options.MaxIntervalInSeconds == 0 { options.MaxIntervalInSeconds = defaultAggregateIntervalInSeconds } if options.Clock == nil { options.Clock = clock.RealClock{} } if options.SpamKeyFunc == nil { options.SpamKeyFunc = getSpamKey } return options }
populateDefaults populates the zero value options with defaults
populateDefaults
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func (c *EventCorrelator) EventCorrelate(newEvent *v1.Event) (*EventCorrelateResult, error) { if newEvent == nil { return nil, fmt.Errorf("event is nil") } aggregateEvent, ckey := c.aggregator.EventAggregate(newEvent) observedEvent, patch, err := c.logger.eventObserve(aggregateEvent, ckey) if c.filterFunc(observedEvent) { return &EventCorrelateResult{Skip: true}, nil } return &EventCorrelateResult{Event: observedEvent, Patch: patch}, err }
EventCorrelate filters, aggregates, counts, and de-duplicates all incoming events
EventCorrelate
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func (c *EventCorrelator) UpdateState(event *v1.Event) { c.logger.updateState(event) }
UpdateState based on the latest observed state from server
UpdateState
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/events_cache.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/events_cache.go
Apache-2.0
func ValidateEventType(eventtype string) bool { switch eventtype { case v1.EventTypeNormal, v1.EventTypeWarning: return true } return false }
ValidateEventType checks that eventtype is an expected type of event
ValidateEventType
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/util/util.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/util/util.go
Apache-2.0
func IsKeyNotFoundError(err error) bool { statusErr, _ := err.(*errors.StatusError) return statusErr != nil && statusErr.Status().Code == http.StatusNotFound }
IsKeyNotFoundError is utility function that checks if an error is not found error
IsKeyNotFoundError
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/record/util/util.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/record/util/util.go
Apache-2.0
func Register(opts RegisterOpts) { registerMetrics.Do(func() { if opts.ClientCertExpiry != nil { ClientCertExpiry = opts.ClientCertExpiry } if opts.ClientCertRotationAge != nil { ClientCertRotationAge = opts.ClientCertRotationAge } if opts.RequestLatency != nil { RequestLatency = opts.RequestLatency } if opts.ResolverLatency != nil { ResolverLatency = opts.ResolverLatency } if opts.RequestSize != nil { RequestSize = opts.RequestSize } if opts.ResponseSize != nil { ResponseSize = opts.ResponseSize } if opts.RateLimiterLatency != nil { RateLimiterLatency = opts.RateLimiterLatency } if opts.RequestResult != nil { RequestResult = opts.RequestResult } if opts.ExecPluginCalls != nil { ExecPluginCalls = opts.ExecPluginCalls } if opts.RequestRetry != nil { RequestRetry = opts.RequestRetry } if opts.TransportCacheEntries != nil { TransportCacheEntries = opts.TransportCacheEntries } if opts.TransportCreateCalls != nil { TransportCreateCalls = opts.TransportCreateCalls } }) }
Register registers metrics for the rest client to use. This can only be called once.
Register
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/metrics/metrics.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/metrics/metrics.go
Apache-2.0
func NewRetryWatcher(initialResourceVersion string, watcherClient cache.Watcher) (*RetryWatcher, error) { return newRetryWatcher(initialResourceVersion, watcherClient, 1*time.Second) }
NewRetryWatcher creates a new RetryWatcher. It will make sure that watches gets restarted in case of recoverable errors. The initialResourceVersion will be given to watch method when first called.
NewRetryWatcher
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/retrywatcher.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/retrywatcher.go
Apache-2.0
func (rw *RetryWatcher) doReceive() (bool, time.Duration) { watcher, err := rw.watcherClient.Watch(metav1.ListOptions{ ResourceVersion: rw.lastResourceVersion, AllowWatchBookmarks: true, }) // We are very unlikely to hit EOF here since we are just establishing the call, // but it may happen that the apiserver is just shutting down (e.g. being restarted) // This is consistent with how it is handled for informers switch err { case nil: break case io.EOF: // watch closed normally return false, 0 case io.ErrUnexpectedEOF: klog.V(1).InfoS("Watch closed with unexpected EOF", "err", err) return false, 0 default: msg := "Watch failed" if net.IsProbableEOF(err) || net.IsTimeout(err) { klog.V(5).InfoS(msg, "err", err) // Retry return false, 0 } klog.ErrorS(err, msg) // Retry return false, 0 } if watcher == nil { klog.ErrorS(nil, "Watch returned nil watcher") // Retry return false, 0 } ch := watcher.ResultChan() defer watcher.Stop() for { select { case <-rw.stopChan: klog.V(4).InfoS("Stopping RetryWatcher.") return true, 0 case event, ok := <-ch: if !ok { klog.V(4).InfoS("Failed to get event! Re-creating the watcher.", "resourceVersion", rw.lastResourceVersion) return false, 0 } // We need to inspect the event and get ResourceVersion out of it switch event.Type { case watch.Added, watch.Modified, watch.Deleted, watch.Bookmark: metaObject, ok := event.Object.(resourceVersionGetter) if !ok { _ = rw.send(watch.Event{ Type: watch.Error, Object: &apierrors.NewInternalError(errors.New("retryWatcher: doesn't support resourceVersion")).ErrStatus, }) // We have to abort here because this might cause lastResourceVersion inconsistency by skipping a potential RV with valid data! return true, 0 } resourceVersion := metaObject.GetResourceVersion() if resourceVersion == "" { _ = rw.send(watch.Event{ Type: watch.Error, Object: &apierrors.NewInternalError(fmt.Errorf("retryWatcher: object %#v doesn't support resourceVersion", event.Object)).ErrStatus, }) // We have to abort here because this might cause lastResourceVersion inconsistency by skipping a potential RV with valid data! return true, 0 } // All is fine; send the non-bookmark events and update resource version. if event.Type != watch.Bookmark { ok = rw.send(event) if !ok { return true, 0 } } rw.lastResourceVersion = resourceVersion continue case watch.Error: // This round trip allows us to handle unstructured status errObject := apierrors.FromObject(event.Object) statusErr, ok := errObject.(*apierrors.StatusError) if !ok { klog.Error(fmt.Sprintf("Received an error which is not *metav1.Status but %s", dump.Pretty(event.Object))) // Retry unknown errors return false, 0 } status := statusErr.ErrStatus statusDelay := time.Duration(0) if status.Details != nil { statusDelay = time.Duration(status.Details.RetryAfterSeconds) * time.Second } switch status.Code { case http.StatusGone: // Never retry RV too old errors _ = rw.send(event) return true, 0 case http.StatusGatewayTimeout, http.StatusInternalServerError: // Retry return false, statusDelay default: // We retry by default. RetryWatcher is meant to proceed unless it is certain // that it can't. If we are not certain, we proceed with retry and leave it // up to the user to timeout if needed. // Log here so we have a record of hitting the unexpected error // and we can whitelist some error codes if we missed any that are expected. klog.V(5).Info(fmt.Sprintf("Retrying after unexpected error: %s", dump.Pretty(event.Object))) // Retry return false, statusDelay } default: klog.Errorf("Failed to recognize Event type %q", event.Type) _ = rw.send(watch.Event{ Type: watch.Error, Object: &apierrors.NewInternalError(fmt.Errorf("retryWatcher failed to recognize Event type %q", event.Type)).ErrStatus, }) // We are unable to restart the watch and have to stop the loop or this might cause lastResourceVersion inconsistency by skipping a potential RV with valid data! return true, 0 } } } }
doReceive returns true when it is done, false otherwise. If it is not done the second return value holds the time to wait before calling it again.
doReceive
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/retrywatcher.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/retrywatcher.go
Apache-2.0
func (rw *RetryWatcher) receive() { defer close(rw.doneChan) defer close(rw.resultChan) klog.V(4).Info("Starting RetryWatcher.") defer klog.V(4).Info("Stopping RetryWatcher.") ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { select { case <-rw.stopChan: cancel() return case <-ctx.Done(): return } }() // We use non sliding until so we don't introduce delays on happy path when WATCH call // timeouts or gets closed and we need to reestablish it while also avoiding hot loops. wait.NonSlidingUntilWithContext(ctx, func(ctx context.Context) { done, retryAfter := rw.doReceive() if done { cancel() return } timer := time.NewTimer(retryAfter) select { case <-ctx.Done(): timer.Stop() return case <-timer.C: } klog.V(4).Infof("Restarting RetryWatcher at RV=%q", rw.lastResourceVersion) }, rw.minRestartDelay) }
receive reads the result from a watcher, restarting it if necessary.
receive
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/retrywatcher.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/retrywatcher.go
Apache-2.0
func (rw *RetryWatcher) ResultChan() <-chan watch.Event { return rw.resultChan }
ResultChan implements Interface.
ResultChan
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/retrywatcher.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/retrywatcher.go
Apache-2.0
func (rw *RetryWatcher) Stop() { close(rw.stopChan) }
Stop implements Interface.
Stop
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/retrywatcher.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/retrywatcher.go
Apache-2.0
func UntilWithoutRetry(ctx context.Context, watcher watch.Interface, conditions ...ConditionFunc) (*watch.Event, error) { ch := watcher.ResultChan() defer watcher.Stop() var lastEvent *watch.Event for _, condition := range conditions { // check the next condition against the previous event and short circuit waiting for the next watch if lastEvent != nil { done, err := condition(*lastEvent) if err != nil { return lastEvent, err } if done { continue } } ConditionSucceeded: for { select { case event, ok := <-ch: if !ok { return lastEvent, ErrWatchClosed } lastEvent = &event done, err := condition(event) if err != nil { return lastEvent, err } if done { break ConditionSucceeded } case <-ctx.Done(): return lastEvent, wait.ErrWaitTimeout } } } return lastEvent, nil }
UntilWithoutRetry reads items from the watch until each provided condition succeeds, and then returns the last watch encountered. The first condition that returns an error terminates the watch (and the event is also returned). If no event has been received, the returned event will be nil. Conditions are satisfied sequentially so as to provide a useful primitive for higher level composition. Waits until context deadline or until context is canceled. Warning: Unless you have a very specific use case (probably a special Watcher) don't use this function!!! Warning: This will fail e.g. on API timeouts and/or 'too old resource version' error. Warning: You are most probably looking for a function *Until* or *UntilWithSync* below, Warning: solving such issues. TODO: Consider making this function private to prevent misuse when the other occurrences in our codebase are gone.
UntilWithoutRetry
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/until.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/until.go
Apache-2.0
func Until(ctx context.Context, initialResourceVersion string, watcherClient cache.Watcher, conditions ...ConditionFunc) (*watch.Event, error) { w, err := NewRetryWatcher(initialResourceVersion, watcherClient) if err != nil { return nil, err } return UntilWithoutRetry(ctx, w, conditions...) }
Until wraps the watcherClient's watch function with RetryWatcher making sure that watcher gets restarted in case of errors. The initialResourceVersion will be given to watch method when first called. It shall not be "" or "0" given the underlying WATCH call issues (#74022). Remaining behaviour is identical to function UntilWithoutRetry. (See above.) Until can deal with API timeouts and lost connections. It guarantees you to see all events and in the order they happened. Due to this guarantee there is no way it can deal with 'Resource version too old error'. It will fail in this case. (See `UntilWithSync` if you'd prefer to recover from all the errors including RV too old by re-listing those items. In normal code you should care about being level driven so you'd not care about not seeing all the edges.) The most frequent usage for Until would be a test where you want to verify exact order of events ("edges").
Until
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/until.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/until.go
Apache-2.0
func UntilWithSync(ctx context.Context, lw cache.ListerWatcher, objType runtime.Object, precondition PreconditionFunc, conditions ...ConditionFunc) (*watch.Event, error) { indexer, informer, watcher, done := NewIndexerInformerWatcher(lw, objType) // We need to wait for the internal informers to fully stop so it's easier to reason about // and it works with non-thread safe clients. defer func() { <-done }() // Proxy watcher can be stopped multiple times so it's fine to use defer here to cover alternative branches and // let UntilWithoutRetry to stop it defer watcher.Stop() if precondition != nil { if !cache.WaitForCacheSync(ctx.Done(), informer.HasSynced) { return nil, fmt.Errorf("UntilWithSync: unable to sync caches: %w", ctx.Err()) } done, err := precondition(indexer) if err != nil { return nil, err } if done { return nil, nil } } return UntilWithoutRetry(ctx, watcher, conditions...) }
UntilWithSync creates an informer from lw, optionally checks precondition when the store is synced, and watches the output until each provided condition succeeds, in a way that is identical to function UntilWithoutRetry. (See above.) UntilWithSync can deal with all errors like API timeout, lost connections and 'Resource version too old'. It is the only function that can recover from 'Resource version too old', Until and UntilWithoutRetry will just fail in that case. On the other hand it can't provide you with guarantees as strong as using simple Watch method with Until. It can skip some intermediate events in case of watch function failing but it will re-list to recover and you always get an event, if there has been a change, after recovery. Also with the current implementation based on DeltaFIFO, order of the events you receive is guaranteed only for particular object, not between more of them even it's the same resource. The most frequent usage would be a command that needs to watch the "state of the world" and should't fail, like: waiting for object reaching a state, "small" controllers, ...
UntilWithSync
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/until.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/until.go
Apache-2.0
func ContextWithOptionalTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) { if timeout < 0 { // This should be handled in validation klog.Errorf("Timeout for context shall not be negative!") timeout = 0 } if timeout == 0 { return context.WithCancel(parent) } return context.WithTimeout(parent, timeout) }
ContextWithOptionalTimeout wraps context.WithTimeout and handles infinite timeouts expressed as 0 duration.
ContextWithOptionalTimeout
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/tools/watch/until.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/tools/watch/until.go
Apache-2.0
func (c *cache) put(s string, a *Authenticator) *Authenticator { c.mu.Lock() defer c.mu.Unlock() existing, ok := c.m[s] if ok { return existing } c.m[s] = a return a }
put inserts an authenticator into the cache. If an authenticator is already associated with the key, the first one is returned instead.
put
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
Apache-2.0
func GetAuthenticator(config *api.ExecConfig, cluster *clientauthentication.Cluster) (*Authenticator, error) { return newAuthenticator(globalCache, term.IsTerminal, config, cluster) }
GetAuthenticator returns an exec-based plugin for providing client credentials.
GetAuthenticator
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
Apache-2.0
func (a *Authenticator) UpdateTransportConfig(c *transport.Config) error { // If a bearer token is present in the request - avoid the GetCert callback when // setting up the transport, as that triggers the exec action if the server is // also configured to allow client certificates for authentication. For requests // like "kubectl get --token (token) pods" we should assume the intention is to // use the provided token for authentication. The same can be said for when the // user specifies basic auth or cert auth. if c.HasTokenAuth() || c.HasBasicAuth() || c.HasCertAuth() { return nil } c.Wrap(func(rt http.RoundTripper) http.RoundTripper { return &roundTripper{a, rt} }) if c.HasCertCallback() { return errors.New("can't add TLS certificate callback: transport.Config.TLS.GetCert already set") } c.TLS.GetCertHolder = a.getCert // comparable for TLS config caching if c.DialHolder != nil { if c.DialHolder.Dial == nil { return errors.New("invalid transport.Config.DialHolder: wrapped Dial function is nil") } // if c has a custom dialer, we have to wrap it // TLS config caching is not supported for this config d := connrotation.NewDialerWithTracker(c.DialHolder.Dial, a.connTracker) c.DialHolder = &transport.DialHolder{Dial: d.DialContext} } else { c.DialHolder = a.dial // comparable for TLS config caching } return nil }
UpdateTransportConfig updates the transport.Config to use credentials returned by the plugin.
UpdateTransportConfig
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
Apache-2.0
func (a *Authenticator) maybeRefreshCreds(creds *credentials) error { a.mu.Lock() defer a.mu.Unlock() // Since we're not making a new pointer to a.cachedCreds in getCreds, no // need to do deep comparison. if creds != a.cachedCreds { // Credentials already rotated. return nil } return a.refreshCredsLocked() }
maybeRefreshCreds executes the plugin to force a rotation of the credentials, unless they were rotated already.
maybeRefreshCreds
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
Apache-2.0
func (a *Authenticator) refreshCredsLocked() error { interactive, err := a.interactiveFunc() if err != nil { return fmt.Errorf("exec plugin cannot support interactive mode: %w", err) } cred := &clientauthentication.ExecCredential{ Spec: clientauthentication.ExecCredentialSpec{ Interactive: interactive, }, } if a.provideClusterInfo { cred.Spec.Cluster = a.cluster } env := append(a.environ(), a.env...) data, err := runtime.Encode(codecs.LegacyCodec(a.group), cred) if err != nil { return fmt.Errorf("encode ExecCredentials: %v", err) } env = append(env, fmt.Sprintf("%s=%s", execInfoEnv, data)) stdout := &bytes.Buffer{} cmd := exec.Command(a.cmd, a.args...) cmd.Env = env cmd.Stderr = a.stderr cmd.Stdout = stdout if interactive { cmd.Stdin = a.stdin } err = cmd.Run() incrementCallsMetric(err) if err != nil { return a.wrapCmdRunErrorLocked(err) } _, gvk, err := codecs.UniversalDecoder(a.group).Decode(stdout.Bytes(), nil, cred) if err != nil { return fmt.Errorf("decoding stdout: %v", err) } if gvk.Group != a.group.Group || gvk.Version != a.group.Version { return fmt.Errorf("exec plugin is configured to use API version %s, plugin returned version %s", a.group, schema.GroupVersion{Group: gvk.Group, Version: gvk.Version}) } if cred.Status == nil { return fmt.Errorf("exec plugin didn't return a status field") } if cred.Status.Token == "" && cred.Status.ClientCertificateData == "" && cred.Status.ClientKeyData == "" { return fmt.Errorf("exec plugin didn't return a token or cert/key pair") } if (cred.Status.ClientCertificateData == "") != (cred.Status.ClientKeyData == "") { return fmt.Errorf("exec plugin returned only certificate or key, not both") } if cred.Status.ExpirationTimestamp != nil { a.exp = cred.Status.ExpirationTimestamp.Time } else { a.exp = time.Time{} } newCreds := &credentials{ token: cred.Status.Token, } if cred.Status.ClientKeyData != "" && cred.Status.ClientCertificateData != "" { cert, err := tls.X509KeyPair([]byte(cred.Status.ClientCertificateData), []byte(cred.Status.ClientKeyData)) if err != nil { return fmt.Errorf("failed parsing client key/certificate: %v", err) } // Leaf is initialized to be nil: // https://golang.org/pkg/crypto/tls/#X509KeyPair // Leaf certificate is the first certificate: // https://golang.org/pkg/crypto/tls/#Certificate // Populating leaf is useful for quickly accessing the underlying x509 // certificate values. cert.Leaf, err = x509.ParseCertificate(cert.Certificate[0]) if err != nil { return fmt.Errorf("failed parsing client leaf certificate: %v", err) } newCreds.cert = &cert } oldCreds := a.cachedCreds a.cachedCreds = newCreds // Only close all connections when TLS cert rotates. Token rotation doesn't // need the extra noise. if oldCreds != nil && !reflect.DeepEqual(oldCreds.cert, a.cachedCreds.cert) { // Can be nil if the exec auth plugin only returned token auth. if oldCreds.cert != nil && oldCreds.cert.Leaf != nil { metrics.ClientCertRotationAge.Observe(time.Since(oldCreds.cert.Leaf.NotBefore)) } a.connTracker.CloseAll() } expiry := time.Time{} if a.cachedCreds.cert != nil && a.cachedCreds.cert.Leaf != nil { expiry = a.cachedCreds.cert.Leaf.NotAfter } expirationMetrics.set(a, expiry) return nil }
refreshCredsLocked executes the plugin and reads the credentials from stdout. It must be called while holding the Authenticator's mutex.
refreshCredsLocked
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
Apache-2.0
func (a *Authenticator) wrapCmdRunErrorLocked(err error) error { switch err.(type) { case *exec.Error: // Binary does not exist (see exec.Error). builder := strings.Builder{} fmt.Fprintf(&builder, "exec: executable %s not found", a.cmd) a.sometimes.Do(func() { fmt.Fprint(&builder, installHintVerboseHelp) if a.installHint != "" { fmt.Fprintf(&builder, "\n\n%s", a.installHint) } }) return errors.New(builder.String()) case *exec.ExitError: // Binary execution failed (see exec.Cmd.Run()). e := err.(*exec.ExitError) return fmt.Errorf( "exec: executable %s failed with exit code %d", a.cmd, e.ProcessState.ExitCode(), ) default: return fmt.Errorf("exec: %v", err) }
wrapCmdRunErrorLocked pulls out the code to construct a helpful error message for when the exec plugin's binary fails to Run(). It must be called while holding the Authenticator's mutex.
wrapCmdRunErrorLocked
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
Apache-2.0
func (c *certificateExpirationTracker) set(a *Authenticator, t time.Time) { c.mu.Lock() defer c.mu.Unlock() c.m[a] = t earliest := time.Time{} for _, t := range c.m { if t.IsZero() { continue } if earliest.IsZero() || earliest.After(t) { earliest = t } } if earliest.IsZero() { c.metricSet(nil) } else { c.metricSet(&earliest) } }
set stores the given expiration time and updates the updates the certificate expiry metric to the earliest expiration time.
set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/metrics.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/metrics.go
Apache-2.0
func incrementCallsMetric(err error) { execExitError := &exec.ExitError{} execError := &exec.Error{} pathError := &fs.PathError{} switch { case err == nil: // Binary execution succeeded. metrics.ExecPluginCalls.Increment(successExitCode, noError) case errors.As(err, &execExitError): // Binary execution failed (see "os/exec".Cmd.Run()). metrics.ExecPluginCalls.Increment(execExitError.ExitCode(), pluginExecutionError) case errors.As(err, &execError), errors.As(err, &pathError): // Binary does not exist (see exec.Error, fs.PathError). metrics.ExecPluginCalls.Increment(failureExitCode, pluginNotFoundError) default: // We don't know about this error type. klog.V(2).InfoS("unexpected exec plugin return error type", "type", reflect.TypeOf(err).String(), "err", err) metrics.ExecPluginCalls.Increment(failureExitCode, clientInternalError) } }
incrementCallsMetric increments a global metrics counter for the number of calls to an exec plugin, partitioned by exit code. The provided err should be the return value from exec.Cmd.Run().
incrementCallsMetric
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/metrics.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/metrics.go
Apache-2.0
func (s *severity) get() severity { return severity(atomic.LoadInt32((*int32)(s))) }
get returns the value of the severity.
get
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (s *severity) set(val severity) { atomic.StoreInt32((*int32)(s), int32(val)) }
set sets the value of the severity.
set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (s *severity) String() string { return strconv.FormatInt(int64(*s), 10) }
String is part of the flag.Value interface.
String
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (s *severity) Get() interface{} { return *s }
Get is part of the flag.Value interface.
Get
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (s *severity) Set(value string) error { var threshold severity // Is it a known name? if v, ok := severityByName(value); ok { threshold = v } else { v, err := strconv.ParseInt(value, 10, 32) if err != nil { return err } threshold = severity(v) } logging.stderrThreshold.set(threshold) return nil }
Set is part of the flag.Value interface.
Set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (s *OutputStats) Lines() int64 { return atomic.LoadInt64(&s.lines) }
Lines returns the number of lines written.
Lines
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (s *OutputStats) Bytes() int64 { return atomic.LoadInt64(&s.bytes) }
Bytes returns the number of bytes written.
Bytes
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *Level) get() Level { return Level(atomic.LoadInt32((*int32)(l))) }
get returns the value of the Level.
get
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *Level) set(val Level) { atomic.StoreInt32((*int32)(l), int32(val)) }
set sets the value of the Level.
set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *Level) String() string { return strconv.FormatInt(int64(*l), 10) }
String is part of the flag.Value interface.
String
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *Level) Get() interface{} { return *l }
Get is part of the flag.Value interface.
Get
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *Level) Set(value string) error { v, err := strconv.ParseInt(value, 10, 32) if err != nil { return err } logging.mu.Lock() defer logging.mu.Unlock() logging.setVState(Level(v), logging.vmodule.filter, false) return nil }
Set is part of the flag.Value interface.
Set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (m *modulePat) match(file string) bool { if m.literal { return file == m.pattern } match, _ := filepath.Match(m.pattern, file) return match }
match reports whether the file matches the pattern. It uses a string comparison if the pattern contains no metacharacters.
match
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (m *moduleSpec) Get() interface{} { return nil }
Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the struct is not exported.
Get
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (m *moduleSpec) Set(value string) error { var filter []modulePat for _, pat := range strings.Split(value, ",") { if len(pat) == 0 { // Empty strings such as from a trailing comma can be ignored. continue } patLev := strings.Split(pat, "=") if len(patLev) != 2 || len(patLev[0]) == 0 || len(patLev[1]) == 0 { return errVmoduleSyntax } pattern := patLev[0] v, err := strconv.ParseInt(patLev[1], 10, 32) if err != nil { return errors.New("syntax error: expect comma-separated list of filename=N") } if v < 0 { return errors.New("negative value for vmodule level") } if v == 0 { continue // Ignore. It's harmless but no point in paying the overhead. } // TODO: check syntax of filter? filter = append(filter, modulePat{pattern, isLiteral(pattern), Level(v)}) } logging.mu.Lock() defer logging.mu.Unlock() logging.setVState(logging.verbosity, filter, true) return nil }
Syntax: -vmodule=recordio=2,file=1,gfs*=3
Set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func isLiteral(pattern string) bool { return !strings.ContainsAny(pattern, `\*?[]`) }
isLiteral reports whether the pattern is a literal string, that is, has no metacharacters that require filepath.Match to be called to match the pattern.
isLiteral
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (t *traceLocation) isSet() bool { return t.line > 0 }
isSet reports whether the trace location has been specified. logging.mu is held.
isSet
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (t *traceLocation) match(file string, line int) bool { if t.line != line { return false } if i := strings.LastIndex(file, "/"); i >= 0 { file = file[i+1:] } return t.file == file }
match reports whether the specified file and line matches the trace location. The argument file name is the full path, not the basename specified in the flag. logging.mu is held.
match
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (t *traceLocation) Get() interface{} { return nil }
Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the struct is not exported
Get
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (t *traceLocation) Set(value string) error { if value == "" { // Unset. t.line = 0 t.file = "" } fields := strings.Split(value, ":") if len(fields) != 2 { return errTraceSyntax } file, line := fields[0], fields[1] if !strings.Contains(file, ".") { return errTraceSyntax } v, err := strconv.Atoi(line) if err != nil { return errTraceSyntax } if v <= 0 { return errors.New("negative or zero value for level") } logging.mu.Lock() defer logging.mu.Unlock() t.line = v t.file = file return nil }
Syntax: -log_backtrace_at=gopherflakes.go:234 Note that unlike vmodule the file extension is included here.
Set
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func init() { logging.stderrThreshold = errorLog // Default stderrThreshold is ERROR. logging.setVState(0, nil, false) logging.logDir = "" logging.logFile = "" logging.logFileMaxSizeMB = 1800 logging.toStderr = true logging.alsoToStderr = false logging.skipHeaders = false logging.addDirHeader = false logging.skipLogHeaders = false go logging.flushDaemon() }
init sets up the defaults and runs flushDaemon.
init
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func InitFlags(flagset *flag.FlagSet) { if flagset == nil { flagset = flag.CommandLine } flagset.StringVar(&logging.logDir, "log_dir", logging.logDir, "If non-empty, write log files in this directory") flagset.StringVar(&logging.logFile, "log_file", logging.logFile, "If non-empty, use this log file") flagset.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", logging.logFileMaxSizeMB, "Defines the maximum size a log file can grow to. Unit is megabytes. "+ "If the value is 0, the maximum file size is unlimited.") flagset.BoolVar(&logging.toStderr, "logtostderr", logging.toStderr, "log to standard error instead of files") flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", logging.alsoToStderr, "log to standard error as well as files") flagset.Var(&logging.verbosity, "v", "number for the log level verbosity") flagset.BoolVar(&logging.skipHeaders, "add_dir_header", logging.addDirHeader, "If true, adds the file directory to the header") flagset.BoolVar(&logging.skipHeaders, "skip_headers", logging.skipHeaders, "If true, avoid header prefixes in the log messages") flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", logging.skipLogHeaders, "If true, avoid headers when opening log files") flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr") flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging") flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace") }
InitFlags is for explicitly initializing the flags.
InitFlags
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Flush() { logging.lockAndFlushAll() }
Flush flushes all pending log I/O.
Flush
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) setVState(verbosity Level, filter []modulePat, setFilter bool) { // Turn verbosity off so V will not fire while we are in transition. logging.verbosity.set(0) // Ditto for filter length. atomic.StoreInt32(&logging.filterLength, 0) // Set the new filters and wipe the pc->Level map if the filter has changed. if setFilter { logging.vmodule.filter = filter logging.vmap = make(map[uintptr]Level) } // Things are consistent now, so enable filtering and verbosity. // They are enabled in order opposite to that in V. atomic.StoreInt32(&logging.filterLength, int32(len(filter))) logging.verbosity.set(verbosity) }
setVState sets a consistent state for V logging. l.mu is held.
setVState
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) getBuffer() *buffer { l.freeListMu.Lock() b := l.freeList if b != nil { l.freeList = b.next } l.freeListMu.Unlock() if b == nil { b = new(buffer) } else { b.next = nil b.Reset() } return b }
getBuffer returns a new, ready-to-use buffer.
getBuffer
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) putBuffer(b *buffer) { if b.Len() >= 256 { // Let big buffers die a natural death. return } l.freeListMu.Lock() b.next = l.freeList l.freeList = b l.freeListMu.Unlock() }
putBuffer returns a buffer to the free list.
putBuffer
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) formatHeader(s severity, file string, line int) *buffer { now := timeNow() if line < 0 { line = 0 // not a real line number, but acceptable to someDigits } if s > fatalLog { s = infoLog // for safety. } buf := l.getBuffer() if l.skipHeaders { return buf } // Avoid Fprintf, for speed. The format is so simple that we can do it quickly by hand. // It's worth about 3X. Fprintf is hard. _, month, day := now.Date() hour, minute, second := now.Clock() // Lmmdd hh:mm:ss.uuuuuu threadid file:line] buf.tmp[0] = severityChar[s] buf.twoDigits(1, int(month)) buf.twoDigits(3, day) buf.tmp[5] = ' ' buf.twoDigits(6, hour) buf.tmp[8] = ':' buf.twoDigits(9, minute) buf.tmp[11] = ':' buf.twoDigits(12, second) buf.tmp[14] = '.' buf.nDigits(6, 15, now.Nanosecond()/1000, '0') buf.tmp[21] = ' ' buf.nDigits(7, 22, pid, ' ') // TODO: should be TID buf.tmp[29] = ' ' buf.Write(buf.tmp[:30]) buf.WriteString(file) buf.tmp[0] = ':' n := buf.someDigits(1, line) buf.tmp[n+1] = ']' buf.tmp[n+2] = ' ' buf.Write(buf.tmp[:n+3]) return buf }
formatHeader formats a log header using the provided file name and line number.
formatHeader
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (buf *buffer) twoDigits(i, d int) { buf.tmp[i+1] = digits[d%10] d /= 10 buf.tmp[i] = digits[d%10] }
twoDigits formats a zero-prefixed two-digit integer at buf.tmp[i].
twoDigits
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (buf *buffer) nDigits(n, i, d int, pad byte) { j := n - 1 for ; j >= 0 && d > 0; j-- { buf.tmp[i+j] = digits[d%10] d /= 10 } for ; j >= 0; j-- { buf.tmp[i+j] = pad } }
nDigits formats an n-digit integer at buf.tmp[i], padding with pad on the left. It assumes d >= 0.
nDigits
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (buf *buffer) someDigits(i, d int) int { // Print into the top, then copy down. We know there's space for at least // a 10-digit number. j := len(buf.tmp) for { j-- buf.tmp[j] = digits[d%10] d /= 10 if d == 0 { break } } return copy(buf.tmp[i:], buf.tmp[j:]) }
someDigits formats a zero-prefixed variable-width integer at buf.tmp[i].
someDigits
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) printWithFileLine(s severity, file string, line int, alsoToStderr bool, args ...interface{}) { buf := l.formatHeader(s, file, line) fmt.Fprint(buf, args...) if buf.Bytes()[buf.Len()-1] != '\n' { buf.WriteByte('\n') } l.output(s, buf, file, line, alsoToStderr) }
printWithFileLine behaves like print but uses the provided file and line number. If alsoLogToStderr is true, the log message always appears on standard error; it will also appear in the log file unless --logtostderr is set.
printWithFileLine
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func SetOutput(w io.Writer) { logging.mu.Lock() defer logging.mu.Unlock() for s := fatalLog; s >= infoLog; s-- { rb := &redirectBuffer{ w: w, } logging.file[s] = rb } }
SetOutput sets the output destination for all severities
SetOutput
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func SetOutputBySeverity(name string, w io.Writer) { logging.mu.Lock() defer logging.mu.Unlock() sev, ok := severityByName(name) if !ok { panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name)) } rb := &redirectBuffer{ w: w, } logging.file[sev] = rb }
SetOutputBySeverity sets the output destination for specific severity
SetOutputBySeverity
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoToStderr bool) { l.mu.Lock() if l.traceLocation.isSet() { if l.traceLocation.match(file, line) { buf.Write(stacks(false)) } } data := buf.Bytes() if l.toStderr { os.Stderr.Write(data) } else { if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() { os.Stderr.Write(data) } if logging.logFile != "" { // Since we are using a single log file, all of the items in l.file array // will point to the same file, so just use one of them to write data. if l.file[infoLog] == nil { if err := l.createFiles(infoLog); err != nil { os.Stderr.Write(data) // Make sure the message appears somewhere. l.exit(err) } } l.file[infoLog].Write(data) } else { if l.file[s] == nil { if err := l.createFiles(s); err != nil { os.Stderr.Write(data) // Make sure the message appears somewhere. l.exit(err) } } switch s { case fatalLog: l.file[fatalLog].Write(data) fallthrough case errorLog: l.file[errorLog].Write(data) fallthrough case warningLog: l.file[warningLog].Write(data) fallthrough case infoLog: l.file[infoLog].Write(data) } } } if s == fatalLog { // If we got here via Exit rather than Fatal, print no stacks. if atomic.LoadUint32(&fatalNoStacks) > 0 { l.mu.Unlock() timeoutFlush(10 * time.Second) os.Exit(1) } // Dump all goroutine stacks before exiting. // First, make sure we see the trace for the current goroutine on standard error. // If -logtostderr has been specified, the loop below will do that anyway // as the first stack in the full dump. if !l.toStderr { os.Stderr.Write(stacks(false)) } // Write the stack trace for all goroutines to the files. trace := stacks(true) logExitFunc = func(error) {} // If we get a write error, we'll still exit below. for log := fatalLog; log >= infoLog; log-- { if f := l.file[log]; f != nil { // Can be nil if -logtostderr is set. f.Write(trace) } } l.mu.Unlock() timeoutFlush(10 * time.Second) os.Exit(255) // C++ uses -1, which is silly because it's anded with 255 anyway. } l.putBuffer(buf) l.mu.Unlock() if stats := severityStats[s]; stats != nil { atomic.AddInt64(&stats.lines, 1) atomic.AddInt64(&stats.bytes, int64(len(data))) } }
output writes the data to the log files and releases the buffer.
output
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func timeoutFlush(timeout time.Duration) { done := make(chan bool, 1) go func() { Flush() // calls logging.lockAndFlushAll() done <- true }() select { case <-done: case <-time.After(timeout): fmt.Fprintln(os.Stderr, "klog: Flush took longer than", timeout) } }
timeoutFlush calls Flush and returns when it completes or after timeout elapses, whichever happens first. This is needed because the hooks invoked by Flush may deadlock when klog.Fatal is called from a hook that holds a lock.
timeoutFlush
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func stacks(all bool) []byte { // We don't know how big the traces are, so grow a few times if they don't fit. Start large, though. n := 10000 if all { n = 100000 } var trace []byte for i := 0; i < 5; i++ { trace = make([]byte, n) nbytes := runtime.Stack(trace, all) if nbytes < len(trace) { return trace[:nbytes] } n *= 2 } return trace }
stacks is a wrapper for runtime.Stack that attempts to recover the data for all goroutines.
stacks
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func CalculateMaxSize() uint64 { if logging.logFile != "" { if logging.logFileMaxSizeMB == 0 { // If logFileMaxSizeMB is zero, we don't have limitations on the log size. return math.MaxUint64 } // Flag logFileMaxSizeMB is in MB for user convenience. return logging.logFileMaxSizeMB * 1024 * 1024 } // If "log_file" flag is not specified, the target file (sb.file) will be cleaned up when reaches a fixed size. return MaxSize }
CalculateMaxSize returns the real max size in bytes after considering the default max size and the flag options.
CalculateMaxSize
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (sb *syncBuffer) rotateFile(now time.Time, startup bool) error { if sb.file != nil { sb.Flush() sb.file.Close() } var err error sb.file, _, err = create(severityName[sb.sev], now, startup) sb.nbytes = 0 if err != nil { return err } sb.Writer = bufio.NewWriterSize(sb.file, bufferSize) if sb.logger.skipLogHeaders { return nil } // Write header. var buf bytes.Buffer fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05")) fmt.Fprintf(&buf, "Running on machine: %s\n", host) fmt.Fprintf(&buf, "Binary: Built with %s %s for %s/%s\n", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH) fmt.Fprintf(&buf, "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n") n, err := sb.file.Write(buf.Bytes()) sb.nbytes += uint64(n) return err }
rotateFile closes the syncBuffer's file and starts a new one. The startup argument indicates whether this is the initial startup of klog. If startup is true, existing files are opened for appending instead of truncated.
rotateFile
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) createFiles(sev severity) error { now := time.Now() // Files are created in decreasing severity order, so as soon as we find one // has already been created, we can stop. for s := sev; s >= infoLog && l.file[s] == nil; s-- { sb := &syncBuffer{ logger: l, sev: s, maxbytes: CalculateMaxSize(), } if err := sb.rotateFile(now, true); err != nil { return err } l.file[s] = sb } return nil }
createFiles creates all the log files for severity from sev down to infoLog. l.mu is held.
createFiles
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) flushDaemon() { for range time.NewTicker(flushInterval).C { l.lockAndFlushAll() } }
flushDaemon periodically flushes the log file buffers.
flushDaemon
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) lockAndFlushAll() { l.mu.Lock() l.flushAll() l.mu.Unlock() }
lockAndFlushAll is like flushAll but locks l.mu first.
lockAndFlushAll
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) flushAll() { // Flush from fatal down, in case there's trouble flushing. for s := fatalLog; s >= infoLog; s-- { file := l.file[s] if file != nil { file.Flush() // ignore error file.Sync() // ignore error } } }
flushAll flushes all the logs and attempts to "sync" their data to disk. l.mu is held.
flushAll
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func CopyStandardLogTo(name string) { sev, ok := severityByName(name) if !ok { panic(fmt.Sprintf("log.CopyStandardLogTo(%q): unrecognized severity name", name)) } // Set a log format that captures the user's file and line: // d.go:23: message stdLog.SetFlags(stdLog.Lshortfile) stdLog.SetOutput(logBridge(sev)) }
CopyStandardLogTo arranges for messages written to the Go "log" package's default logs to also appear in the Google logs for the named and lower severities. Subsequent changes to the standard log's default output location or format may break this behavior. Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not recognized, CopyStandardLogTo panics.
CopyStandardLogTo
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (lb logBridge) Write(b []byte) (n int, err error) { var ( file = "???" line = 1 text string ) // Split "d.go:23: message" into "d.go", "23", and "message". if parts := bytes.SplitN(b, []byte{':'}, 3); len(parts) != 3 || len(parts[0]) < 1 || len(parts[2]) < 1 { text = fmt.Sprintf("bad log format: %s", b) } else { file = string(parts[0]) text = string(parts[2][1:]) // skip leading space line, err = strconv.Atoi(string(parts[1])) if err != nil { text = fmt.Sprintf("bad line number: %s", b) line = 1 } } // printWithFileLine with alsoToStderr=true, so standard log messages // always appear on standard error. logging.printWithFileLine(severity(lb), file, line, true, text) return len(b), nil }
Write parses the standard logging line and passes its components to the logger for severity(lb).
Write
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (l *loggingT) setV(pc uintptr) Level { fn := runtime.FuncForPC(pc) file, _ := fn.FileLine(pc) // The file is something like /a/b/c/d.go. We want just the d. if strings.HasSuffix(file, ".go") { file = file[:len(file)-3] } if slash := strings.LastIndex(file, "/"); slash >= 0 { file = file[slash+1:] } for _, filter := range l.vmodule.filter { if filter.match(file) { l.vmap[pc] = filter.level return filter.level } } l.vmap[pc] = 0 return 0 }
setV computes and remembers the V level for a given PC when vmodule is enabled. File pattern matching takes the basename of the file, stripped of its .go suffix, and uses filepath.Match, which is a little more general than the *? matching used in C++. l.mu is held.
setV
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func V(level Level) Verbose { // This function tries hard to be cheap unless there's work to do. // The fast path is two atomic loads and compares. // Here is a cheap but safe test to see if V logging is enabled globally. if logging.verbosity.get() >= level { return Verbose(true) } // It's off globally but it vmodule may still be set. // Here is another cheap but safe test to see if vmodule is enabled. if atomic.LoadInt32(&logging.filterLength) > 0 { // Now we need a proper lock to use the logging structure. The pcs field // is shared so we must lock before accessing it. This is fairly expensive, // but if V logging is enabled we're slow anyway. logging.mu.Lock() defer logging.mu.Unlock() if runtime.Callers(2, logging.pcs[:]) == 0 { return Verbose(false) } v, ok := logging.vmap[logging.pcs[0]] if !ok { v = logging.setV(logging.pcs[0]) } return Verbose(v >= level) } return Verbose(false) }
V reports whether verbosity at the call site is at least the requested level. The returned value is a boolean of type Verbose, which implements Info, Infoln and Infof. These methods will write to the Info log if called. Thus, one may write either if klog.V(2) { klog.Info("log this") } or klog.V(2).Info("log this") The second form is shorter but the first is cheaper if logging is off because it does not evaluate its arguments. Whether an individual call to V generates a log record depends on the setting of the -v and --vmodule flags; both are off by default. If the level in the call to V is at least the value of -v, or of -vmodule for the source file containing the call, the V call will log.
V
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (v Verbose) Info(args ...interface{}) { if v { logging.print(infoLog, args...) } }
Info is equivalent to the global Info function, guarded by the value of v. See the documentation of V for usage.
Info
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (v Verbose) Infoln(args ...interface{}) { if v { logging.println(infoLog, args...) } }
Infoln is equivalent to the global Infoln function, guarded by the value of v. See the documentation of V for usage.
Infoln
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func (v Verbose) Infof(format string, args ...interface{}) { if v { logging.printf(infoLog, format, args...) } }
Infof is equivalent to the global Infof function, guarded by the value of v. See the documentation of V for usage.
Infof
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Info(args ...interface{}) { logging.print(infoLog, args...) }
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Info
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func InfoDepth(depth int, args ...interface{}) { logging.printDepth(infoLog, depth, args...) }
InfoDepth acts as Info but uses depth to determine which call frame to log. InfoDepth(0, "msg") is the same as Info("msg").
InfoDepth
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Infoln(args ...interface{}) { logging.println(infoLog, args...) }
Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is always appended.
Infoln
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Infof(format string, args ...interface{}) { logging.printf(infoLog, format, args...) }
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Infof
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Warning(args ...interface{}) { logging.print(warningLog, args...) }
Warning logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Warning
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func WarningDepth(depth int, args ...interface{}) { logging.printDepth(warningLog, depth, args...) }
WarningDepth acts as Warning but uses depth to determine which call frame to log. WarningDepth(0, "msg") is the same as Warning("msg").
WarningDepth
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Warningln(args ...interface{}) { logging.println(warningLog, args...) }
Warningln logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is always appended.
Warningln
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Warningf(format string, args ...interface{}) { logging.printf(warningLog, format, args...) }
Warningf logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Warningf
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Error(args ...interface{}) { logging.print(errorLog, args...) }
Error logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Error
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func ErrorDepth(depth int, args ...interface{}) { logging.printDepth(errorLog, depth, args...) }
ErrorDepth acts as Error but uses depth to determine which call frame to log. ErrorDepth(0, "msg") is the same as Error("msg").
ErrorDepth
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Errorln(args ...interface{}) { logging.println(errorLog, args...) }
Errorln logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is always appended.
Errorln
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Errorf(format string, args ...interface{}) { logging.printf(errorLog, format, args...) }
Errorf logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Errorf
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Fatal(args ...interface{}) { logging.print(fatalLog, args...) }
Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Fatal
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func FatalDepth(depth int, args ...interface{}) { logging.printDepth(fatalLog, depth, args...) }
FatalDepth acts as Fatal but uses depth to determine which call frame to log. FatalDepth(0, "msg") is the same as Fatal("msg").
FatalDepth
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Fatalln(args ...interface{}) { logging.println(fatalLog, args...) }
Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Println; a newline is always appended.
Fatalln
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Fatalf(format string, args ...interface{}) { logging.printf(fatalLog, format, args...) }
Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
Fatalf
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Exit(args ...interface{}) { atomic.StoreUint32(&fatalNoStacks, 1) logging.print(fatalLog, args...) }
Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Exit
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func ExitDepth(depth int, args ...interface{}) { atomic.StoreUint32(&fatalNoStacks, 1) logging.printDepth(fatalLog, depth, args...) }
ExitDepth acts as Exit but uses depth to determine which call frame to log. ExitDepth(0, "msg") is the same as Exit("msg").
ExitDepth
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0
func Exitln(args ...interface{}) { atomic.StoreUint32(&fatalNoStacks, 1) logging.println(fatalLog, args...) }
Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
Exitln
go
k8snetworkplumbingwg/multus-cni
vendor/k8s.io/klog/klog.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/k8s.io/klog/klog.go
Apache-2.0