-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Fix PV allocation on non-English vSphere #73115
Conversation
/assign @BaluDontu |
0455d8e
to
f73a163
Compare
There was a problem hiding this 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") |
There was a problem hiding this comment.
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())
f73a163
to
875b4e9
Compare
@neolit123 Updated and added a release note, PTAL |
/test pull-kubernetes-e2e-kops-aws |
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 |
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") |
There was a problem hiding this comment.
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 ""
}
There was a problem hiding this comment.
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:
kubernetes/pkg/cloudprovider/providers/vsphere/vclib/datacenter_test.go
Lines 138 to 141 in b66e332
_, err = dc.GetVirtualDiskPage83Data(ctx, diskPath+testNameNotFound) | |
if err == nil { | |
t.Error("expected error") | |
} |
e7d8c57
to
2bad9fc
Compare
2bad9fc
to
345049b
Compare
@dougm Updated, also did a quick smoke test again trying to allocate a PV when running this with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice @alvaroaleman
/lgtm
@dougm Can you also |
/approve |
[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 |
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?: