mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Use coordination v1 API
This commit is contained in:
parent
f20876908f
commit
e8ca50c43c
@ -6,14 +6,14 @@ go_library(
|
|||||||
importpath = "k8s.io/kubernetes/pkg/kubelet/nodelease",
|
importpath = "k8s.io/kubernetes/pkg/kubelet/nodelease",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
"//vendor/k8s.io/utils/pointer:go_default_library",
|
"//vendor/k8s.io/utils/pointer:go_default_library",
|
||||||
],
|
],
|
||||||
@ -24,7 +24,7 @@ go_test(
|
|||||||
srcs = ["controller_test.go"],
|
srcs = ["controller_test.go"],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
|
@ -20,14 +20,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
coordv1beta1 "k8s.io/api/coordination/v1beta1"
|
coordinationv1 "k8s.io/api/coordination/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
coordclientset "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
|
coordclientset "k8s.io/client-go/kubernetes/typed/coordination/v1"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
@ -35,9 +35,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// renewInterval is the interval at which the lease is renewed
|
// renewInterval is the interval at which the lease is renewed
|
||||||
// TODO(mtaufen): 10s was the decision in the KEP, to keep the behavior as close to the
|
|
||||||
// current default behavior as possible. In the future, we should determine a reasonable
|
|
||||||
// fraction of the lease duration at which to renew, and use that instead.
|
|
||||||
renewInterval = 10 * time.Second
|
renewInterval = 10 * time.Second
|
||||||
// maxUpdateRetries is the number of immediate, successive retries the Kubelet will attempt
|
// maxUpdateRetries is the number of immediate, successive retries the Kubelet will attempt
|
||||||
// when renewing the lease before it waits for the renewal interval before trying again,
|
// when renewing the lease before it waits for the renewal interval before trying again,
|
||||||
@ -66,7 +63,7 @@ type controller struct {
|
|||||||
func NewController(clock clock.Clock, client clientset.Interface, holderIdentity string, leaseDurationSeconds int32, onRepeatedHeartbeatFailure func()) Controller {
|
func NewController(clock clock.Clock, client clientset.Interface, holderIdentity string, leaseDurationSeconds int32, onRepeatedHeartbeatFailure func()) Controller {
|
||||||
var leaseClient coordclientset.LeaseInterface
|
var leaseClient coordclientset.LeaseInterface
|
||||||
if client != nil {
|
if client != nil {
|
||||||
leaseClient = client.CoordinationV1beta1().Leases(corev1.NamespaceNodeLease)
|
leaseClient = client.CoordinationV1().Leases(corev1.NamespaceNodeLease)
|
||||||
}
|
}
|
||||||
return &controller{
|
return &controller{
|
||||||
client: client,
|
client: client,
|
||||||
@ -102,9 +99,9 @@ func (c *controller) sync() {
|
|||||||
// and uses exponentially increasing waits to prevent overloading the API server
|
// and uses exponentially increasing waits to prevent overloading the API server
|
||||||
// with retries. Returns the lease, and true if this call created the lease,
|
// with retries. Returns the lease, and true if this call created the lease,
|
||||||
// false otherwise.
|
// false otherwise.
|
||||||
func (c *controller) backoffEnsureLease() (*coordv1beta1.Lease, bool) {
|
func (c *controller) backoffEnsureLease() (*coordinationv1.Lease, bool) {
|
||||||
var (
|
var (
|
||||||
lease *coordv1beta1.Lease
|
lease *coordinationv1.Lease
|
||||||
created bool
|
created bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
@ -124,7 +121,7 @@ func (c *controller) backoffEnsureLease() (*coordv1beta1.Lease, bool) {
|
|||||||
|
|
||||||
// ensureLease creates the lease if it does not exist. Returns the lease and
|
// ensureLease creates the lease if it does not exist. Returns the lease and
|
||||||
// a bool (true if this call created the lease), or any error that occurs.
|
// a bool (true if this call created the lease), or any error that occurs.
|
||||||
func (c *controller) ensureLease() (*coordv1beta1.Lease, bool, error) {
|
func (c *controller) ensureLease() (*coordinationv1.Lease, bool, error) {
|
||||||
lease, err := c.leaseClient.Get(c.holderIdentity, metav1.GetOptions{})
|
lease, err := c.leaseClient.Get(c.holderIdentity, metav1.GetOptions{})
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
// lease does not exist, create it
|
// lease does not exist, create it
|
||||||
@ -143,7 +140,7 @@ func (c *controller) ensureLease() (*coordv1beta1.Lease, bool, error) {
|
|||||||
|
|
||||||
// retryUpdateLease attempts to update the lease for maxUpdateRetries,
|
// retryUpdateLease attempts to update the lease for maxUpdateRetries,
|
||||||
// call this once you're sure the lease has been created
|
// call this once you're sure the lease has been created
|
||||||
func (c *controller) retryUpdateLease(base *coordv1beta1.Lease) error {
|
func (c *controller) retryUpdateLease(base *coordinationv1.Lease) error {
|
||||||
for i := 0; i < maxUpdateRetries; i++ {
|
for i := 0; i < maxUpdateRetries; i++ {
|
||||||
_, err := c.leaseClient.Update(c.newLease(base))
|
_, err := c.leaseClient.Update(c.newLease(base))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -164,17 +161,17 @@ func (c *controller) retryUpdateLease(base *coordv1beta1.Lease) error {
|
|||||||
|
|
||||||
// newLease constructs a new lease if base is nil, or returns a copy of base
|
// newLease constructs a new lease if base is nil, or returns a copy of base
|
||||||
// with desired state asserted on the copy.
|
// with desired state asserted on the copy.
|
||||||
func (c *controller) newLease(base *coordv1beta1.Lease) *coordv1beta1.Lease {
|
func (c *controller) newLease(base *coordinationv1.Lease) *coordinationv1.Lease {
|
||||||
// Use the bare minimum set of fields; other fields exist for debugging/legacy,
|
// Use the bare minimum set of fields; other fields exist for debugging/legacy,
|
||||||
// but we don't need to make node heartbeats more complicated by using them.
|
// but we don't need to make node heartbeats more complicated by using them.
|
||||||
var lease *coordv1beta1.Lease
|
var lease *coordinationv1.Lease
|
||||||
if base == nil {
|
if base == nil {
|
||||||
lease = &coordv1beta1.Lease{
|
lease = &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: c.holderIdentity,
|
Name: c.holderIdentity,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(c.holderIdentity),
|
HolderIdentity: pointer.StringPtr(c.holderIdentity),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(c.leaseDurationSeconds),
|
LeaseDurationSeconds: pointer.Int32Ptr(c.leaseDurationSeconds),
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
coordv1beta1 "k8s.io/api/coordination/v1beta1"
|
coordinationv1 "k8s.io/api/coordination/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -47,8 +47,8 @@ func TestNewLease(t *testing.T) {
|
|||||||
cases := []struct {
|
cases := []struct {
|
||||||
desc string
|
desc string
|
||||||
controller *controller
|
controller *controller
|
||||||
base *coordv1beta1.Lease
|
base *coordinationv1.Lease
|
||||||
expect *coordv1beta1.Lease
|
expect *coordinationv1.Lease
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "nil base without node",
|
desc: "nil base without node",
|
||||||
@ -59,12 +59,12 @@ func TestNewLease(t *testing.T) {
|
|||||||
clock: fakeClock,
|
clock: fakeClock,
|
||||||
},
|
},
|
||||||
base: nil,
|
base: nil,
|
||||||
expect: &coordv1beta1.Lease{
|
expect: &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(node.Name),
|
HolderIdentity: pointer.StringPtr(node.Name),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
||||||
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
||||||
@ -80,7 +80,7 @@ func TestNewLease(t *testing.T) {
|
|||||||
clock: fakeClock,
|
clock: fakeClock,
|
||||||
},
|
},
|
||||||
base: nil,
|
base: nil,
|
||||||
expect: &coordv1beta1.Lease{
|
expect: &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
@ -93,7 +93,7 @@ func TestNewLease(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(node.Name),
|
HolderIdentity: pointer.StringPtr(node.Name),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
||||||
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
||||||
@ -108,18 +108,18 @@ func TestNewLease(t *testing.T) {
|
|||||||
leaseDurationSeconds: 10,
|
leaseDurationSeconds: 10,
|
||||||
clock: fakeClock,
|
clock: fakeClock,
|
||||||
},
|
},
|
||||||
base: &coordv1beta1.Lease{
|
base: &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(node.Name),
|
HolderIdentity: pointer.StringPtr(node.Name),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
||||||
RenewTime: &metav1.MicroTime{Time: fakeClock.Now().Add(-10 * time.Second)},
|
RenewTime: &metav1.MicroTime{Time: fakeClock.Now().Add(-10 * time.Second)},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: &coordv1beta1.Lease{
|
expect: &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
@ -132,7 +132,7 @@ func TestNewLease(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(node.Name),
|
HolderIdentity: pointer.StringPtr(node.Name),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
||||||
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
||||||
@ -147,7 +147,7 @@ func TestNewLease(t *testing.T) {
|
|||||||
leaseDurationSeconds: 10,
|
leaseDurationSeconds: 10,
|
||||||
clock: fakeClock,
|
clock: fakeClock,
|
||||||
},
|
},
|
||||||
base: &coordv1beta1.Lease{
|
base: &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
@ -160,13 +160,13 @@ func TestNewLease(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(node.Name),
|
HolderIdentity: pointer.StringPtr(node.Name),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
||||||
RenewTime: &metav1.MicroTime{Time: fakeClock.Now().Add(-10 * time.Second)},
|
RenewTime: &metav1.MicroTime{Time: fakeClock.Now().Add(-10 * time.Second)},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: &coordv1beta1.Lease{
|
expect: &coordinationv1.Lease{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
Namespace: corev1.NamespaceNodeLease,
|
Namespace: corev1.NamespaceNodeLease,
|
||||||
@ -179,7 +179,7 @@ func TestNewLease(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: coordv1beta1.LeaseSpec{
|
Spec: coordinationv1.LeaseSpec{
|
||||||
HolderIdentity: pointer.StringPtr(node.Name),
|
HolderIdentity: pointer.StringPtr(node.Name),
|
||||||
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
LeaseDurationSeconds: pointer.Int32Ptr(10),
|
||||||
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
RenewTime: &metav1.MicroTime{Time: fakeClock.Now()},
|
||||||
@ -221,7 +221,7 @@ func TestRetryUpdateLease(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "no errors",
|
desc: "no errors",
|
||||||
updateReactor: func(action clienttesting.Action) (bool, runtime.Object, error) {
|
updateReactor: func(action clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
return true, &coordv1beta1.Lease{}, nil
|
return true, &coordinationv1.Lease{}, nil
|
||||||
},
|
},
|
||||||
getReactor: nil,
|
getReactor: nil,
|
||||||
onRepeatedHeartbeatFailure: nil,
|
onRepeatedHeartbeatFailure: nil,
|
||||||
@ -248,12 +248,12 @@ func TestRetryUpdateLease(t *testing.T) {
|
|||||||
case 2:
|
case 2:
|
||||||
return true, nil, optimistcLockUpdateErr
|
return true, nil, optimistcLockUpdateErr
|
||||||
default:
|
default:
|
||||||
return true, &coordv1beta1.Lease{}, nil
|
return true, &coordinationv1.Lease{}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(),
|
}(),
|
||||||
getReactor: func(action clienttesting.Action) (bool, runtime.Object, error) {
|
getReactor: func(action clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
return true, &coordv1beta1.Lease{}, nil
|
return true, &coordinationv1.Lease{}, nil
|
||||||
},
|
},
|
||||||
onRepeatedHeartbeatFailure: func() { t.Fatalf("onRepeatedHeartbeatFailure called") },
|
onRepeatedHeartbeatFailure: func() { t.Fatalf("onRepeatedHeartbeatFailure called") },
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
@ -271,7 +271,7 @@ func TestRetryUpdateLease(t *testing.T) {
|
|||||||
c := &controller{
|
c := &controller{
|
||||||
clock: clock.NewFakeClock(time.Now()),
|
clock: clock.NewFakeClock(time.Now()),
|
||||||
client: cl,
|
client: cl,
|
||||||
leaseClient: cl.CoordinationV1beta1().Leases(corev1.NamespaceNodeLease),
|
leaseClient: cl.CoordinationV1().Leases(corev1.NamespaceNodeLease),
|
||||||
holderIdentity: node.Name,
|
holderIdentity: node.Name,
|
||||||
leaseDurationSeconds: 10,
|
leaseDurationSeconds: 10,
|
||||||
onRepeatedHeartbeatFailure: tc.onRepeatedHeartbeatFailure,
|
onRepeatedHeartbeatFailure: tc.onRepeatedHeartbeatFailure,
|
||||||
|
@ -54,7 +54,7 @@ go_library(
|
|||||||
"//pkg/kubelet/sysctl:go_default_library",
|
"//pkg/kubelet/sysctl:go_default_library",
|
||||||
"//pkg/security/apparmor:go_default_library",
|
"//pkg/security/apparmor:go_default_library",
|
||||||
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
|
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
coordinationv1 "k8s.io/api/coordination/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -48,10 +48,10 @@ var _ = framework.KubeDescribe("NodeLease", func() {
|
|||||||
|
|
||||||
ginkgo.Context("when the NodeLease feature is enabled", func() {
|
ginkgo.Context("when the NodeLease feature is enabled", func() {
|
||||||
ginkgo.It("the kubelet should create and update a lease in the kube-node-lease namespace", func() {
|
ginkgo.It("the kubelet should create and update a lease in the kube-node-lease namespace", func() {
|
||||||
leaseClient := f.ClientSet.CoordinationV1beta1().Leases(v1.NamespaceNodeLease)
|
leaseClient := f.ClientSet.CoordinationV1().Leases(v1.NamespaceNodeLease)
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
lease *coordinationv1beta1.Lease
|
lease *coordinationv1.Lease
|
||||||
)
|
)
|
||||||
ginkgo.By("check that lease for this Kubelet exists in the kube-node-lease namespace")
|
ginkgo.By("check that lease for this Kubelet exists in the kube-node-lease namespace")
|
||||||
gomega.Eventually(func() error {
|
gomega.Eventually(func() error {
|
||||||
@ -91,9 +91,9 @@ var _ = framework.KubeDescribe("NodeLease", func() {
|
|||||||
|
|
||||||
ginkgo.By("wait until there is node lease")
|
ginkgo.By("wait until there is node lease")
|
||||||
var err error
|
var err error
|
||||||
var lease *coordinationv1beta1.Lease
|
var lease *coordinationv1.Lease
|
||||||
gomega.Eventually(func() error {
|
gomega.Eventually(func() error {
|
||||||
lease, err = f.ClientSet.CoordinationV1beta1().Leases(v1.NamespaceNodeLease).Get(nodeName, metav1.GetOptions{})
|
lease, err = f.ClientSet.CoordinationV1().Leases(v1.NamespaceNodeLease).Get(nodeName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ func getHeartbeatTimeAndStatus(clientSet clientset.Interface, nodeName string) (
|
|||||||
return heartbeatTime, node.Status
|
return heartbeatTime, node.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
func expectLease(lease *coordinationv1beta1.Lease, nodeName string) error {
|
func expectLease(lease *coordinationv1.Lease, nodeName string) error {
|
||||||
// expect values for HolderIdentity, LeaseDurationSeconds, and RenewTime
|
// expect values for HolderIdentity, LeaseDurationSeconds, and RenewTime
|
||||||
if lease.Spec.HolderIdentity == nil {
|
if lease.Spec.HolderIdentity == nil {
|
||||||
return fmt.Errorf("Spec.HolderIdentity should not be nil")
|
return fmt.Errorf("Spec.HolderIdentity should not be nil")
|
||||||
|
@ -99,7 +99,7 @@ var _ = SIGDescribe("[Disruptive]NodeLease", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("node lease should be deleted when corresponding node is deleted", func() {
|
ginkgo.It("node lease should be deleted when corresponding node is deleted", func() {
|
||||||
leaseClient := c.CoordinationV1beta1().Leases(v1.NamespaceNodeLease)
|
leaseClient := c.CoordinationV1().Leases(v1.NamespaceNodeLease)
|
||||||
err := e2enode.WaitForReadyNodes(c, framework.TestContext.CloudConfig.NumNodes, 10*time.Minute)
|
err := e2enode.WaitForReadyNodes(c, framework.TestContext.CloudConfig.NumNodes, 10*time.Minute)
|
||||||
gomega.Expect(err).To(gomega.BeNil())
|
gomega.Expect(err).To(gomega.BeNil())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user