Documentation ¶
Overview ¶
Package exec embeds Rook's exec logic
Copyright 2016 The Rook Authors. All rights reserved.
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.
Index ¶
- Constants
- Variables
- func ExitStatus(err error) (int, bool)
- func ExtractExitCode(err error) (int, error)
- func IsTimeout(err error) bool
- type CephCLIError
- type CommandExecutor
- func (c *CommandExecutor) ExecuteCommand(command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
- func (*CommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
- func (c *CommandExecutor) ExecuteCommandWithStdin(timeout time.Duration, command string, stdin *string, arg ...string) error
- func (*CommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
- type ExecOptions
- type Executor
- type RemotePodCommandExecutor
- func (e *RemotePodCommandExecutor) ExecCommandInContainerWithFullOutput(ctx context.Context, appLabel, containerName, namespace string, cmd ...string) (string, string, error)
- func (e *RemotePodCommandExecutor) ExecCommandInContainerWithFullOutputWithTimeout(ctx context.Context, appLabel, containerName, namespace string, cmd ...string) (string, string, error)
- func (e *RemotePodCommandExecutor) ExecWithOptions(ctx context.Context, options ExecOptions) (string, string, error)
- type TranslateCommandExecutor
- func (e *TranslateCommandExecutor) ExecuteCommand(command string, arg ...string) error
- func (e *TranslateCommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
- func (e *TranslateCommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
- func (e *TranslateCommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
- func (e *TranslateCommandExecutor) ExecuteCommandWithStdin(timeout time.Duration, command string, stdin *string, arg ...string) error
- func (e *TranslateCommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
Constants ¶
const TimeoutWaitingForMessage = "exec timeout waiting for"
TimeoutWaitingForMessage can be used to identify if an error is due to a timeout.
Variables ¶
var (
CephCommandsTimeout = 15 * time.Second
)
Functions ¶
func ExtractExitCode ¶
ExtractExitCode attempts to get the exit code from the error returned by an Executor function. This should also work for any errors returned by the golang os/exec package and "k8s.io/utils/exec"
Types ¶
type CephCLIError ¶
type CephCLIError struct {
// contains filtered or unexported fields
}
CephCLIError is Ceph CLI Error type
func (*CephCLIError) Error ¶
func (e *CephCLIError) Error() string
type CommandExecutor ¶
type CommandExecutor struct{}
CommandExecutor is the type of the Executor
func (*CommandExecutor) ExecuteCommand ¶
func (c *CommandExecutor) ExecuteCommand(command string, arg ...string) error
ExecuteCommand starts a process and wait for its completion
func (*CommandExecutor) ExecuteCommandWithCombinedOutput ¶
func (*CommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
ExecuteCommandWithCombinedOutput executes a command with combined output
func (*CommandExecutor) ExecuteCommandWithEnv ¶
func (*CommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
ExecuteCommandWithEnv starts a process with env variables and wait for its completion
func (*CommandExecutor) ExecuteCommandWithOutput ¶
func (*CommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
ExecuteCommandWithOutput executes a command with output
func (*CommandExecutor) ExecuteCommandWithStdin ¶
func (c *CommandExecutor) ExecuteCommandWithStdin(timeout time.Duration, command string, stdin *string, arg ...string) error
ExecuteCommandWithStdin starts a process, provides stdin and wait for its completion with timeout.
func (*CommandExecutor) ExecuteCommandWithTimeout ¶
func (*CommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
ExecuteCommandWithTimeout starts a process and wait for its completion with timeout.
type ExecOptions ¶
type ExecOptions struct { Command []string Namespace string PodName string ContainerName string Stdin io.Reader CaptureStdout bool CaptureStderr bool // If false, whitespace in std{err,out} will be removed. PreserveWhitespace bool }
ExecOptions passed to ExecWithOptions
type Executor ¶
type Executor interface { ExecuteCommand(command string, arg ...string) error ExecuteCommandWithEnv(env []string, command string, arg ...string) error ExecuteCommandWithOutput(command string, arg ...string) (string, error) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error) ExecuteCommandWithStdin(timeout time.Duration, command string, stdin *string, arg ...string) error }
Executor is the main interface for all the exec commands
type RemotePodCommandExecutor ¶
type RemotePodCommandExecutor struct { ClientSet kubernetes.Interface RestClient *rest.Config }
RemotePodCommandExecutor is an exec.Executor that execs every command in a remote container This is especially useful when the CephCluster networking type is Multus and when the Operator pod does not have the right network annotations.
func (*RemotePodCommandExecutor) ExecCommandInContainerWithFullOutput ¶
func (e *RemotePodCommandExecutor) ExecCommandInContainerWithFullOutput(ctx context.Context, appLabel, containerName, namespace string, cmd ...string) (string, string, error)
ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error
func (*RemotePodCommandExecutor) ExecCommandInContainerWithFullOutputWithTimeout ¶
func (*RemotePodCommandExecutor) ExecWithOptions ¶
func (e *RemotePodCommandExecutor) ExecWithOptions(ctx context.Context, options ExecOptions) (string, string, error)
ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.
type TranslateCommandExecutor ¶
type TranslateCommandExecutor struct { // Executor is probably a exec.CommandExecutor that will run the translated commands Executor Executor // Translator translates every command before running it Translator func(command string, arg ...string) (string, []string) }
TranslateCommandExecutor is an exec.Executor that translates every command before executing it This is useful to run the commands in a job with `kubectl run ...` when running the operator outside of Kubernetes and need to run tools that require running inside the cluster.
func (*TranslateCommandExecutor) ExecuteCommand ¶
func (e *TranslateCommandExecutor) ExecuteCommand(command string, arg ...string) error
ExecuteCommand starts a process and wait for its completion
func (*TranslateCommandExecutor) ExecuteCommandWithCombinedOutput ¶
func (e *TranslateCommandExecutor) ExecuteCommandWithCombinedOutput(command string, arg ...string) (string, error)
ExecuteCommandWithCombinedOutput starts a process and returns its stdout and stderr combined.
func (*TranslateCommandExecutor) ExecuteCommandWithEnv ¶
func (e *TranslateCommandExecutor) ExecuteCommandWithEnv(env []string, command string, arg ...string) error
ExecuteCommandWithEnv starts a process with an env variable and wait for its completion
func (*TranslateCommandExecutor) ExecuteCommandWithOutput ¶
func (e *TranslateCommandExecutor) ExecuteCommandWithOutput(command string, arg ...string) (string, error)
ExecuteCommandWithOutput starts a process and wait for its completion
func (*TranslateCommandExecutor) ExecuteCommandWithStdin ¶
func (e *TranslateCommandExecutor) ExecuteCommandWithStdin(timeout time.Duration, command string, stdin *string, arg ...string) error
ExecuteCommandWithStdin starts a process, provides stdin and wait for its completion with timeout.
func (*TranslateCommandExecutor) ExecuteCommandWithTimeout ¶
func (e *TranslateCommandExecutor) ExecuteCommandWithTimeout(timeout time.Duration, command string, arg ...string) (string, error)
ExecuteCommandWithTimeout starts a process and wait for its completion with timeout.