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

Fix PV allocation on non-English vSphere #73115

Merged

Conversation

alvaroaleman
Copy link
Member

@alvaroaleman alvaroaleman commented Jan 20, 2019

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fixes PV allocation on a non-English vSphere installation

Which issue(s) this PR fixes:

Fixes #71997

Special notes for your reviewer:

I have manually verified that PV allocation still works on an English vSphere. I can not test it on a non-English vsphere as I don't have that at hand, however since the testcase contains the error message @ipointffogl mentioned in #71997 I'd argue its safe to assume that this will fix the issue.

The whole thing still feels like a rubberduck fix because the proper solution would be to not use API error messages to gather infos.

/shrug
/area vsphere

Does this PR introduce a user-facing change?:

Fixed a bug that caused PV allocation on non-English vSphere installations to fail 

@k8s-ci-robot k8s-ci-robot added ¯\_(ツ)_/¯ ¯\\\_(ツ)_/¯ kind/bug Categorizes issue or PR as related to a bug. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 20, 2019
@alvaroaleman
Copy link
Member Author

/assign @BaluDontu

@alvaroaleman alvaroaleman force-pushed the 71997-non-english-vsphere-pvc branch 2 times, most recently from 0455d8e to f73a163 Compare January 20, 2019 16:49
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 20, 2019
Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

/priority backlog

i think this might be worth a release note?

match := re.FindStringSubmatch(err.Error())
match := datastorePathFromErrorExtractorRegex.FindStringSubmatch(err.Error())
if len(match) < 2 {
return "", errors.New("Couldn't extract folder ID from vSphere api error, regex did not find a match")
Copy link
Member

Choose a reason for hiding this comment

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

errors should start lowercase
api -> API

would it make sense to include the string we are matching in the output?

fmt.Errorf("could not extract folder ID from vSphere API error %q", err.Error())

@k8s-ci-robot k8s-ci-robot removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 20, 2019
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jan 21, 2019
@alvaroaleman
Copy link
Member Author

@neolit123 Updated and added a release note, PTAL

@alvaroaleman
Copy link
Member Author

/test pull-kubernetes-e2e-kops-aws

@ipointffogl
Copy link

ipointffogl commented Jan 21, 2019

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fixes PV allocation on a non-English vSphere installation

Which issue(s) this PR fixes:

Fixes #71997

Special notes for your reviewer:

I have manually verified that PV allocation still works on an English vSphere. I can not test it on a non-English vsphere as I don't have that at hand, however since the testcase contains the error message @ipointffogl mentioned in #71997 I'd argue its safe to assume that this will fix the issue.

The whole thing still feels like a rubberduck fix because the proper solution would be to not use API error messages to gather infos.

/shrug
/area vsphere

Does this PR introduce a user-facing change?:

Fixed a bug that caused PV allocation on noin-English vSphere installations to fail 

Can be tested by setting the environment variable "GOVMOMI_LOCALE" for the kube controller to e.g. "de_DE".

@alvaroaleman
Copy link
Member Author

Can be tested by setting the environment variable "GOVMOMI_LOCALE" for the kube controller to e.g. "de_DE".

Thanks for the hint! Just tested it, my patch does indeed fix the issue

@alvaroaleman
Copy link
Member Author

Hey @divyenpatel or @dougm could one of you have a look?

@@ -326,8 +328,10 @@ func getcanonicalVolumePath(ctx context.Context, dc *vclib.Datacenter, volumePat
// It would fail and return an folder ID in the error message.
_, err := dc.GetVirtualDiskPage83Data(ctx, dummyDiskVolPath)
if err != nil {
re := regexp.MustCompile("File (.*?) was not found")
Copy link
Member

Choose a reason for hiding this comment

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

Rather than match the error message at all, we can use the fault type like so:

// fileNotFound returns the value of File if err is a FileNotFound soap fault, an empty string otherwise.
func fileNotFound(err error) string {
	if soap.IsSoapFault(err) {
		fault := soap.ToSoapFault(err)
		if f, ok := fault.VimFault().(types.FileNotFound); ok {
			return f.File
		}
	}
	return ""
}

Copy link
Member

Choose a reason for hiding this comment

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

Note that this can be tested against vcsim, with the error returned here for example:

_, err = dc.GetVirtualDiskPage83Data(ctx, diskPath+testNameNotFound)
if err == nil {
t.Error("expected error")
}

@alvaroaleman alvaroaleman force-pushed the 71997-non-english-vsphere-pvc branch 2 times, most recently from e7d8c57 to 2bad9fc Compare January 26, 2019 18:55
@alvaroaleman
Copy link
Member Author

@dougm Updated, also did a quick smoke test again trying to allocate a PV when running this with GOVMOMI_LOCALE=de_DE, worked fine 👍

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Nice @alvaroaleman
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 27, 2019
@alvaroaleman
Copy link
Member Author

@dougm Can you also /approve or do you want me to find someone else for that?

@dougm
Copy link
Member

dougm commented Jan 29, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, dougm

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 Jan 29, 2019
@k8s-ci-robot k8s-ci-robot merged commit cbf5218 into kubernetes:master Jan 29, 2019
@alvaroaleman alvaroaleman deleted the 71997-non-english-vsphere-pvc branch February 9, 2019 19:56
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. ¯\_(ツ)_/¯ ¯\\\_(ツ)_/¯
Projects
None yet
6 participants