Merge pull request #55992 from zhangxiaoyu-zidif/fix-binary-check-nfs

Automatic merge from submit-queue (batch tested with PRs 55925, 55999, 55944, 55992, 56196). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix binary check for nfs.go

**What this PR does / why we need it**:
err check can't show that the binary does not exist.
If the binary does not exist, the err still be nil ever. 
we should add print check to show if the binary exist.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes https://github.com/kubernetes/kubernetes/issues/56479

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-12-14 04:32:20 -08:00 committed by GitHub
commit f2ff2da235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,15 +194,15 @@ func (nfsMounter *nfsMounter) CanMount() error {
exec := nfsMounter.plugin.host.GetExec(nfsMounter.plugin.GetPluginName())
switch runtime.GOOS {
case "linux":
if _, err := exec.Run("/bin/ls", "/sbin/mount.nfs"); err != nil {
if _, err := exec.Run("test", "-x", "/sbin/mount.nfs"); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs is missing")
}
if _, err := exec.Run("/bin/ls", "/sbin/mount.nfs4"); err != nil {
if _, err := exec.Run("test", "-x", "/sbin/mount.nfs4"); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs4 is missing")
}
return nil
case "darwin":
if _, err := exec.Run("/bin/ls", "/sbin/mount_nfs"); err != nil {
if _, err := exec.Run("test", "-x", "/sbin/mount_nfs"); err != nil {
return fmt.Errorf("Required binary /sbin/mount_nfs is missing")
}
}