mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update k8s.io/mount-utils to current master
kubernetes/kubernetes#111083 has been merged and synced into k8s.io/mount-utils. This should remove any systemd log messages while calling NodeStageVolume and NodeGetVolumeStats. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
3c3cbc8005
commit
533994daff
10
vendor/k8s.io/utils/exec/exec.go
generated
vendored
10
vendor/k8s.io/utils/exec/exec.go
generated
vendored
@ -19,6 +19,7 @@ package exec
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"io/fs"
|
||||
osexec "os/exec"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -98,17 +99,18 @@ func New() Interface {
|
||||
|
||||
// Command is part of the Interface interface.
|
||||
func (executor *executor) Command(cmd string, args ...string) Cmd {
|
||||
return (*cmdWrapper)(osexec.Command(cmd, args...))
|
||||
return (*cmdWrapper)(maskErrDotCmd(osexec.Command(cmd, args...)))
|
||||
}
|
||||
|
||||
// CommandContext is part of the Interface interface.
|
||||
func (executor *executor) CommandContext(ctx context.Context, cmd string, args ...string) Cmd {
|
||||
return (*cmdWrapper)(osexec.CommandContext(ctx, cmd, args...))
|
||||
return (*cmdWrapper)(maskErrDotCmd(osexec.CommandContext(ctx, cmd, args...)))
|
||||
}
|
||||
|
||||
// LookPath is part of the Interface interface
|
||||
func (executor *executor) LookPath(file string) (string, error) {
|
||||
return osexec.LookPath(file)
|
||||
path, err := osexec.LookPath(file)
|
||||
return path, handleError(maskErrDot(err))
|
||||
}
|
||||
|
||||
// Wraps exec.Cmd so we can capture errors.
|
||||
@ -198,6 +200,8 @@ func handleError(err error) error {
|
||||
switch e := err.(type) {
|
||||
case *osexec.ExitError:
|
||||
return &ExitErrorWrapper{e}
|
||||
case *fs.PathError:
|
||||
return ErrExecutableNotFound
|
||||
case *osexec.Error:
|
||||
if e.Err == osexec.ErrNotFound {
|
||||
return ErrExecutableNotFound
|
||||
|
32
vendor/k8s.io/utils/exec/fixup_go118.go
generated
vendored
Normal file
32
vendor/k8s.io/utils/exec/fixup_go118.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
//go:build !go1.19
|
||||
// +build !go1.19
|
||||
|
||||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package exec
|
||||
|
||||
import (
|
||||
osexec "os/exec"
|
||||
)
|
||||
|
||||
func maskErrDotCmd(cmd *osexec.Cmd) *osexec.Cmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func maskErrDot(err error) error {
|
||||
return err
|
||||
}
|
40
vendor/k8s.io/utils/exec/fixup_go119.go
generated
vendored
Normal file
40
vendor/k8s.io/utils/exec/fixup_go119.go
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
//go:build go1.19
|
||||
// +build go1.19
|
||||
|
||||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package exec
|
||||
|
||||
import (
|
||||
"errors"
|
||||
osexec "os/exec"
|
||||
)
|
||||
|
||||
// maskErrDotCmd reverts the behavior of osexec.Cmd to what it was before go1.19
|
||||
// specifically set the Err field to nil (LookPath returns a new error when the file
|
||||
// is resolved to the current directory.
|
||||
func maskErrDotCmd(cmd *osexec.Cmd) *osexec.Cmd {
|
||||
cmd.Err = maskErrDot(cmd.Err)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func maskErrDot(err error) error {
|
||||
if err != nil && errors.Is(err, osexec.ErrDot) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user