apimachinery: k8s.io/apimachinery/pkg/util/runtime Index | Files

package runtime

import "k8s.io/apimachinery/pkg/util/runtime"

Index

Package Files

runtime.go

Variables

var ErrorHandlers = []func(error){
    logError,
    (&rudimentaryErrorBackoff{
        lastErrorTime: time.Now(),

        minPeriod: time.Millisecond,
    }).OnError,
}

ErrorHandlers is a list of functions which will be invoked when an unreturnable error occurs. TODO(lavalamp): for testability, this and the below HandleError function should be packaged up into a testable and reusable object.

var PanicHandlers = []func(interface{}){logPanic}

PanicHandlers is a list of functions which will be invoked when a panic happens.

var (
    // ReallyCrash controls the behavior of HandleCrash and now defaults
    // true. It's still exposed so components can optionally set to false
    // to restore prior behavior.
    ReallyCrash = true
)

func GetCaller Uses

func GetCaller() string

GetCaller returns the caller of the function that calls it.

func HandleCrash Uses

func HandleCrash(additionalHandlers ...func(interface{}))

HandleCrash simply catches a crash and logs an error. Meant to be called via defer. Additional context-specific handlers can be provided, and will be called in case of panic. HandleCrash actually crashes, after calling the handlers and logging the panic message.

TODO: remove this function. We are switching to a world where it's safe for apiserver to panic, since it will be restarted by kubelet. At the beginning of the Kubernetes project, nothing was going to restart apiserver and so catching panics was important. But it's actually much simpler for monitoring software if we just exit when an unexpected panic happens.

func HandleError Uses

func HandleError(err error)

HandlerError is a method to invoke when a non-user facing piece of code cannot return an error and needs to indicate it has been ignored. Invoking this method is preferable to logging the error - the default behavior is to log but the errors may be sent to a remote server for analysis.

func Must Uses

func Must(err error)

Must panics on non-nil errors. Useful to handling programmer level errors.

func RecoverFromPanic Uses

func RecoverFromPanic(err *error)

RecoverFromPanic replaces the specified error with an error containing the original error, and the call tree when a panic occurs. This enables error handlers to handle errors and panics the same way.

Package runtime imports 5 packages (graph) and is imported by 2259 packages. Updated 2019-06-12. Refresh now. Tools for package owners.