common

package
v3.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 32 Imported by: 64

Documentation

Index

Constants

View Source
const (
	// Container names used in the workflow pod
	MainContainerName = "main"
	InitContainerName = "init"
	WaitContainerName = "wait"

	// DockerSockVolumeName is the volume name for the /var/run/docker.sock host path volume
	DockerSockVolumeName = "docker-sock"

	// AnnotationKeyNodeID is the ID of the node.
	// Historically, the pod name was the same as the node ID.
	// Therefore, if it does not exist, then the node ID is the pod name.
	AnnotationKeyNodeID = workflow.WorkflowFullName + "/node-id"
	// AnnotationKeyNodeName is the pod metadata annotation key containing the workflow node name
	AnnotationKeyNodeName = workflow.WorkflowFullName + "/node-name"
	// AnnotationKeyNodeName is the node's type
	AnnotationKeyNodeType = workflow.WorkflowFullName + "/node-type"

	// AnnotationKeyRBACRule is a rule to match the claims
	AnnotationKeyRBACRule           = workflow.WorkflowFullName + "/rbac-rule"
	AnnotationKeyRBACRulePrecedence = workflow.WorkflowFullName + "/rbac-rule-precedence"

	// AnnotationKeyOutputs is the pod metadata annotation key containing the container outputs
	AnnotationKeyOutputs = workflow.WorkflowFullName + "/outputs"
	// AnnotationKeyCronWfScheduledTime is the workflow metadata annotation key containing the time when the workflow
	// was scheduled to run by CronWorkflow.
	AnnotationKeyCronWfScheduledTime = workflow.WorkflowFullName + "/scheduled-time"

	// AnnotationKeyWorkflowName is the name of the workflow
	AnnotationKeyWorkflowName = workflow.WorkflowFullName + "/workflow-name"
	// AnnotationKeyWorkflowUID is the uid of the workflow
	AnnotationKeyWorkflowUID = workflow.WorkflowFullName + "/workflow-uid"

	// AnnotationKeyPodNameVersion stores the pod naming convention version
	AnnotationKeyPodNameVersion = workflow.WorkflowFullName + "/pod-name-format"

	// LabelKeyControllerInstanceID is the label the controller will carry forward to workflows/pod labels
	// for the purposes of workflow segregation
	LabelKeyControllerInstanceID = workflow.WorkflowFullName + "/controller-instanceid"
	// Who created this workflow.
	LabelKeyCreator      = workflow.WorkflowFullName + "/creator"
	LabelKeyCreatorEmail = workflow.WorkflowFullName + "/creator-email"
	// LabelKeyCompleted is the metadata label applied on workflows and workflow pods to indicates if resource is completed
	// Workflows and pods with a completed=true label will be ignored by the controller.
	// See also `LabelKeyWorkflowArchivingStatus`.
	LabelKeyCompleted = workflow.WorkflowFullName + "/completed"
	// LabelKeyWorkflowArchivingStatus indicates if a workflow needs archiving or not:
	// * “ - does not need archiving ... yet
	// * `Pending` - pending archiving
	// * `Archived` - has been archived
	// See also `LabelKeyCompleted`.
	LabelKeyWorkflowArchivingStatus = workflow.WorkflowFullName + "/workflow-archiving-status"
	// LabelKeyWorkflow is the pod metadata label to indicate the associated workflow name
	LabelKeyWorkflow = workflow.WorkflowFullName + "/workflow"
	// LabelKeyPhase is a label applied to workflows to indicate the current phase of the workflow (for filtering purposes)
	LabelKeyPhase = workflow.WorkflowFullName + "/phase"
	// LabelKeyPreviousWorkflowName is a label applied to resubmitted workflows
	LabelKeyPreviousWorkflowName = workflow.WorkflowFullName + "/resubmitted-from-workflow"
	// LabelKeyCronWorkflow is a label applied to Workflows that are started by a CronWorkflow
	LabelKeyCronWorkflow = workflow.WorkflowFullName + "/cron-workflow"
	// LabelKeyWorkflowTemplate is a label applied to Workflows that are submitted from Workflowtemplate
	LabelKeyWorkflowTemplate = workflow.WorkflowFullName + "/workflow-template"
	// LabelKeyWorkflowEventBinding is a label applied to Workflows that are submitted from a WorkflowEventBinding
	LabelKeyWorkflowEventBinding = workflow.WorkflowFullName + "/workflow-event-binding"
	// LabelKeyWorkflowTemplate is a label applied to Workflows that are submitted from ClusterWorkflowtemplate
	LabelKeyClusterWorkflowTemplate = workflow.WorkflowFullName + "/cluster-workflow-template"
	// LabelKeyOnExit is a label applied to Pods that are run from onExit nodes, so that they are not shut down when stopping a Workflow
	LabelKeyOnExit = workflow.WorkflowFullName + "/on-exit"

	// LabelKeyConfigMapType is the label key for the type of configmap.
	LabelKeyConfigMapType = "workflows.argoproj.io/configmap-type"
	// LabelValueTypeConfigMapCache is a key for configmaps that are memoization cache.
	LabelValueTypeConfigMapCache = "Cache"
	// LabelValueTypeConfigMapParameter is a key for configmaps that contains parameter values.
	LabelValueTypeConfigMapParameter = "Parameter"

	// ExecutorArtifactBaseDir is the base directory in the init container in which artifacts will be copied to.
	// Each artifact will be named according to its input name (e.g: /argo/inputs/artifacts/CODE)
	ExecutorArtifactBaseDir = "/argo/inputs/artifacts"

	// ExecutorMainFilesystemDir is a path made available to the init/wait containers such that they
	// can access the same volume mounts used in the main container. This is used for the purposes
	// of artifact loading (when there is overlapping paths between artifacts and volume mounts),
	// as well as artifact collection by the wait container.
	ExecutorMainFilesystemDir = "/mainctrfs"

	// ExecutorStagingEmptyDir is the path of the emptydir which is used as a staging area to transfer a file between init/main container for script/resource templates
	ExecutorStagingEmptyDir = "/argo/staging"
	// ExecutorScriptSourcePath is the path which init will write the script source file to for script templates
	ExecutorScriptSourcePath = "/argo/staging/script"
	// ExecutorResourceManifestPath is the path which init will write the a manifest file to for resource templates
	ExecutorResourceManifestPath = "/tmp/manifest.yaml"

	// EnvVarPodName contains the name of the pod (currently unused)
	EnvVarPodName = "ARGO_POD_NAME"
	// EnvVarWorkflowName
	EnvVarWorkflowName = "ARGO_WORKFLOW_NAME"
	// EnvVarContainerName container the container's name for the current pod
	EnvVarContainerName = "ARGO_CONTAINER_NAME"
	// EnvVarDeadline is the deadline for the pod
	EnvVarDeadline = "ARGO_DEADLINE"
	// EnvVarIncludeScriptOutput capture the stdout and stderr
	EnvVarIncludeScriptOutput = "ARGO_INCLUDE_SCRIPT_OUTPUT"
	// EnvVarTemplate is the template
	EnvVarTemplate = "ARGO_TEMPLATE"
	// EnvVarContainerRuntimeExecutor contains the name of the container runtime executor to use, empty is equal to "docker"
	EnvVarContainerRuntimeExecutor = "ARGO_CONTAINER_RUNTIME_EXECUTOR"
	// EnvVarDownwardAPINodeIP is the envvar used to get the `status.hostIP`
	EnvVarDownwardAPINodeIP = "ARGO_KUBELET_HOST"
	// EnvVarKubeletPort is used to configure the kubelet api port
	EnvVarKubeletPort = "ARGO_KUBELET_PORT"
	// EnvVarKubeletInsecure is used to disable the TLS verification
	EnvVarKubeletInsecure = "ARGO_KUBELET_INSECURE"
	// EnvVarArgoTrace is used enable tracing statements in Argo components
	EnvVarArgoTrace = "ARGO_TRACE"

	// ContainerRuntimeExecutorDocker to use docker as container runtime executor
	ContainerRuntimeExecutorDocker = "docker"

	// ContainerRuntimeExecutorKubelet to use the kubelet as container runtime executor
	ContainerRuntimeExecutorKubelet = "kubelet"

	// ContainerRuntimeExecutorK8sAPI to use the Kubernetes API server as container runtime executor
	ContainerRuntimeExecutorK8sAPI = "k8sapi"

	// ContainerRuntimeExecutorPNS indicates to use process namespace sharing as the container runtime executor
	ContainerRuntimeExecutorPNS = "pns"

	// ContainerRuntimeExecutorEmissary indicates to use emissary container runtime executor
	ContainerRuntimeExecutorEmissary = "emissary"

	// GlobalVarWorkflowName is a global workflow variable referencing the workflow's metadata.name field
	GlobalVarWorkflowName = "workflow.name"
	// GlobalVarWorkflowNamespace is a global workflow variable referencing the workflow's metadata.namespace field
	GlobalVarWorkflowNamespace = "workflow.namespace"
	// GlobalVarWorkflowServiceAccountName is a global workflow variable referencing the workflow's spec.serviceAccountName field
	GlobalVarWorkflowServiceAccountName = "workflow.serviceAccountName"
	// GlobalVarWorkflowUID is a global workflow variable referencing the workflow's metadata.uid field
	GlobalVarWorkflowUID = "workflow.uid"
	// GlobalVarWorkflowStatus is a global workflow variable referencing the workflow's status.phase field
	GlobalVarWorkflowStatus = "workflow.status"
	// GlobalVarWorkflowCreationTimestamp is the workflow variable referencing the workflow's metadata.creationTimestamp field
	GlobalVarWorkflowCreationTimestamp = "workflow.creationTimestamp"
	// GlobalVarWorkflowPriority is the workflow variable referencing the workflow's priority field
	GlobalVarWorkflowPriority = "workflow.priority"
	// GlobalVarWorkflowFailures is a global variable of a JSON map referencing the workflow's failed nodes
	GlobalVarWorkflowFailures = "workflow.failures"
	// GlobalVarWorkflowDuration is the current duration of this workflow
	GlobalVarWorkflowDuration = "workflow.duration"
	// GlobalVarWorkflowParameters is a JSON string containing all workflow parameters
	GlobalVarWorkflowParameters = "workflow.parameters"
	// GlobalVarWorkflowCronScheduleTime is the scheduled timestamp of a Workflow started by a CronWorkflow
	GlobalVarWorkflowCronScheduleTime = "workflow.scheduledTime"

	// LocalVarPodName is a step level variable that references the name of the pod
	LocalVarPodName = "pod.name"
	// LocalVarRetries is a step level variable that references the retries number if retryStrategy is specified
	LocalVarRetries = "retries"
	// LocalVarDuration is a step level variable (currently only available in metric emission) that tracks the duration of the step
	LocalVarDuration = "duration"
	// LocalVarStatus is a step level variable (currently only available in metric emission) that tracks the duration of the step
	LocalVarStatus = "status"
	// LocalVarResourcesDuration is a step level variable (currently only available in metric emission) that tracks the resources duration of the step
	LocalVarResourcesDuration = "resourcesDuration"
	// LocalVarExitCode is a step level variable (currently only available in metric emission) that tracks the step's exit code
	LocalVarExitCode = "exitCode"

	// LocalVarRetriesLastExitCode is a variable that references information about the last retry's exit code
	LocalVarRetriesLastExitCode = "lastRetry.exitCode"
	// LocalVarRetriesLastStatus is a variable that references information about the last retry's status
	LocalVarRetriesLastStatus = "lastRetry.status"
	// LocalVarRetriesLastDuration is a variable that references information about the last retry's duration
	LocalVarRetriesLastDuration = "lastRetry.duration"

	KubeConfigDefaultMountPath    = "/kube/config"
	KubeConfigDefaultVolumeName   = "kubeconfig"
	ServiceAccountTokenMountPath  = "/var/run/secrets/kubernetes.io/serviceaccount" //nolint:gosec
	ServiceAccountTokenVolumeName = "exec-sa-token"                                 //nolint:gosec
	SecretVolMountPath            = "/argo/secret"
)

Variables

View Source
var AnnotationKeyKillCmd = func(containerName string) string { return workflow.WorkflowFullName + "/kill-cmd-" + containerName }

AnnotationKeyKillCmd specifies the command to use to kill to container, useful for injected sidecars

View Source
var GlobalVarValidWorkflowVariablePrefix = []string{"item.", "steps.", "inputs.", "outputs.", "pod.", "workflow.", "tasks."}

GlobalVarWorkflowRootTags is a list of root tags in workflow which could be used for variable reference

Functions

func AddPodAnnotation

func AddPodAnnotation(ctx context.Context, c kubernetes.Interface, podName, namespace, key, value string, options ...interface{}) error

AddPodAnnotation adds an annotation to pod

func ConvertCronWorkflowToWorkflow

func ConvertCronWorkflowToWorkflow(cronWf *wfv1.CronWorkflow) *wfv1.Workflow

func ConvertCronWorkflowToWorkflowWithProperties

func ConvertCronWorkflowToWorkflowWithProperties(cronWf *wfv1.CronWorkflow, name string, scheduledTime time.Time) *wfv1.Workflow

func DeletePod

func DeletePod(ctx context.Context, c kubernetes.Interface, podName, namespace string) error

DeletePod deletes a pod. Ignores NotFound error

func ExecPodContainer

func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, container string, stdout bool, stderr bool, command ...string) (remotecommand.Executor, error)

ExecPodContainer runs a command in a container in a pod and returns the remotecommand.Executor

func FindOverlappingVolume

func FindOverlappingVolume(tmpl *wfv1.Template, path string) *apiv1.VolumeMount

FindOverlappingVolume looks an artifact path, checks if it overlaps with any user specified volumeMounts in the template, and returns the deepest volumeMount (if any). A return value of nil indicates the path is not under any volumeMount.

func GenerateOnExitNodeName

func GenerateOnExitNodeName(parentNodeName string) string

func GetConfigMapValue added in v3.2.5

func GetConfigMapValue(configMapInformer cache.SharedIndexInformer, namespace, name, key string) (string, error)

GetConfigMapValue retrieves a configmap value

func GetExecutorOutput

func GetExecutorOutput(exec remotecommand.Executor) (*bytes.Buffer, *bytes.Buffer, error)

GetExecutorOutput returns the output of an remotecommand.Executor

func GetServiceAccountTokenName

func GetServiceAccountTokenName(ctx context.Context, clientset kubernetes.Interface, namespace, name string) (string, error)

GetServiceAccountTokenName returns the name of the first referenced ServiceAccountToken secret of the service account.

func GetTaskAncestry

func GetTaskAncestry(ctx DagContext, taskName string) []string

GetTaskAncestry returns a list of taskNames which are ancestors of this task. The list is ordered by the tasks finished time.

func GetTaskDependencies

func GetTaskDependencies(task *wfv1.DAGTask, ctx DagContext) (map[string]DependencyType, string)

func GetTemplateGetterString

func GetTemplateGetterString(getter wfv1.TemplateHolder) string

GetTemplateGetterString returns string of TemplateHolder.

func GetTemplateHolderString

func GetTemplateHolderString(tmplHolder wfv1.TemplateReferenceHolder) string

GetTemplateHolderString returns string of TemplateReferenceHolder.

func NewPlaceholderGenerator

func NewPlaceholderGenerator() *placeholderGenerator

NewPlaceholderGenerator returns a placeholderGenerator.

func NewWorkflowFromWorkflowTemplate

func NewWorkflowFromWorkflowTemplate(templateName string, workflowMetadata *metav1.ObjectMeta, clusterScope bool) *wfv1.Workflow

func ProcessArgs

func ProcessArgs(tmpl *wfv1.Template, args wfv1.ArgumentsProvider, globalParams, localParams Parameters, validateOnly bool, namespace string, configMapInformer cache.SharedIndexInformer) (*wfv1.Template, error)

ProcessArgs sets in the inputs, the values either passed via arguments, or the hardwired values It substitutes: * parameters in the template from the arguments * global parameters (e.g. {{workflow.parameters.XX}}, {{workflow.name}}, {{workflow.status}}) * local parameters (e.g. {{pod.name}})

func RunCommand

func RunCommand(name string, arg ...string) ([]byte, error)

RunCommand is a convenience function to run/log a command and log the stderr upon failure

func RunShellCommand

func RunShellCommand(arg ...string) ([]byte, error)

RunShellCommand is a convenience function to use RunCommand for shell executions. It's os-specific and runs `cmd` in windows.

func SplitClusterWorkflowTemplateYAMLFile

func SplitClusterWorkflowTemplateYAMLFile(body []byte, strict bool) ([]wfv1.ClusterWorkflowTemplate, error)

SplitClusterWorkflowTemplateYAMLFile is a helper to split a body into multiple cluster workflow template objects

func SplitCronWorkflowYAMLFile

func SplitCronWorkflowYAMLFile(body []byte, strict bool) ([]wfv1.CronWorkflow, error)

SplitCronWorkflowYAMLFile is a helper to split a body into multiple workflow template objects

func SplitWorkflowTemplateYAMLFile

func SplitWorkflowTemplateYAMLFile(body []byte, strict bool) ([]wfv1.WorkflowTemplate, error)

SplitWorkflowTemplateYAMLFile is a helper to split a body into multiple workflow template objects

func SplitWorkflowYAMLFile

func SplitWorkflowYAMLFile(body []byte, strict bool) ([]wfv1.Workflow, error)

SplitWorkflowYAMLFile is a helper to split a body into multiple workflow objects

func SubstituteParams

func SubstituteParams(tmpl *wfv1.Template, globalParams, localParams Parameters) (*wfv1.Template, error)

SubstituteParams returns a new copy of the template with global, pod, and input parameters substituted

func UnstructuredHasCompletedLabel

func UnstructuredHasCompletedLabel(obj interface{}) bool

func ValidateTaskResults

func ValidateTaskResults(dagTask *wfv1.DAGTask) error

Types

type DagContext

type DagContext interface {
	GetTask(taskName string) *wfv1.DAGTask
	GetTaskDependencies(taskName string) []string
	GetTaskFinishedAtTime(taskName string) time.Time
}

type DependencyType

type DependencyType int
const (
	DependencyTypeTask DependencyType = iota
	DependencyTypeItems
)

type Parameters

type Parameters map[string]string

Parameters extends string map with useful methods.

func (Parameters) DeepCopy

func (ps Parameters) DeepCopy() Parameters

DeepCopy returns a new instance which has the same parameters as the receiver.

func (Parameters) Merge

func (ps Parameters) Merge(args ...Parameters) Parameters

Merge merges given parameters.

type ParseResult

type ParseResult struct {
	Object metav1.Object
	Err    error
}

func ParseObjects

func ParseObjects(body []byte, strict bool) []ParseResult

type RoundTripCallback

type RoundTripCallback func(conn *websocket.Conn, resp *http.Response, err error) error

type TaskResult

type TaskResult string
const (
	TaskResultSucceeded    TaskResult = "Succeeded"
	TaskResultFailed       TaskResult = "Failed"
	TaskResultErrored      TaskResult = "Errored"
	TaskResultSkipped      TaskResult = "Skipped"
	TaskResultDaemoned     TaskResult = "Daemoned"
	TaskResultAnySucceeded TaskResult = "AnySucceeded"
	TaskResultAllFailed    TaskResult = "AllFailed"
)

type WebsocketRoundTripper

type WebsocketRoundTripper struct {
	Dialer *websocket.Dialer
	Do     RoundTripCallback
}

func (*WebsocketRoundTripper) RoundTrip

func (d *WebsocketRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL