New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that Node lease has OwnerReference set #84998
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,30 @@ var _ = framework.KubeDescribe("NodeLease", func() { | |
time.Duration(*lease.Spec.LeaseDurationSeconds/4)*time.Second) | ||
}) | ||
|
||
ginkgo.It("should have OwnerReferences set", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a conformance test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't create conformance test from scratch. |
||
leaseClient := f.ClientSet.CoordinationV1().Leases(v1.NamespaceNodeLease) | ||
var ( | ||
err error | ||
leaseList *coordinationv1.LeaseList | ||
) | ||
gomega.Eventually(func() error { | ||
leaseList, err = leaseClient.List(metav1.ListOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}, 5*time.Minute, 5*time.Second).Should(gomega.BeNil()) | ||
// All the leases should have OwnerReferences set to their corresponding | ||
// Node object. | ||
for i := range leaseList.Items { | ||
lease := &leaseList.Items[i] | ||
ownerRefs := lease.ObjectMeta.OwnerReferences | ||
framework.ExpectEqual(len(ownerRefs), 1) | ||
framework.ExpectEqual(ownerRefs[0].Kind, v1.SchemeGroupVersion.WithKind("Node").Kind) | ||
framework.ExpectEqual(ownerRefs[0].APIVersion, v1.SchemeGroupVersion.WithKind("Node").Version) | ||
} | ||
}) | ||
|
||
ginkgo.It("the kubelet should report node status infrequently", func() { | ||
ginkgo.By("wait until node is ready") | ||
e2enode.WaitForNodeToBeReady(f.ClientSet, nodeName, 5*time.Minute) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to ensure a new lease always have OwnerReferences, should we do it in newLease() and return "missing owner ref" error in such case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that, but that would be much more invasive change (despite the first glance, the flow is non-trivial). I wanted to avoid making significant rewrite on the last moment before code-freeze.
Also note that if we create the Lease correctly, we will be fine (assuming noone will remove it, but that could cause issues anyway, because the node may be deleted in the meantime, so protecting against it is not the goal).
So I actually think the current approach is the best tradeoff between simplicity of code-changes and the goal to achieve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK