vendor: update kubernetes v1.18.0-beta.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2020-03-05 19:53:52 +01:00
parent 4210588d3c
commit a3e7f68fa5
59 changed files with 5215 additions and 1802 deletions

20
vendor/k8s.io/client-go/go.mod generated vendored
View File

@@ -10,34 +10,34 @@ require (
github.com/Azure/go-autorest/autorest/adal v0.5.0
github.com/davecgh/go-spew v1.1.1
github.com/evanphx/json-patch v4.2.0+incompatible
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d
github.com/gogo/protobuf v1.3.1
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903
github.com/golang/protobuf v1.3.2
github.com/google/btree v1.0.0 // indirect
github.com/google/gofuzz v1.0.0
github.com/google/gofuzz v1.1.0
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d
github.com/googleapis/gnostic v0.1.0
github.com/gophercloud/gophercloud v0.1.0
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7
github.com/imdario/mergo v0.3.5
github.com/peterbourgon/diskv v2.0.1+incompatible
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
google.golang.org/appengine v1.5.0 // indirect
k8s.io/api v0.18.0-alpha.1
k8s.io/apimachinery v0.18.0-alpha.1
k8s.io/api v0.18.0-beta.1
k8s.io/apimachinery v0.18.0-beta.1
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f
sigs.k8s.io/yaml v1.1.0
k8s.io/utils v0.0.0-20200117235808-5f6fbceb4c31
sigs.k8s.io/yaml v1.2.0
)
replace (
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13
k8s.io/api => k8s.io/api v0.18.0-alpha.1
k8s.io/apimachinery => k8s.io/apimachinery v0.18.0-alpha.1
k8s.io/api => k8s.io/api v0.18.0-beta.1
k8s.io/apimachinery => k8s.io/apimachinery v0.18.0-beta.1
)

View File

@@ -30,6 +30,7 @@ import (
"reflect"
"strconv"
"strings"
"sync"
"time"
"golang.org/x/net/http2"
@@ -51,6 +52,9 @@ var (
// throttled (via the provided rateLimiter) for more than longThrottleLatency will
// be logged.
longThrottleLatency = 50 * time.Millisecond
// extraLongThrottleLatency defines the threshold for logging requests at log level 2.
extraLongThrottleLatency = 1 * time.Second
)
// HTTPClient is an interface for testing a request object.
@@ -61,8 +65,8 @@ type HTTPClient interface {
// ResponseWrapper is an interface for getting a response.
// The response may be either accessed as a raw data (the whole output is put into memory) or as a stream.
type ResponseWrapper interface {
DoRaw() ([]byte, error)
Stream() (io.ReadCloser, error)
DoRaw(context.Context) ([]byte, error)
Stream(context.Context) (io.ReadCloser, error)
}
// RequestConstructionError is returned when there's an error assembling a request.
@@ -104,9 +108,6 @@ type Request struct {
// output
err error
body io.Reader
// This is only used for per-request timeouts, deadlines, and cancellations.
ctx context.Context
}
// NewRequest creates a new request helper object for accessing runtime.Objects on a server.
@@ -438,13 +439,6 @@ func (r *Request) Body(obj interface{}) *Request {
return r
}
// Context adds a context to the request. Contexts are only used for
// timeouts, deadlines, and cancellations.
func (r *Request) Context(ctx context.Context) *Request {
r.ctx = ctx
return r
}
// URL returns the current working URL.
func (r *Request) URL() *url.URL {
p := r.pathPrefix
@@ -548,29 +542,56 @@ func (r Request) finalURLTemplate() url.URL {
return *url
}
func (r *Request) tryThrottle() error {
func (r *Request) tryThrottle(ctx context.Context) error {
if r.rateLimiter == nil {
return nil
}
now := time.Now()
var err error
if r.ctx != nil {
err = r.rateLimiter.Wait(r.ctx)
} else {
r.rateLimiter.Accept()
}
if latency := time.Since(now); latency > longThrottleLatency {
err := r.rateLimiter.Wait(ctx)
latency := time.Since(now)
if latency > longThrottleLatency {
klog.V(3).Infof("Throttling request took %v, request: %s:%s", latency, r.verb, r.URL().String())
}
if latency > extraLongThrottleLatency {
globalThrottledLogger.Log(2, fmt.Sprintf("Throttling request took %v, request: %s:%s", latency, r.verb, r.URL().String()))
}
return err
}
type throttledLogger struct {
logTimeLock sync.RWMutex
lastLogTime time.Time
minLogInterval time.Duration
}
var globalThrottledLogger = &throttledLogger{
minLogInterval: 1 * time.Second,
}
func (b *throttledLogger) Log(level klog.Level, message string) {
if bool(klog.V(level)) {
if func() bool {
b.logTimeLock.RLock()
defer b.logTimeLock.RUnlock()
return time.Since(b.lastLogTime) > b.minLogInterval
}() {
b.logTimeLock.Lock()
defer b.logTimeLock.Unlock()
if time.Since(b.lastLogTime) > b.minLogInterval {
klog.V(level).Info(message)
b.lastLogTime = time.Now()
}
}
}
}
// Watch attempts to begin watching the requested location.
// Returns a watch.Interface, or an error.
func (r *Request) Watch() (watch.Interface, error) {
func (r *Request) Watch(ctx context.Context) (watch.Interface, error) {
// We specifically don't want to rate limit watches, so we
// don't use r.rateLimiter here.
if r.err != nil {
@@ -582,9 +603,7 @@ func (r *Request) Watch() (watch.Interface, error) {
if err != nil {
return nil, err
}
if r.ctx != nil {
req = req.WithContext(r.ctx)
}
req = req.WithContext(ctx)
req.Header = r.headers
client := r.c.Client
if client == nil {
@@ -659,12 +678,12 @@ func updateURLMetrics(req *Request, resp *http.Response, err error) {
// Returns io.ReadCloser which could be used for streaming of the response, or an error
// Any non-2xx http status code causes an error. If we get a non-2xx code, we try to convert the body into an APIStatus object.
// If we can, we return that as an error. Otherwise, we create an error that lists the http status and the content of the response.
func (r *Request) Stream() (io.ReadCloser, error) {
func (r *Request) Stream(ctx context.Context) (io.ReadCloser, error) {
if r.err != nil {
return nil, r.err
}
if err := r.tryThrottle(); err != nil {
if err := r.tryThrottle(ctx); err != nil {
return nil, err
}
@@ -676,9 +695,7 @@ func (r *Request) Stream() (io.ReadCloser, error) {
if r.body != nil {
req.Body = ioutil.NopCloser(r.body)
}
if r.ctx != nil {
req = req.WithContext(r.ctx)
}
req = req.WithContext(ctx)
req.Header = r.headers
client := r.c.Client
if client == nil {
@@ -746,7 +763,7 @@ func (r *Request) requestPreflightCheck() error {
// received. It handles retry behavior and up front validation of requests. It will invoke
// fn at most once. It will return an error if a problem occurred prior to connecting to the
// server - the provided function is responsible for handling server errors.
func (r *Request) request(fn func(*http.Request, *http.Response)) error {
func (r *Request) request(ctx context.Context, fn func(*http.Request, *http.Response)) error {
//Metrics for total request latency
start := time.Now()
defer func() {
@@ -767,26 +784,30 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
client = http.DefaultClient
}
// Throttle the first try before setting up the timeout configured on the
// client. We don't want a throttled client to return timeouts to callers
// before it makes a single request.
if err := r.tryThrottle(ctx); err != nil {
return err
}
if r.timeout > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, r.timeout)
defer cancel()
}
// Right now we make about ten retry attempts if we get a Retry-After response.
maxRetries := 10
retries := 0
for {
url := r.URL().String()
req, err := http.NewRequest(r.verb, url, r.body)
if err != nil {
return err
}
if r.timeout > 0 {
if r.ctx == nil {
r.ctx = context.Background()
}
var cancelFn context.CancelFunc
r.ctx, cancelFn = context.WithTimeout(r.ctx, r.timeout)
defer cancelFn()
}
if r.ctx != nil {
req = req.WithContext(r.ctx)
}
req = req.WithContext(ctx)
req.Header = r.headers
r.backoff.Sleep(r.backoff.CalculateBackoff(r.URL()))
@@ -794,7 +815,7 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
// We are retrying the request that we already send to apiserver
// at least once before.
// This request should also be throttled with the client-internal rate limiter.
if err := r.tryThrottle(); err != nil {
if err := r.tryThrottle(ctx); err != nil {
return err
}
}
@@ -806,7 +827,7 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
r.backoff.UpdateBackoff(r.URL(), err, resp.StatusCode)
}
if err != nil {
// "Connection reset by peer", "Connection refused" or "apiserver is shutting down" are usually a transient errors.
// "Connection reset by peer" or "apiserver is shutting down" are usually a transient errors.
// Thus in case of "GET" operations, we simply retry it.
// We are not automatically retrying "write" operations, as
// they are not idempotent.
@@ -814,7 +835,7 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
return err
}
// For connection errors and apiserver shutdown errors retry.
if net.IsConnectionReset(err) || net.IsConnectionRefused(err) {
if net.IsConnectionReset(err) {
// For the purpose of retry, we set the artificial "retry-after" response.
// TODO: Should we clean the original response if it exists?
resp = &http.Response{
@@ -869,13 +890,9 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
// Error type:
// * If the server responds with a status: *errors.StatusError or *errors.UnexpectedObjectError
// * http.Client.Do errors are returned directly.
func (r *Request) Do() Result {
if err := r.tryThrottle(); err != nil {
return Result{err: err}
}
func (r *Request) Do(ctx context.Context) Result {
var result Result
err := r.request(func(req *http.Request, resp *http.Response) {
err := r.request(ctx, func(req *http.Request, resp *http.Response) {
result = r.transformResponse(resp, req)
})
if err != nil {
@@ -885,13 +902,9 @@ func (r *Request) Do() Result {
}
// DoRaw executes the request but does not process the response body.
func (r *Request) DoRaw() ([]byte, error) {
if err := r.tryThrottle(); err != nil {
return nil, err
}
func (r *Request) DoRaw(ctx context.Context) ([]byte, error) {
var result Result
err := r.request(func(req *http.Request, resp *http.Response) {
err := r.request(ctx, func(req *http.Request, resp *http.Response) {
result.body, result.err = ioutil.ReadAll(resp.Body)
glogBody("Response Body", result.body)
if resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent {

View File

@@ -77,11 +77,6 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.
closable := &closableConn{Conn: conn}
// Start tracking the connection
d.mu.Lock()
d.conns[closable] = struct{}{}
d.mu.Unlock()
// When the connection is closed, remove it from the map. This will
// be no-op if the connection isn't in the map, e.g. if CloseAll()
// is called.
@@ -91,6 +86,11 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.
d.mu.Unlock()
}
// Start tracking the connection
d.mu.Lock()
d.conns[closable] = struct{}{}
d.mu.Unlock()
return closable, nil
}