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

Enable govmomi context timeouts #157

Closed
dougm opened this issue Feb 26, 2016 · 11 comments
Closed

Enable govmomi context timeouts #157

dougm opened this issue Feb 26, 2016 · 11 comments
Labels
component/utilities priority/p4 product/govmomi Related to the Go library for interacting with VMware vSphere APIs

Comments

@dougm
Copy link
Member

dougm commented Feb 26, 2016

We are currently using a single Context.Background for all govmomi operations. We should look at using the context to provide a default timeout for vsphere oprations and more fine grained timeouts as needed.

https://godoc.org/golang.org/x/net/context

https://blog.golang.org/context

@dougm dougm added product/govmomi Related to the Go library for interacting with VMware vSphere APIs component/utilities labels Feb 26, 2016
@dougm
Copy link
Member Author

dougm commented Mar 11, 2016

We can start with the vsphere/session package

@cgtexmex cgtexmex self-assigned this Mar 17, 2016
@cgtexmex
Copy link
Contributor

To provide a generic timeout I'm thinking of injecting one in the /vim25/soap.RoundTrip function. I believe this is the common entry point from the caller (govmomi) to the server. I would check to see if the passed context has a time out -- or a timeout that doesn't exceed a certain threshold. If the provided context doesn't then I would create a child context with a specified default timeout and pass that to the /vim25/soap.do function.

Then we would enforce a basic timeout, but easily allow users to specify their own. Thoughts? Am I missing something?

cc:/ @caglar10ur

@dougm
Copy link
Member Author

dougm commented Mar 23, 2016

Don't think we want to inject a default timeout into the vim25/soap code, can't we do that at the vsphere/session package level?

@cgtexmex
Copy link
Contributor

The injection at the soap layer would enforce a timeout for every call to VC or ESX. If the timeout is exceeded then the soap layer would cancel the request on VC / ESX and return an error. This would only inject if a timeout wasn't provided.

At the session package level are you talking about the /session/keep_alive.RoundTrip ? So do something similar there? i.e. inject a default if one isn't provided? Or am I missing something?

@dougm
Copy link
Member Author

dougm commented Mar 23, 2016

@cgtexmex
Copy link
Contributor

Ahhhhh....I was completely focused of implementing the timeouts in govmomi proper, so that all projects utilizing would benefit. I'll look at the vic session stuff and implement there.

Why wouldn't we want sane timeouts in the core govmomi code?

@dougm
Copy link
Member Author

dougm commented Mar 23, 2016

Leave it to the caller to decide. We should have a timeout option in govc with a reasonable default, but that'd be another story.

@cgtexmex
Copy link
Contributor

Is this what you're thinking for injecting a timeout? Look at the create method:

https://github.com/cgtexmex/vic/blob/context/pkg/vsphere/session/session.go

This will create a new child context with a timeout if no deadline exist. If this is what you're thinking then I'll wrap it in a function that will take the parent context as a param.

@dougm
Copy link
Member Author

dougm commented Apr 7, 2016

Looks like the context package will be included with Go 1.7: golang/go#14660

@mdubya66 mdubya66 added this to the VIC GA Release milestone Jul 1, 2016
@mdubya66 mdubya66 removed this from the VIC GA Release milestone Sep 19, 2016
@cgtexmex cgtexmex removed their assignment Jan 18, 2017
@mdubya66
Copy link
Contributor

low for now.

@dougm
Copy link
Member Author

dougm commented Jan 31, 2017

We are using Context timeouts/deadlines now where appropriate.

@dougm dougm closed this as completed Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/utilities priority/p4 product/govmomi Related to the Go library for interacting with VMware vSphere APIs
Projects
None yet
Development

No branches or pull requests

3 participants