workflow

package
v0.5.1-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rerun

func Rerun(
	ctx context.Context,
	mc model.ClientSet,
	client Client,
	wfe *model.WorkflowExecution,
) error

Rerun reruns the workflow execution to the argo workflow server.

func ResetWorkflowExecutionStatus

func ResetWorkflowExecutionStatus(
	ctx context.Context,
	mc model.ClientSet,
	workflowExecution *model.WorkflowExecution,
) error

ResetWorkflowExecutionStatus resets the workflow execution status and all its stage and step execution status. Rerun the workflow execution need reset the running information.

func Run

func Run(
	ctx context.Context,
	mc model.ClientSet,
	client Client,
	wfe *model.WorkflowExecution,
) error

Run runs the workflow execution to the argo workflow server.

Types

type ArgoAPIClient

type ArgoAPIClient struct {
	apiclient.Client

	Ctx context.Context
}

ArgoAPIClient is a wrapper of argo workflow client. It interacts with argo workflow server.

func NewArgoAPIClient

func NewArgoAPIClient(restCfg *rest.Config) (*ArgoAPIClient, error)

type ArgoWorkflowClient

type ArgoWorkflowClient struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

func (*ArgoWorkflowClient) Delete

func (s *ArgoWorkflowClient) Delete(ctx context.Context, opts DeleteOptions) error

func (*ArgoWorkflowClient) GetLogs

func (s *ArgoWorkflowClient) GetLogs(ctx context.Context, opts LogsOptions) ([]byte, error)

GetWorkflowStepExecutionLogs gets workflow step execution logs.

func (*ArgoWorkflowClient) Resubmit

func (s *ArgoWorkflowClient) Resubmit(ctx context.Context, opts ResubmitOptions) error

func (*ArgoWorkflowClient) Resume

func (s *ArgoWorkflowClient) Resume(ctx context.Context, opts ResumeOptions) error

func (*ArgoWorkflowClient) StreamLogs

func (s *ArgoWorkflowClient) StreamLogs(ctx context.Context, opts StreamLogsOptions) error

StreamWorkflowStepExecutionLogs streams workflow step execution logs.

func (*ArgoWorkflowClient) Submit

func (s *ArgoWorkflowClient) Submit(ctx context.Context, opts SubmitOptions) error

func (*ArgoWorkflowClient) Terminate

func (s *ArgoWorkflowClient) Terminate(ctx context.Context, opts TerminateOptions) error

Terminate terminates a workflow execution. It will stop all nodes of the workflow execution.

type Client

type Client interface {
	// Submit submits a workflow to the workflow engine.
	Submit(context.Context, SubmitOptions) error
	// Resume resumes a workflow step execution of a workflow execution..
	Resume(context.Context, ResumeOptions) error
	// Resubmit resubmits a workflow to the workflow engine.
	Resubmit(context.Context, ResubmitOptions) error
	// Delete deletes a workflow from the workflow engine.
	Delete(context.Context, DeleteOptions) error
	// GetLogs gets logs of a workflow step execution.
	GetLogs(context.Context, LogsOptions) ([]byte, error)
	// StreamLogs streams logs of a workflow execution.
	StreamLogs(context.Context, StreamLogsOptions) error
	// Terminate terminates a workflow execution.
	Terminate(context.Context, TerminateOptions) error
}

Client is the interface that defines the operations of workflow engine.

func NewArgoWorkflowClient

func NewArgoWorkflowClient(mc model.ClientSet, restCfg *rest.Config) (Client, error)

type DeleteOptions

type DeleteOptions struct {
	WorkflowExecution *model.WorkflowExecution
}

type GetOptions

type GetOptions struct {
	WorkflowExecution *model.WorkflowExecution
}

type LogsOptions

type LogsOptions struct {
	optypes.LogOptions

	WorkflowExecution *model.WorkflowExecution
	StepExecution     *model.WorkflowStepExecution
}

LogsOptions is the options for getting logs of a workflow step execution.

type ResubmitOptions

type ResubmitOptions struct {
	WorkflowExecution *model.WorkflowExecution
}

type ResumeOptions

type ResumeOptions struct {
	// Approve or deny of the workflow approval step execution.
	Approve bool

	// WorkflowExecution is the workflow execution to be resumed.
	WorkflowExecution *model.WorkflowExecution
	// WorkflowStepExecution is the workflow step execution to be resumed.
	WorkflowStepExecution *model.WorkflowStepExecution
}

ResumeOptions is the options for submitting a workflow. WorkflowExecution's Edge WorkflowStageExecutions and their Edge WorkflowStepExecutions must be set.

type StatusSyncer

type StatusSyncer struct {
	Logger         log.Logger
	ModelClient    model.ClientSet
	WorkflowClient Client
}

StatusSyncer sync the status of workflow execution.

func NewStatusSyncer

func NewStatusSyncer(
	mc model.ClientSet,
	wc Client,
) *StatusSyncer

func (*StatusSyncer) IsCanceled added in v0.5.0

func (m *StatusSyncer) IsCanceled(ctx context.Context, wf *wfv1.Workflow) (bool, error)

func (*StatusSyncer) SyncStageExecutionStatus

func (m *StatusSyncer) SyncStageExecutionStatus(
	ctx context.Context,
	node wfv1.NodeStatus,
	stageExecutionID object.ID,
	canceled bool,
) error

SyncStageExecutionStatus syncs workflow stage execution status.

func (*StatusSyncer) SyncStepExecutionStatus

func (m *StatusSyncer) SyncStepExecutionStatus(
	ctx context.Context,
	node wfv1.NodeStatus,
	stepExecutionID object.ID,
	canceled bool,
) error

SyncStepExecutionStatus syncs workflow step execution status.

func (*StatusSyncer) SyncWorkflowExecutionStatus

func (m *StatusSyncer) SyncWorkflowExecutionStatus(ctx context.Context, wf *wfv1.Workflow) error

SyncWorkflowExecutionStatus syncs the status of workflow execution.

type StreamLogsOptions

type StreamLogsOptions struct {
	LogsOptions

	Out io.Writer
}

StreamLogsOptions is the options for streaming logs of a workflow execution.

type SubmitOptions

type SubmitOptions struct {
	WorkflowExecution *model.WorkflowExecution
	SubjectID         object.ID
}

type SubmitParamsOpts

type SubmitParamsOpts struct {
	WorkflowExecution *model.WorkflowExecution
	Params            map[string]string
}

SubmitParamsOpts is the options for submitting a workflow with parameters.

type TemplateManager

type TemplateManager struct {
	// contains filtered or unexported fields
}

TemplateManager is the manager of workflow templates. Manager generate argo workflow definition with model.WorkflowExecution. It generates templates for workflow with workflow, stage and step executions.

func NewTemplateManager

func NewTemplateManager(mc model.ClientSet) *TemplateManager

func (*TemplateManager) GetStageExecutionEnterTemplate

func (t *TemplateManager) GetStageExecutionEnterTemplate(
	stageExecution *model.WorkflowStageExecution,
) *wfv1.Template

GetStageExecutionEnterTemplate returns the enter template of a stage execution. The template handler sync the status of the stage execution to "Running".

func (*TemplateManager) GetStageExecutionExitTemplate

func (t *TemplateManager) GetStageExecutionExitTemplate(
	stageExecution *model.WorkflowStageExecution,
) *wfv1.Template

GetStageExecutionExitTemplate returns the exit template of a stage execution. The template handler sync the status of the stage execution to "Succeeded" or "Failed".

func (*TemplateManager) GetStageExecutionStatusTemplate

func (t *TemplateManager) GetStageExecutionStatusTemplate(
	name string,
	stageExecution *model.WorkflowStageExecution,
) *wfv1.Template

GetStageExecutionStatusTemplate returns the status template of a stage execution. The status template handler sync the status of the stage execution to "Running", "Succeeded" or "Failed".

func (*TemplateManager) GetStageExecutionTemplates

func (t *TemplateManager) GetStageExecutionTemplates(
	ctx context.Context,
	stageExecution *model.WorkflowStageExecution,
) (stageTemplate *wfv1.Template, subTemplates []*wfv1.Template, err error)

GetStageExecutionTemplates extends one stage execution to template, return stage template and its step templates.

func (*TemplateManager) GetStepExecutionExtendTemplates

func (t *TemplateManager) GetStepExecutionExtendTemplates(
	ctx context.Context,
	stepExecution *model.WorkflowStepExecution,
) (extendTemplate *wfv1.Template, stepTemplates []*wfv1.Template, err error)

GetStepExecutionExtendTemplates extends one step execution to three step executions, enter template, main template, exit step template, which are used to update the status of the step execution. The extend templates are used to manager lifecycle of the step execution.

func (*TemplateManager) GetStepExecutionStatusTemplate

func (t *TemplateManager) GetStepExecutionStatusTemplate(
	name string,
	stepExecution *model.WorkflowStepExecution,
) *wfv1.Template

GetStepExecutionStatusTemplate returns the status template of a step execution. The status template handler sync the status of the step execution to "Running", "Succeeded" or "Failed".

func (*TemplateManager) GetStepExecutionTemplates

func (t *TemplateManager) GetStepExecutionTemplates(
	ctx context.Context,
	stepExecution *model.WorkflowStepExecution,
) ([]*wfv1.Template, error)

GetStepExecutionTemplates extends one step execution to three step executions, enter template, main template, exit step template, which are used to update the status of the step execution.

func (*TemplateManager) GetWorkflowExecutionEnterTemplate

func (t *TemplateManager) GetWorkflowExecutionEnterTemplate(wf *model.WorkflowExecution) *wfv1.Template

GetWorkflowExecutionEnterTemplate returns the enter template of a workflow execution.

func (*TemplateManager) GetWorkflowExecutionExitTemplate

func (t *TemplateManager) GetWorkflowExecutionExitTemplate(wf *model.WorkflowExecution) *wfv1.Template

getExitTemplate returns template for workflow exit handler.

func (*TemplateManager) GetWorkflowExecutionStatusTemplate

func (t *TemplateManager) GetWorkflowExecutionStatusTemplate(
	name string,
	wf *model.WorkflowExecution,
) *wfv1.Template

GetWorkflowExecutionStatusTemplate returns the status template of a workflow execution. The status template handler sync the status of the workflow execution to "Running", "Succeeded" or "Failed". It will be called with the lifecycle hook of the stage execution.

func (*TemplateManager) GetWorkflowExecutionTemplates

func (t *TemplateManager) GetWorkflowExecutionTemplates(
	ctx context.Context,
	stageExecutions model.WorkflowStageExecutions,
) ([]*wfv1.Template, error)

GetWorkflowExecutionTemplates get workflow execution templates.

func (*TemplateManager) ToArgoWorkflow

func (t *TemplateManager) ToArgoWorkflow(
	ctx context.Context,
	workflowExecution *model.WorkflowExecution,
	token string,
) (*wfv1.Workflow, error)

ToArgoWorkflow returns an argo workflow for a workflow execution. The workflow execution MUST contains edges of stage and step executions.

type TerminateOptions

type TerminateOptions struct {
	WorkflowExecution *model.WorkflowExecution
}

TerminateOptions is the options for terminating a workflow execution.

type WorkflowReconciler

type WorkflowReconciler struct {
	Logger       logr.Logger
	KubeClient   client.Client
	StatusSyncer *StatusSyncer
}

WorkflowReconciler reconciles a Workflow object.

func (WorkflowReconciler) Reconcile

func (r WorkflowReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile reconciles the workflow.

func (WorkflowReconciler) Setup

func (r WorkflowReconciler) Setup(mgr ctrl.Manager) error

Directories

Path Synopsis
installer

Jump to

Keyboard shortcuts

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