Skip to content

Commit

Permalink
chore: monitor leaked node lease using tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jigisha620 committed Aug 21, 2024
1 parent 3a95818 commit 1460366
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/pkg/environment/common/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ func (env *Environment) EventuallyExpectTerminatingWithTimeout(timeout time.Dura
}).WithTimeout(timeout).Should(Succeed())
}

func (env *Environment) EventuallyExpectNoLeakedKubeNodeLease() {
GinkgoHelper()
// expect no kube node lease to be leaked
leases := &coordinationv1.LeaseList{}
Expect(env.Client.List(env.Context, leases, client.InNamespace("kube-node-lease"))).To(Succeed())
leakedLeases := lo.Filter(leases.Items, func(l coordinationv1.Lease, _ int) bool {
return l.OwnerReferences == nil
})
Expect(leakedLeases).To(HaveLen(0))
}

func (env *Environment) EventuallyExpectHealthyWithTimeout(timeout time.Duration, pods ...*corev1.Pod) {
GinkgoHelper()
Eventually(func(g Gomega) {
Expand Down
1 change: 1 addition & 0 deletions test/pkg/environment/common/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (env *Environment) ExpectCleanCluster() {

func (env *Environment) Cleanup() {
env.CleanupObjects(CleanableObjects...)
env.EventuallyExpectNoLeakedKubeNodeLease()
env.eventuallyExpectScaleDown()
env.ExpectNoCrashes()
}
Expand Down

0 comments on commit 1460366

Please sign in to comment.