-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Move node related methods to framework/node package #78282
Move node related methods to framework/node package #78282
Conversation
Hi @jiatongw. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @andrewsykim @timothysc |
@@ -135,8 +135,6 @@ const ( | |||
|
|||
// PollShortTimeout is the short timeout value in polling. | |||
PollShortTimeout = 1 * time.Minute | |||
// PollLongTimeout is the long timeout value in polling. | |||
PollLongTimeout = 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.
This const is not in use so removed
/ok-to-test |
test/e2e/apps/network_partition.go
Outdated
@@ -30,14 +30,15 @@ import ( | |||
|
|||
"k8s.io/client-go/tools/cache" | |||
|
|||
"k8s.io/api/core/v1" | |||
v1 "k8s.io/api/core/v1" |
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.
this change isn't needed (same below)
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.
This was added automatically be goreturns
when saving files.. will remove it.
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.
Fixed
8efc18b
to
a67b879
Compare
|
||
// FirstNodeAddresses returns the first address of the given type of each node. | ||
func FirstNodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string { | ||
hosts := []string{} |
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.
The original method name was NodeAddresses
. Rename this method to FirstNodeAddresses
is because e2enode.NodeAddresses
will cause a golint error (stutters).
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.
Does this function need to return []string
, wondering why not just string
? I see it was always like this but might be worth doing a refactor now, or at least leave a TODO for later
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.
Agreed this signature is weird, and the name is weird.
Should be FirstAddress and return string, or add a //TODO here.
|
||
// ProxyRequest performs a get on a node proxy endpoint given the nodename and rest client. | ||
func ProxyRequest(c clientset.Interface, node, endpoint string, port int) (restclient.Result, error) { | ||
// proxy tends to hang in some cases when Node is not ready. Add an artificial timeout for this call. |
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.
The original method name was NodeProxyRequest
. Rename this method to ProxyRequest
is because e2enode.NodeProxyRequest
will cause a golint error (stutters).
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.
Minor comments, overall PR looks good. I think test/e2e/framework/node
can use some more cleaning up, but we can do this in a follow-up PR once things are moved into it's own package.
|
||
// FirstNodeAddresses returns the first address of the given type of each node. | ||
func FirstNodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string { | ||
hosts := []string{} |
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.
Does this function need to return []string
, wondering why not just string
? I see it was always like this but might be worth doing a refactor now, or at least leave a TODO for later
return hosts | ||
} | ||
|
||
func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue, silent bool) bool { |
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.
this function 🙈
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 will add a TODO
for FirstNodeAddresses
, and will make the change along with others in the following PR.
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.
Please add a TODO to cleanup this function
test/e2e/framework/node/resource.go
Outdated
|
||
const ( | ||
// Poll is how often to Poll pods, nodes and claims. | ||
Poll = 2 * time.Second |
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.
can this be unexported?
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.
https://cs.k8s.io/?q=framework.Poll&i=nope&files=&repos=kubernetes/kubernetes
This is used in other packages.
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.
That's a different constant that the one here though?
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.
That's the same. The Poll
here is which I copied from util.go
, to avoid import cycles.
But we can make this unexported, since other packages import from framework.Poll
, we can make this Poll
just use within node package?
test/e2e/framework/node/resource.go
Outdated
Poll = 2 * time.Second | ||
|
||
// PollShortTimeout is the short timeout value in polling. | ||
PollShortTimeout = 1 * 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.
can this be unexported?
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.
https://cs.k8s.io/?q=PollShortTimeout&i=nope&files=&repos=kubernetes/kubernetes
This is also referred by other packages
test/e2e/framework/node/resource.go
Outdated
// SingleCallTimeout is how long to try single API calls (like 'get' or 'list'). Used to prevent | ||
// transient failures from failing tests. | ||
// TODO: client should not apply this timeout to Watch calls. Increased from 30s until that is fixed. | ||
SingleCallTimeout = 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.
can this be unexported?
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.
a67b879
to
fbe9115
Compare
3a50b08
to
be14076
Compare
Changed as requested @timothysc Renamed exported functions whose name have redundant strings. I leave unexported functions unchanged because those will not be used as I have a second commit for reviewers convenience. Once approved, I'll squash to one. |
26b0eb3
to
53805a0
Compare
/test pull-kubernetes-e2e-gce |
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.
minor comments, then lgtm
/approve
@@ -579,7 +580,7 @@ func (config *NetworkingTestConfig) setup(selector map[string]string) { | |||
ginkgo.By("Getting node addresses") | |||
ExpectNoError(WaitForAllNodesSchedulable(config.f.ClientSet, 10*time.Minute)) | |||
nodeList := GetReadySchedulableNodesOrDie(config.f.ClientSet) | |||
config.ExternalAddrs = NodeAddresses(nodeList, v1.NodeExternalIP) | |||
config.ExternalAddrs = e2enode.FirstAddresses(nodeList, v1.NodeExternalIP) |
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.
FirstAddresses?
|
||
// FirstNodeAddresses returns the first address of the given type of each node. | ||
func FirstNodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string { | ||
hosts := []string{} |
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.
Agreed this signature is weird, and the name is weird.
Should be FirstAddress and return string, or add a //TODO here.
return hosts | ||
} | ||
|
||
func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionType, wantTrue, silent bool) bool { |
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.
Please add a TODO to cleanup this function
test/e2e/framework/node/wait.go
Outdated
// there is no not-ready nodes in it. By cluster size we mean number of Nodes | ||
// excluding Master Node. | ||
func CheckReady(c clientset.Interface, size int, timeout time.Duration) ([]v1.Node, error) { | ||
for start := time.Now(); time.Since(start) < timeout; time.Sleep(20 * time.Second) { |
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.
please factor the magic numbers to be consts in this file, or add it as a //TODO.
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.
factored 20 * time.Second
to a const sleepTime
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jiatongw, timothysc The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
test/e2e/framework/node/wait.go
Outdated
// WaitForReady waits up to timeout for cluster to has desired size and | ||
// there is no not-ready nodes in it. By cluster size we mean number of Nodes | ||
// excluding Master Node. | ||
func WaitForReady(c clientset.Interface, size int, timeout time.Duration) error { |
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.
Why change the signature of this method from e2enode.WaitForReadyNodes
to e2enode.WaitForReady
?
1WaitForReadycould wait for any general condition while
WaitForReadyNodes` makes it sound more explicit that the condition is a certain number of nodes
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.
As per Tim's suggestion, we have a e2enode
package, so the signature should remove the redundant node(s)
in naming. e2enode.WaitForReady
has a e2enode
prefix, so people know that this is a node related function
what do you think?
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.
Makes sense removing the redundant naming but for this one, if i was looking at godos (as an example), e2enode.WaitForReadyNodes
sounds like it waits for some number of nodes, while e2enode.WaitForReady
sounds like i could pass some "condition" object and check if a certain node meets that condition.
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.
👍 make more sense
test/e2e/framework/node/wait.go
Outdated
} | ||
|
||
// WaitForNameToBeReady returns whether node name is ready within timeout. | ||
func WaitForNameToBeReady(c clientset.Interface, name string, timeout time.Duration) bool { |
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.
Here you change the signature from WaitForNodeToBeReady
to WaitForNameToBeReady
, yes?
wouldn't it read better e2enode.WaitForNodeToBeReady
?
I think the name makes more sense given what it does.
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.
same as above
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.
For this one, e2enode.WaitForNameToBeReady
sounds a bit weird to me, whereas e2enode.WaitForNodeToBeReady
tells me exactly what it does. I think keeping the extra "node" in the method signature adds value (is not purely redundant).
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.
will fix, thanks
test/e2e/framework/node/resource.go
Outdated
) | ||
|
||
const ( | ||
// Poll is how often to Poll pods, nodes and claims. |
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.
s/Poll/poll
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.
thanks for catching this. will fix
test/e2e/framework/node/resource.go
Outdated
// Poll is how often to Poll pods, nodes and claims. | ||
poll = 2 * time.Second | ||
|
||
// SingleCallTimeout is how long to try single API calls (like 'get' or 'list'). Used to prevent |
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.
s/SingleCallTimeout/singleCallTimeout
Just poke me on the #testing-commons slack channel when you feel it's all ready to go. |
53805a0
to
62cc152
Compare
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.
Going to call good enough. I could totally needle stuff, but it's not your code, it's what was inherited.
/lgtm
/retest |
- Add a package "node" under e2e/framework and alias e2enode; - Rename some functions whose name have redundant string. Signed-off-by: Jiatong Wang <wangjiatong@vmware.com>
62cc152
to
b1c346c
Compare
@timstclair Hi Tim, could you re-review and lgtm? Merging conflicts so I rebased. |
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.
/lgtm
What type of PR is this?
/kind cleanup
/priority backlog
What this PR does / why we need it:
util.go
node related functions toframework/node
package, aliase2enode
Reference issue #77197, #76206 (parent issue #75601 )
Special notes for your reviewer:
There are a lot of node related functions in
util.go
andservice_util.go
are callingFailf()
orExpectNoError()
. I leave those unchanged because moving them toframework/node
will cause aimport cycle
error (i.e.import e2enode
inutil.go
andimport framework
inframework/node
package ). I plan to do follow up PRs to completely clean up the rest of node related functions.Does this PR introduce a user-facing change?: