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

Reduce total duration of clusterctl tests by switching from wait.Poll to wait.PollImmediate(...) #331

Merged
merged 1 commit into from
Jun 14, 2018

Conversation

spew
Copy link
Contributor

@spew spew commented Jun 11, 2018

What this PR does / why we need it:
This PR improves the runtime of the clusterctl unit tests by polling immediately for changes instead of waiting first. On my Mac the runtime is reduced from ~48 seconds to around 10 seconds. A runtime comparison of the clusterctl folder's for go test ./...

BEFORE:

$ go test ./...
?   	sigs.k8s.io/cluster-api/clusterctl	[no test files]
ok  	sigs.k8s.io/cluster-api/clusterctl/clusterdeployer	47.809s
ok  	sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/minikube	0.038s
ok  	sigs.k8s.io/cluster-api/clusterctl/cmd	0.180s

AFTER

$ go test ./...
?   	sigs.k8s.io/cluster-api/clusterctl	[no test files]
ok  	sigs.k8s.io/cluster-api/clusterctl/clusterdeployer	9.885s
ok  	sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/minikube	0.025s
ok  	sigs.k8s.io/cluster-api/clusterctl/cmd	0.192s

Release note:

Small improvement in the duration of clusterctl create cluster by polling for changes immediately. 

@kubernetes/kube-deploy-reviewers

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: spew

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 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 11, 2018
@spew
Copy link
Contributor Author

spew commented Jun 11, 2018

/assign @jessicaochen @karan

@dims
Copy link
Member

dims commented Jun 12, 2018

/lgtm

@k8s-ci-robot
Copy link
Contributor

@dims: changing LGTM is restricted to assignees, and only kubernetes-sigs/cluster-api repo collaborators may be assigned issues.

In response to this:

/lgtm

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.

@karan
Copy link
Contributor

karan commented Jun 12, 2018

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 12, 2018
@karan
Copy link
Contributor

karan commented Jun 12, 2018

Question - how does it affect the actual runtime?

The docs see to be not accurate here https://github.com/kubernetes/apimachinery/blob/master/pkg/util/wait/wait.go#L230

@jessicaochen
Copy link
Contributor

I had would have thought Poll would check a condition first before going into the wait. Is there any reason not to have wait.PollImmediate be our default Poll?

@spew
Copy link
Contributor Author

spew commented Jun 12, 2018

@karan for the real runtime i think the effect will be negligable because often times the first poll won't be successful anyway (i.e. more time needs to be waited until the condition becomes true).

From the docs for wait.Poll:

// Poll always waits the interval before the run of 'condition'.
// 'condition' will always be invoked at least once.

From the docs for wait.PollImmediate

// Poll always checks 'condition' before waiting for the interval. 'condition'
// will always be invoked at least once.

I am not seeing any inaccuracy. However, there does seem to be a mistake in that the "Immediate" is missing after Poll so maybe that's where the confusion comes from.

@spew
Copy link
Contributor Author

spew commented Jun 12, 2018

@jessicaochen Most likely our default Poll should be PollImmediate, however, I limited the scope of this change to only the code I was testing directly.

@spew
Copy link
Contributor Author

spew commented Jun 12, 2018

Opened a PR for fixing the wait.PollImmediate docs here: kubernetes/kubernetes#65026

@jessicaochen
Copy link
Contributor

Sure, could you create an issue to track making PollImmediate our repo default so we have consistency in the future?

@spew
Copy link
Contributor Author

spew commented Jun 12, 2018

Created an issue for that: #336

Copy link
Contributor

@jessicaochen jessicaochen left a comment

Choose a reason for hiding this comment

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

lgtm (leaving backslash for seconary lgtm-er)

@spew
Copy link
Contributor Author

spew commented Jun 12, 2018

@karan could please take another look.

@karan
Copy link
Contributor

karan commented Jun 14, 2018

/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 14, 2018
@spew
Copy link
Contributor Author

spew commented Jun 14, 2018

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 14, 2018
@k8s-ci-robot k8s-ci-robot merged commit ca0cee6 into kubernetes-sigs:master Jun 14, 2018
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants