Skip to content

Commit

Permalink
Removed Monkey due to licencing (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellistarn authored Aug 12, 2021
1 parent da80591 commit d84365e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 64 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/awslabs/karpenter
go 1.16

require (
bou.ke/monkey v1.0.2
github.com/Pallinder/go-randomdata v1.2.0
github.com/avast/retry-go v2.7.0+incompatible
github.com/aws/aws-sdk-go v1.38.69
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI=
bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down
121 changes: 60 additions & 61 deletions pkg/controllers/node/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"testing"
"time"

"bou.ke/monkey"
"github.com/Pallinder/go-randomdata"
"github.com/awslabs/karpenter/pkg/apis/provisioning/v1alpha3"
"github.com/awslabs/karpenter/pkg/controllers/node"
Expand Down Expand Up @@ -92,31 +91,31 @@ var _ = Describe("Controller", func() {
n = ExpectNodeExists(env.Client, n.Name)
Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())
})
It("should terminate nodes after expiry", func() {
provisioner.Spec.TTLSecondsUntilExpired = ptr.Int64(30)
n := test.Node(test.NodeOptions{
Finalizers: []string{v1alpha3.TerminationFinalizer},
Labels: map[string]string{
v1alpha3.ProvisionerNameLabelKey: provisioner.Name,
},
})
ExpectCreated(env.Client, provisioner, n)

// Should still exist
ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(n))
n = ExpectNodeExists(env.Client, n.Name)
Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())

// Simulate time passing
afterExpiry := time.Now().Add(time.Duration(*provisioner.Spec.TTLSecondsUntilExpired) * time.Second)
monkey.Patch(time.Now, func() time.Time {
return afterExpiry
})
defer func() { monkey.Unpatch(time.Now) }()
ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(n))
n = ExpectNodeExists(env.Client, n.Name)
Expect(n.DeletionTimestamp.IsZero()).To(BeFalse())
})
// It("should terminate nodes after expiry", func() {
// provisioner.Spec.TTLSecondsUntilExpired = ptr.Int64(30)
// n := test.Node(test.NodeOptions{
// Finalizers: []string{v1alpha3.TerminationFinalizer},
// Labels: map[string]string{
// v1alpha3.ProvisionerNameLabelKey: provisioner.Name,
// },
// })
// ExpectCreated(env.Client, provisioner, n)

// // Should still exist
// ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(n))
// n = ExpectNodeExists(env.Client, n.Name)
// Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())

// // Simulate time passing
// afterExpiry := time.Now().Add(time.Duration(*provisioner.Spec.TTLSecondsUntilExpired) * time.Second)
// monkey.Patch(time.Now, func() time.Time {
// return afterExpiry
// })
// defer func() { monkey.Unpatch(time.Now) }()
// ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(n))
// n = ExpectNodeExists(env.Client, n.Name)
// Expect(n.DeletionTimestamp.IsZero()).To(BeFalse())
// })
})

Context("Readiness", func() {
Expand Down Expand Up @@ -182,41 +181,41 @@ var _ = Describe("Controller", func() {
})
})
Context("Liveness", func() {
It("should terminate nodes that fail to join after 5 minutes", func() {
n := test.Node(test.NodeOptions{
Finalizers: []string{v1alpha3.TerminationFinalizer},
Labels: map[string]string{v1alpha3.ProvisionerNameLabelKey: provisioner.Name},
ReadyStatus: v1.ConditionUnknown,
})
pod := test.Pod(test.PodOptions{NodeName: n.Name})
ExpectCreated(env.Client, provisioner, pod)
ExpectCreatedWithStatus(env.Client, n)

ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(provisioner))

// Expect n not deleted
n = ExpectNodeExists(env.Client, n.Name)
Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())

// Set pod DeletionTimestamp and do another reconcile
Expect(env.Client.Delete(ctx, pod)).To(Succeed())
ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(provisioner))

// Expect node not deleted
n = ExpectNodeExists(env.Client, n.Name)
Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())

// Simulate time passing and a n failing to join
future := time.Now().Add(node.LivenessTimeout)
monkey.Patch(time.Now, func() time.Time {
return future
})
defer func() { monkey.Unpatch(time.Now) }()
ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(n))

n = ExpectNodeExists(env.Client, n.Name)
Expect(n.DeletionTimestamp.IsZero()).To(BeFalse())
})
// It("should terminate nodes that fail to join after 5 minutes", func() {
// n := test.Node(test.NodeOptions{
// Finalizers: []string{v1alpha3.TerminationFinalizer},
// Labels: map[string]string{v1alpha3.ProvisionerNameLabelKey: provisioner.Name},
// ReadyStatus: v1.ConditionUnknown,
// })
// pod := test.Pod(test.PodOptions{NodeName: n.Name})
// ExpectCreated(env.Client, provisioner, pod)
// ExpectCreatedWithStatus(env.Client, n)

// ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(provisioner))

// // Expect n not deleted
// n = ExpectNodeExists(env.Client, n.Name)
// Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())

// // Set pod DeletionTimestamp and do another reconcile
// Expect(env.Client.Delete(ctx, pod)).To(Succeed())
// ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(provisioner))

// // Expect node not deleted
// n = ExpectNodeExists(env.Client, n.Name)
// Expect(n.DeletionTimestamp.IsZero()).To(BeTrue())

// // Simulate time passing and a n failing to join
// future := time.Now().Add(node.LivenessTimeout)
// monkey.Patch(time.Now, func() time.Time {
// return future
// })
// defer func() { monkey.Unpatch(time.Now) }()
// ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(n))

// n = ExpectNodeExists(env.Client, n.Name)
// Expect(n.DeletionTimestamp.IsZero()).To(BeFalse())
// })
})
Describe("Emptiness", func() {
It("should not TTL nodes that have ready status unknown", func() {
Expand Down

0 comments on commit d84365e

Please sign in to comment.