aboutsummaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/util
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/util')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/clock/clock.go51
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go174
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go4
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go6
4 files changed, 139 insertions, 96 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go b/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
index 9567f9006..0d739d961 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
@@ -80,7 +80,6 @@ type fakeClockWaiter struct {
stepInterval time.Duration
skipIfBlocked bool
destChan chan time.Time
- fired bool
}
func NewFakeClock(t time.Time) *FakeClock {
@@ -175,12 +174,10 @@ func (f *FakeClock) setTimeLocked(t time.Time) {
if w.skipIfBlocked {
select {
case w.destChan <- t:
- w.fired = true
default:
}
} else {
w.destChan <- t
- w.fired = true
}
if w.stepInterval > 0 {
@@ -287,36 +284,50 @@ func (f *fakeTimer) C() <-chan time.Time {
return f.waiter.destChan
}
-// Stop stops the timer and returns true if the timer has not yet fired, or false otherwise.
+// Stop conditionally stops the timer. If the timer has neither fired
+// nor been stopped then this call stops the timer and returns true,
+// otherwise this call returns false. This is like time.Timer::Stop.
func (f *fakeTimer) Stop() bool {
f.fakeClock.lock.Lock()
defer f.fakeClock.lock.Unlock()
-
- newWaiters := make([]fakeClockWaiter, 0, len(f.fakeClock.waiters))
- for i := range f.fakeClock.waiters {
- w := &f.fakeClock.waiters[i]
- if w != &f.waiter {
- newWaiters = append(newWaiters, *w)
+ // The timer has already fired or been stopped, unless it is found
+ // among the clock's waiters.
+ stopped := false
+ oldWaiters := f.fakeClock.waiters
+ newWaiters := make([]fakeClockWaiter, 0, len(oldWaiters))
+ seekChan := f.waiter.destChan
+ for i := range oldWaiters {
+ // Identify the timer's fakeClockWaiter by the identity of the
+ // destination channel, nothing else is necessarily unique and
+ // constant since the timer's creation.
+ if oldWaiters[i].destChan == seekChan {
+ stopped = true
+ } else {
+ newWaiters = append(newWaiters, oldWaiters[i])
}
}
f.fakeClock.waiters = newWaiters
- return !f.waiter.fired
+ return stopped
}
-// Reset resets the timer to the fake clock's "now" + d. It returns true if the timer has not yet
-// fired, or false otherwise.
+// Reset conditionally updates the firing time of the timer. If the
+// timer has neither fired nor been stopped then this call resets the
+// timer to the fake clock's "now" + d and returns true, otherwise
+// this call returns false. This is like time.Timer::Reset.
func (f *fakeTimer) Reset(d time.Duration) bool {
f.fakeClock.lock.Lock()
defer f.fakeClock.lock.Unlock()
-
- active := !f.waiter.fired
-
- f.waiter.fired = false
- f.waiter.targetTime = f.fakeClock.time.Add(d)
-
- return active
+ waiters := f.fakeClock.waiters
+ seekChan := f.waiter.destChan
+ for i := range waiters {
+ if waiters[i].destChan == seekChan {
+ waiters[i].targetTime = f.fakeClock.time.Add(d)
+ return true
+ }
+ }
+ return false
}
type Ticker interface {
diff --git a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
index 48dd7d9c5..64cbc7703 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
@@ -17,22 +17,17 @@ limitations under the License.
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto
-/*
- Package intstr is a generated protocol buffer package.
-
- It is generated from these files:
- k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto
-
- It has these top-level messages:
- IntOrString
-*/
package intstr
-import proto "github.com/gogo/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+ fmt "fmt"
+
+ io "io"
+ math "math"
+ math_bits "math/bits"
-import io "io"
+ proto "github.com/gogo/protobuf/proto"
+)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
@@ -45,17 +40,69 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
-func (m *IntOrString) Reset() { *m = IntOrString{} }
-func (*IntOrString) ProtoMessage() {}
-func (*IntOrString) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{0} }
+func (m *IntOrString) Reset() { *m = IntOrString{} }
+func (*IntOrString) ProtoMessage() {}
+func (*IntOrString) Descriptor() ([]byte, []int) {
+ return fileDescriptor_94e046ae3ce6121c, []int{0}
+}
+func (m *IntOrString) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *IntOrString) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+}
+func (m *IntOrString) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_IntOrString.Merge(m, src)
+}
+func (m *IntOrString) XXX_Size() int {
+ return m.Size()
+}
+func (m *IntOrString) XXX_DiscardUnknown() {
+ xxx_messageInfo_IntOrString.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_IntOrString proto.InternalMessageInfo
func init() {
proto.RegisterType((*IntOrString)(nil), "k8s.io.apimachinery.pkg.util.intstr.IntOrString")
}
+
+func init() {
+ proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto", fileDescriptor_94e046ae3ce6121c)
+}
+
+var fileDescriptor_94e046ae3ce6121c = []byte{
+ // 292 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0x31, 0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
+ 0xee, 0xdf, 0x97, 0x86, 0x7f, 0x77, 0x67, 0xec, 0x89, 0xe1, 0x45, 0x30, 0x90, 0x0a, 0x1e, 0x92,
+ 0xd5, 0xe8, 0x5f, 0x88, 0xa3, 0xff, 0x93, 0xe3, 0x8e, 0x1d, 0x4c, 0x7d, 0x1b, 0x77, 0x6b, 0xc3,
+ 0xe5, 0x60, 0x1b, 0xae, 0x17, 0xe2, 0xe8, 0xf0, 0x97, 0x9b, 0xf9, 0x36, 0xee, 0xd6, 0x9b, 0x83,
+ 0xb7, 0xf7, 0x31, 0xda, 0x7c, 0x84, 0x68, 0x72, 0x59, 0xd5, 0x04, 0x6d, 0x6b, 0x82, 0x76, 0x35,
+ 0x41, 0x1b, 0x47, 0x70, 0xe5, 0x08, 0xde, 0x3a, 0x82, 0x77, 0x8e, 0xe0, 0x4f, 0x47, 0xf0, 0xcb,
+ 0x17, 0x41, 0x8f, 0x83, 0xf6, 0xc3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x52, 0xa0, 0xb5, 0xc9,
+ 0x64, 0x01, 0x00, 0x00,
+}
+
func (m *IntOrString) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
@@ -63,33 +110,44 @@ func (m *IntOrString) Marshal() (dAtA []byte, err error) {
}
func (m *IntOrString) MarshalTo(dAtA []byte) (int, error) {
- var i int
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *IntOrString) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
_ = i
var l int
_ = l
- dAtA[i] = 0x8
- i++
- i = encodeVarintGenerated(dAtA, i, uint64(m.Type))
- dAtA[i] = 0x10
- i++
- i = encodeVarintGenerated(dAtA, i, uint64(m.IntVal))
- dAtA[i] = 0x1a
- i++
+ i -= len(m.StrVal)
+ copy(dAtA[i:], m.StrVal)
i = encodeVarintGenerated(dAtA, i, uint64(len(m.StrVal)))
- i += copy(dAtA[i:], m.StrVal)
- return i, nil
+ i--
+ dAtA[i] = 0x1a
+ i = encodeVarintGenerated(dAtA, i, uint64(m.IntVal))
+ i--
+ dAtA[i] = 0x10
+ i = encodeVarintGenerated(dAtA, i, uint64(m.Type))
+ i--
+ dAtA[i] = 0x8
+ return len(dAtA) - i, nil
}
func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int {
+ offset -= sovGenerated(v)
+ base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
- return offset + 1
+ return base
}
func (m *IntOrString) Size() (n int) {
+ if m == nil {
+ return 0
+ }
var l int
_ = l
n += 1 + sovGenerated(uint64(m.Type))
@@ -100,14 +158,7 @@ func (m *IntOrString) Size() (n int) {
}
func sovGenerated(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
+ return (math_bits.Len64(x|1) + 6) / 7
}
func sozGenerated(x uint64) (n int) {
return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63))))
@@ -127,7 +178,7 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
+ wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
@@ -155,7 +206,7 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- m.Type |= (Type(b) & 0x7F) << shift
+ m.Type |= Type(b&0x7F) << shift
if b < 0x80 {
break
}
@@ -174,7 +225,7 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- m.IntVal |= (int32(b) & 0x7F) << shift
+ m.IntVal |= int32(b&0x7F) << shift
if b < 0x80 {
break
}
@@ -193,7 +244,7 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
+ stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
@@ -203,6 +254,9 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
return ErrInvalidLengthGenerated
}
postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGenerated
+ }
if postIndex > l {
return io.ErrUnexpectedEOF
}
@@ -217,6 +271,9 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
if skippy < 0 {
return ErrInvalidLengthGenerated
}
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGenerated
+ }
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
@@ -283,10 +340,13 @@ func skipGenerated(dAtA []byte) (n int, err error) {
break
}
}
- iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthGenerated
}
+ iNdEx += length
+ if iNdEx < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
return iNdEx, nil
case 3:
for {
@@ -315,6 +375,9 @@ func skipGenerated(dAtA []byte) (n int, err error) {
return 0, err
}
iNdEx = start + next
+ if iNdEx < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
}
return iNdEx, nil
case 4:
@@ -333,30 +396,3 @@ var (
ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
)
-
-func init() {
- proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto", fileDescriptorGenerated)
-}
-
-var fileDescriptorGenerated = []byte{
- // 292 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0x31, 0x4b, 0x33, 0x31,
- 0x1c, 0xc6, 0x93, 0xb7, 0x7d, 0x8b, 0x9e, 0xe0, 0x50, 0x1c, 0x8a, 0x43, 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xe8, 0x5f, 0x88, 0xa3, 0xff, 0x93, 0xe3, 0x8e, 0x1d, 0x4c, 0x7d, 0x1b, 0x77, 0x6b, 0xc3,
- 0xe5, 0x60, 0x1b, 0xae, 0x17, 0xe2, 0xe8, 0xf0, 0x97, 0x9b, 0xf9, 0x36, 0xee, 0xd6, 0x9b, 0x83,
- 0xb7, 0xf7, 0x31, 0xda, 0x7c, 0x84, 0x68, 0x72, 0x59, 0xd5, 0x04, 0x6d, 0x6b, 0x82, 0x76, 0x35,
- 0x41, 0x1b, 0x47, 0x70, 0xe5, 0x08, 0xde, 0x3a, 0x82, 0x77, 0x8e, 0xe0, 0x4f, 0x47, 0xf0, 0xcb,
- 0x17, 0x41, 0x8f, 0x83, 0xf6, 0xc3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x52, 0xa0, 0xb5, 0xc9,
- 0x64, 0x01, 0x00, 0x00,
-}
diff --git a/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go b/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
index 5b26ed262..12c8a7b6c 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
@@ -122,11 +122,11 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
// the OpenAPI spec of this type.
//
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
-func (_ IntOrString) OpenAPISchemaType() []string { return []string{"string"} }
+func (IntOrString) OpenAPISchemaType() []string { return []string{"string"} }
// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
-func (_ IntOrString) OpenAPISchemaFormat() string { return "int-or-string" }
+func (IntOrString) OpenAPISchemaFormat() string { return "int-or-string" }
func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
if intstr == nil {
diff --git a/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go b/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
index 3c886f46c..c7348129a 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
@@ -40,11 +40,7 @@ var PanicHandlers = []func(interface{}){logPanic}
// 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.
+// E.g., you can provide one or more additional handlers for something like shutting down go routines gracefully.
func HandleCrash(additionalHandlers ...func(interface{})) {
if r := recover(); r != nil {
for _, fn := range PanicHandlers {