lifecycle

package
v1.0.35 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AtLeastOneJobHasFailed is used when at least one job has failed, and there is toleration defined.
	AtLeastOneJobHasFailed = "AtLeastOneJobHasFailed"

	// TooManyJobsHaveFailed is used when the number of failures exceed the number of toleration.
	TooManyJobsHaveFailed = "TooManyJobsHaveFailed"

	// ExactlyOneJobIsFailed indicate that the only scheduled job is in the Failed Phase.
	ExactlyOneJobIsFailed = "ExactlyOneJobIsFailed"
)

Reasons for Failure.

View Source
const (
	// AllJobsAreSuccessful is when all the scheduled jobs are successfully completed.
	AllJobsAreSuccessful = "AllJobsAreSuccessful"

	// ExactlyOneJobIsSuccessful indicate that the only scheduled job is in the Success Phase.
	ExactlyOneJobIsSuccessful = "ExactlyOneJobIsSuccessful"

	// ToleratedJobsAreSuccessful indicate that despite (tolerated) failures, a required number of jobs are successful.
	ToleratedJobsAreSuccessful = "JobSuccessfulDespiteErrors"
)

Reasons for Success.

View Source
const (
	// AtLeastOneJobIsRunning indicate that  all jobs are created, and at least one is still running.
	AtLeastOneJobIsRunning = "AtLeastOneJobIsRunning"

	// ExactlyOneJobIsRunning indicate that the only scheduled job is in the Running phase.
	ExactlyOneJobIsRunning = "ExactlyOneJobIsRunning"
)

Reasons for Running.

View Source
const (
	// AtLeastOneJobIsNotScheduled indicate that there is at least one job that is not yet scheduled.
	AtLeastOneJobIsNotScheduled = "AtLeastOneJobIsNotScheduled"

	// ExactlyOneJobIsPending indicate that the only scheduled job is in the Pending phase.
	ExactlyOneJobIsPending = "ExactlyOneJobIsPending"
)

Reasons for Pending.

Variables

This section is empty.

Functions

func Failed

func Failed(ctx context.Context, r common.Reconciler, obj client.Object, issue error) (reconcile.Result, error)

Failed is a wrap that logs the error, updates the status, and does not requeue the request.

func GroupedJobs

func GroupedJobs(totalJobs int, state ClassifierReader, lf *v1alpha1.Lifecycle, tolerate *v1alpha1.TolerateSpec) bool

GroupedJobs calculate the lifecycle for action with multiple sub-jobs, such as Clusters, Cascade, Calls, ...

func Pending

Pending is a wrapper that sets Phase to Pending and does not requeue the request.

func SingleJob

func SingleJob(state ClassifierReader, lf *v1alpha1.Lifecycle) bool

func VirtualExecution

func VirtualExecution(ctx context.Context, reconciler common.Reconciler, parent client.Object, jobName string,
	callable func(vobj *v1alpha1.VirtualObject) error,
) error

VirtualExecution wraps a call into a virtual object. This is used for operations that do not create external resources. Examples: Deletions, Calls, ... The behavior of VirtualExecution is practically asynchronous. If the callback function fails, it will be reflected in the created virtual jobs and should be captured by the parent's lifecycle. The VirtualExecution will return nil. If the VirtualExecution fails (e.g, cannot create a virtual object), it will return an error.

Types

type Classifier

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

Classifier splits jobs into Pending, Running, Successful, and Failed. To relief the garbage collector, we use a embeddable structure that we reset at every reconciliation cycle.

func (*Classifier) Classify

func (in *Classifier) Classify(name string, obj client.Object)

Classify the object based on the standard Frisbee lifecycle.

func (*Classifier) ClassifyExternal

func (in *Classifier) ClassifyExternal(name string, obj client.Object, conv Convertor)

ClassifyExternal classifies the object based on the custom lifecycle.

func (*Classifier) Count

func (in *Classifier) Count() int

func (*Classifier) GetFailedJobs

func (in *Classifier) GetFailedJobs(jobNames ...string) []client.Object

func (*Classifier) GetPendingJobs

func (in *Classifier) GetPendingJobs(jobNames ...string) []client.Object

func (*Classifier) GetRunningJobs

func (in *Classifier) GetRunningJobs(jobNames ...string) []client.Object

func (*Classifier) GetSuccessfulJobs

func (in *Classifier) GetSuccessfulJobs(jobNames ...string) []client.Object

func (*Classifier) GetTerminatingJobs

func (in *Classifier) GetTerminatingJobs(jobNames ...string) []client.Object

func (*Classifier) IsFailed

func (in *Classifier) IsFailed(job ...string) bool

func (*Classifier) IsPending

func (in *Classifier) IsPending(job ...string) bool

func (*Classifier) IsRunning

func (in *Classifier) IsRunning(job ...string) bool

func (*Classifier) IsSuccessful

func (in *Classifier) IsSuccessful(job ...string) bool

func (*Classifier) IsTerminating

func (in *Classifier) IsTerminating(job ...string) bool

func (*Classifier) ListAll

func (in *Classifier) ListAll() string

func (*Classifier) ListFailedJobs

func (in *Classifier) ListFailedJobs() []string

func (*Classifier) ListPendingJobs

func (in *Classifier) ListPendingJobs() []string

func (*Classifier) ListRunningJobs

func (in *Classifier) ListRunningJobs() []string

func (*Classifier) ListSuccessfulJobs

func (in *Classifier) ListSuccessfulJobs() []string

func (*Classifier) ListTerminatingJobs

func (in *Classifier) ListTerminatingJobs() []string

func (*Classifier) NumAll

func (in *Classifier) NumAll() string

func (Classifier) NumFailedJobs

func (in Classifier) NumFailedJobs() int

func (*Classifier) NumPendingJobs

func (in *Classifier) NumPendingJobs() int

func (*Classifier) NumRunningJobs

func (in *Classifier) NumRunningJobs() int

func (*Classifier) NumSuccessfulJobs

func (in *Classifier) NumSuccessfulJobs() int

func (Classifier) NumTerminatingJobs

func (in Classifier) NumTerminatingJobs() int

func (*Classifier) Reset

func (in *Classifier) Reset()

func (*Classifier) SystemState

func (in *Classifier) SystemState() (abort bool, err error)

type ClassifierReader

type ClassifierReader interface {
	v1alpha1.StateAggregationFunctions

	// ListAll returns a printable form of the names of classified objects
	ListAll() string

	// NumAll returns a printable form of the cardinality of classified objects
	NumAll() string

	// Count returns the number of all registered entities.
	Count() int

	// SystemState returns the state of the SYS services. If all services are running, it should return (false, nil).
	SystemState() (abort bool, err error)

	GetPendingJobs(jobName ...string) []client.Object
	GetRunningJobs(jobName ...string) []client.Object
	GetSuccessfulJobs(jobName ...string) []client.Object
	GetFailedJobs(jobName ...string) []client.Object
}

type Convertor

type Convertor func(object client.Object) v1alpha1.Lifecycle

Jump to

Keyboard shortcuts

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