common

package
v2.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 25 Imported by: 1,146

Documentation

Index

Constants

View Source
const (
	// WorkflowControllerConfigMapKey is the key in the configmap to retrieve workflow configuration from.
	// Content encoding is expected to be YAML.
	WorkflowControllerConfigMapKey = "config"

	// DefaultArchivePattern is the default pattern when storing artifacts in an archive repository
	DefaultArchivePattern = "{{workflow.name}}/{{pod.name}}"

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

	// PodMetadataVolumeName is the volume name defined in a workflow pod spec to expose pod metadata via downward API
	PodMetadataVolumeName = "podmetadata"

	// PodMetadataAnnotationsVolumePath is volume path for metadata.annotations in the downward API
	PodMetadataAnnotationsVolumePath = "annotations"
	// PodMetadataMountPath is the directory mount location for DownwardAPI volume containing pod metadata
	PodMetadataMountPath = "/argo/" + PodMetadataVolumeName
	// PodMetadataAnnotationsPath is the file path containing pod metadata annotations. Examined by executor
	PodMetadataAnnotationsPath = PodMetadataMountPath + "/" + PodMetadataAnnotationsVolumePath

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

	// AnnotationKeyNodeName is the pod metadata annotation key containing the workflow node name
	AnnotationKeyNodeName = workflow.WorkflowFullName + "/node-name"

	// AnnotationKeyNodeMessage is the pod metadata annotation key the executor will use to
	// communicate errors encountered by the executor during artifact load/save, etc...
	AnnotationKeyNodeMessage = workflow.WorkflowFullName + "/node-message"
	// AnnotationKeyTemplate is the pod metadata annotation key containing the container template as JSON
	AnnotationKeyTemplate = workflow.WorkflowFullName + "/template"
	// AnnotationKeyOutputs is the pod metadata annotation key containing the container outputs
	AnnotationKeyOutputs = workflow.WorkflowFullName + "/outputs"
	// AnnotationKeyExecutionControl is the pod metadata annotation key containing execution control parameters
	// set by the controller and obeyed by the executor. For example, the controller will use this annotation to
	// signal the executors of daemoned containers that it should terminate.
	AnnotationKeyExecutionControl = workflow.WorkflowFullName + "/execution"

	// LabelKeyControllerInstanceID is the label the controller will carry forward to workflows/pod labels
	// for the purposes of workflow segregation
	LabelKeyControllerInstanceID = workflow.WorkflowFullName + "/controller-instanceid"
	// LabelKeyCompleted is the metadata label applied on worfklows and workflow pods to indicates if resource is completed
	// Workflows and pods with a completed=true label will be ignored by the controller
	LabelKeyCompleted = workflow.WorkflowFullName + "/completed"
	// 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"
	// LabelKeyCronWorkflow is a label applied to Workflows that are started by a CronWorkflow
	LabelKeyCronWorkflow = workflow.WorkflowFullName + "/cron-workflow"

	// 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"
	// 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"

	// 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"
	// 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"
	// LocalVarPodName is a step level variable that references the name of the pod
	LocalVarPodName = "pod.name"

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

Variables

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(c kubernetes.Interface, podName, namespace, key, value string) error

AddPodAnnotation adds an annotation to pod

func AddPodLabel

func AddPodLabel(c kubernetes.Interface, podName, namespace, key, value string) error

AddPodLabel adds an label to pod

func ContainerLogStream

func ContainerLogStream(config *rest.Config, namespace string, pod string, container string) (io.ReadCloser, error)

ContainerLogStream returns an io.ReadCloser for a container's log stream using the websocket interface. This was implemented in the hopes that we could selectively choose stdout from stderr, but due to https://github.com/kubernetes/kubernetes/issues/28167, it is not possible to discern stdout from stderr using the K8s API server, so this function is unused, instead preferring the pod logs interface from client-go. It's left as a reference for when issue #28167 is eventually resolved.

func ConvertCronWorkflowToWorkflow

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

func DeletePod

func DeletePod(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 GetExecutorOutput

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

GetExecutorOutput returns the output of an remotecommand.Executor

func GetServiceAccountTokenName

func GetServiceAccountTokenName(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 Context, taskName string, tasks []wfv1.DAGTask) []string

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

func GetTemplateGetterString

func GetTemplateGetterString(getter wfv1.TemplateGetter) string

GetTemplateGetterString returns string of TemplateGetter.

func GetTemplateHolderString

func GetTemplateHolderString(tmplHolder wfv1.TemplateHolder) string

GetTemplateHolderString returns string of TemplateHolder.

func IsPodTemplate

func IsPodTemplate(tmpl *wfv1.Template) bool

IsPodTemplate returns whether the template corresponds to a pod

func KillPodContainer

func KillPodContainer(restConfig *rest.Config, namespace string, pod string, container string) error

KillPodContainer is a convenience function to issue a kill signal to a container in a pod It gives a 15 second grace period before issuing SIGKILL NOTE: this only works with containers that have sh

func MergeReferredTemplate

func MergeReferredTemplate(tmpl *wfv1.Template, referred *wfv1.Template) (*wfv1.Template, error)

MergeReferredTemplate merges a referred template to the receiver template.

func NewPlaceholderGenerator

func NewPlaceholderGenerator() *placeholderGenerator

NewPlaceholderGenerator returns a placeholderGenerator.

func ProcessArgs

func ProcessArgs(tmpl *wfv1.Template, args wfv1.ArgumentsProvider, globalParams, localParams map[string]string, validateOnly bool) (*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 Replace

func Replace(fstTmpl *fasttemplate.Template, replaceMap map[string]string, allowUnresolved bool) (string, error)

Replace executes basic string substitution of a template with replacement values. allowUnresolved indicates whether or not it is acceptable to have unresolved variables remaining in the substituted template.

func RunCommand

func RunCommand(name string, arg ...string) error

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

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 map[string]string) (*wfv1.Template, error)

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

Types

type Context

type Context interface {
	// GetTaskNode returns the node status of a task.
	GetTaskNode(taskName string) *wfv1.NodeStatus
}

type ExecutionControl

type ExecutionControl struct {
	// Deadline is a max timestamp in which an executor can run the container before terminating it
	// It is used to signal the executor to terminate a daemoned container. In the future it will be
	// used to support workflow or steps/dag level timeouts.
	Deadline *time.Time `json:"deadline,omitempty"`
	// IncludeScriptOutput is containing flag to include script output
	IncludeScriptOutput bool `json:"includeScriptOutput,omitempty"`
}

ExecutionControl contains execution control parameters for executor to decide how to execute the container

type RoundTripCallback

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

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