Skip to content
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

Merged
merged 1 commit into from
Jun 18, 2019

Conversation

jiatongw
Copy link

What type of PR is this?

/kind cleanup
/priority backlog

What this PR does / why we need it:

  • Move util.go node related functions to framework/node package, alias e2enode
  • Fix references of some methods to use the right package

Reference issue #77197, #76206 (parent issue #75601 )

Special notes for your reviewer:

There are a lot of node related functions in util.go and service_util.go are calling Failf() or ExpectNoError(). I leave those unchanged because moving them to framework/node will cause a import cycle error (i.e. import e2enode in util.go and import framework in framework/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?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. priority/backlog Higher priority than priority/awaiting-more-evidence. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 24, 2019
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 24, 2019
@jiatongw
Copy link
Author

/assign @andrewsykim @timothysc

@k8s-ci-robot k8s-ci-robot added area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 24, 2019
@@ -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

Copy link
Author

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

@figo
Copy link
Contributor

figo commented May 24, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 24, 2019
@@ -30,14 +30,15 @@ import (

"k8s.io/client-go/tools/cache"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Copy link
Member

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)

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@jiatongw jiatongw force-pushed the e2e/framework/utilNode branch 2 times, most recently from 8efc18b to a67b879 Compare May 25, 2019 06:06

// FirstNodeAddresses returns the first address of the given type of each node.
func FirstNodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string {
hosts := []string{}
Copy link
Author

@jiatongw jiatongw May 25, 2019

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).

Copy link
Member

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

Copy link
Member

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.
Copy link
Author

@jiatongw jiatongw May 25, 2019

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).

Copy link
Member

@andrewsykim andrewsykim left a 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{}
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function 🙈

Copy link
Author

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.

Copy link
Member

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


const (
// Poll is how often to Poll pods, nodes and claims.
Poll = 2 * time.Second
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be unexported?

Copy link
Author

@jiatongw jiatongw May 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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?

Copy link
Author

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?

Poll = 2 * time.Second

// PollShortTimeout is the short timeout value in polling.
PollShortTimeout = 1 * time.Minute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be unexported?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be unexported?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 29, 2019
@timothysc timothysc added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Jun 4, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 6, 2019
@jiatongw
Copy link
Author

jiatongw commented Jun 6, 2019

Changed as requested @timothysc

Renamed exported functions whose name have redundant strings. I leave unexported functions unchanged because those will not be used as e2enode.xxx, and it's readable since some of them don't have comments.

I have a second commit for reviewers convenience. Once approved, I'll squash to one.

@jiatongw jiatongw force-pushed the e2e/framework/utilNode branch 2 times, most recently from 26b0eb3 to 53805a0 Compare June 6, 2019 06:29
@jiatongw
Copy link
Author

jiatongw commented Jun 6, 2019

/test pull-kubernetes-e2e-gce

Copy link
Member

@timothysc timothysc left a 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)
Copy link
Member

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{}
Copy link
Member

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 {
Copy link
Member

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

// 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) {
Copy link
Member

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.

Copy link
Author

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

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 10, 2019
// 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 {
Copy link
Contributor

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 whileWaitForReadyNodes` makes it sound more explicit that the condition is a certain number of nodes

Copy link
Author

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?

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 make more sense

}

// WaitForNameToBeReady returns whether node name is ready within timeout.
func WaitForNameToBeReady(c clientset.Interface, name string, timeout time.Duration) bool {
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor

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).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix, thanks

)

const (
// Poll is how often to Poll pods, nodes and claims.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Poll/poll

Copy link
Author

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

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/SingleCallTimeout/singleCallTimeout

@timothysc
Copy link
Member

Just poke me on the #testing-commons slack channel when you feel it's all ready to go.

Copy link
Member

@timothysc timothysc left a 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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2019
@alejandrox1
Copy link
Contributor

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 14, 2019
- 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>
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 18, 2019
@jiatongw
Copy link
Author

@timstclair Hi Tim, could you re-review and lgtm? Merging conflicts so I rebased.

Copy link
Contributor

@alejandrox1 alejandrox1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 18, 2019
@k8s-ci-robot k8s-ci-robot merged commit eaf89cf into kubernetes:master Jun 18, 2019
@jiatongw jiatongw deleted the e2e/framework/utilNode branch June 18, 2019 09:04
@jiatongw jiatongw mentioned this pull request Aug 5, 2019
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants