Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Properly handle successful Run() with stale errno #999

Merged
merged 2 commits into from
Mar 7, 2017

Conversation

msterin
Copy link
Contributor

@msterin msterin commented Mar 7, 2017

Sometimes vmci_server.c does not set errno when returning Success.
In this cases stale errno (e.g. from priorly failed syscall) might be
accidentally picked up. The commit fixes this issue, and also improves
error printing for inotify failures

@govint- it is a light modification of a fragment of your PR. I do not want to wait for the whole PR to come in but it is blocking me, so sending this piece as a separate PR

TEST: manual test on Alpine only (using it for managed plugin conversion). Before the test ALL commands in my runs (including "docker volume ls") where failing with "file not found" which was a leftover from something else. After the fix the issues disappeared.

//CC @govint @pdhamdhere

Sometimes vmci_server.c does not set errno when returning Success.
In this cases stale errno (e.g. from priorly failed syscall) might be
accidentally picked up. The commit fixes this issue, and also  improves
error printing for inotify failures.

Sometimes vmci_server.c does not set errno when returning Success.
In this cases stale errno (e.g. from priorly failed syscall) might be
accidentally picked up. The commit fixes this issues, and also  improves
error prinitng for inotify failures

Cleaned up eror msg
if errno == syscall.ECONNRESET || errno == syscall.ETIMEDOUT {
msg += " Cannot communicate with ESX, please refer to the FAQ https://github.com/vmware/docker-volume-vsphere/wiki#faq"
ret, err = C.Vmci_GetReply(C.int(EsxPort), cmdS, beS, ans)
if ret != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doubly sure that ret == 0 && err != nil will never happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops. Re-read the PR description. LGTM.

Copy link
Contributor Author

@msterin msterin Mar 7, 2017

Choose a reason for hiding this comment

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

it happens all the time on alpine ::-), it simply means the errno is not properly reset (by someone else) and we may see the stale one. I did see it when working with the managed plugin on Alpine distro. It is explicitly a non-event for us since return 0 means we are totally good. It kind of breaks Go purity (err is what matters there) in favor or C "err code" return in return valye, so probably a comment is due.

Copy link
Contributor

@pdhamdhere pdhamdhere left a comment

Choose a reason for hiding this comment

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

Yes, please add a comment and LGTM.

@msterin
Copy link
Contributor Author

msterin commented Mar 7, 2017

Aha ! the CI picked up the new error message:

creating volume [abc_1488855065] on VM[192.168.31.176]---
FAIL: TestVolumeCreationFirstTime (6.95s)
	createVolume_test.go:58: 
		Error has occurred [Error response from daemon: create abc_1488855065: VolumeDriver.Create: Internal issue: ret != 0 but errno is not set. Cancelling operation.
		] while creating volume [abc_1488855065] very first time: err -> exit status 1

@govint - that seems to confim the conclusion about "we return err, do not set errno, this fooling the code into improperly handle memory in vmci exchange with Go.

I will go ahead and merge, we should expect more CI failures before you adjust and merge #941. What's the ETA on this one ?

@msterin msterin merged commit cb642fc into master Mar 7, 2017
@msterin msterin deleted the stale_errno.msterin branch March 8, 2017 02:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants