controllers

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 40 Imported by: 1

Documentation

Index

Examples

Constants

View Source
const (
	// ServiceAccountForHandlers is the service account name to use for jobs
	ServiceAccountForHandlers string = "iter8-handlers"
	// HandlerTypeStart is the type of a start handler
	HandlerTypeStart HandlerType = "Start"
	// HandlerTypeFinish is the type of a finish handler
	HandlerTypeFinish HandlerType = "Finish"
	// HandlerTypeRollback is the type of a rollback handler
	HandlerTypeRollback HandlerType = "Rollback"
	// HandlerTypeFailure is the type of a failure handler
	HandlerTypeFailure HandlerType = "Failure"
	// HandlerTypeLoop is the type of a loop handler
	HandlerTypeLoop HandlerType = "Loop"

	// HandlerYaml is the name of the job spec used for handlers
	HandlerYaml = "handler.yaml"

	// LabelExperimentName is key of label to be added to handler jobs for experiment name
	LabelExperimentName = "iter8/experimentName"
	// LabelExperimentNamespace is key of label to be added to handler jobs for experiment namespace
	LabelExperimentNamespace = "iter8/experimentNamespace"
)
View Source
const (
	// LoggerKey is the key used to extract logger from context
	LoggerKey ContextKey = "logger"

	// OriginalStatusKey is the key used to extract the original status from the context
	OriginalStatusKey ContextKey = "originalStatus"

	// Iter8LogPriorityHigh is the high priority value for Iter8Log
	Iter8LogPriorityHigh Iter8LogPriority = 1

	// Iter8LogPriorityMedium is the medium priority value for Iter8Log
	Iter8LogPriorityMedium Iter8LogPriority = 2

	// Iter8LogPriorityLow is the low priority value for Iter8Log
	Iter8LogPriorityLow Iter8LogPriority = 3

	// Iter8LogSourceTR is the task runner source
	Iter8LogSourceTR Iter8LogSource = "task-runner"
)

Variables

This section is empty.

Functions

func CompletePath added in v0.1.31

func CompletePath(prefix string, suffix string) string

CompletePath is a helper function for converting file paths, specified relative to the caller of this function, into absolute ones. CompletePath is useful in tests and enables deriving the absolute path of experiment YAML files.

Example
filePath := CompletePath("../test/data", "expwithextrafields.yaml")
_, _ = ioutil.ReadFile(filePath)
Output:

func GetJobCondition

func GetJobCondition(job *batchv1.Job, condition batchv1.JobConditionType) *batchv1.JobCondition

GetJobCondition is a utility to retrieve a condition from a Job resource returns nil if it is not present

func HandlerJobCompleted

func HandlerJobCompleted(handlerJob *batchv1.Job) bool

HandlerJobCompleted returns true if the job is completed (has the JobComplete condition set to true)

func HandlerJobFailed

func HandlerJobFailed(handlerJob *batchv1.Job) bool

HandlerJobFailed returns true if the job has failed (has the JobFailed condition set to true)

func Invoke added in v0.1.31

func Invoke(log logr.Logger, endpoint string, payload interface{}, transport HTTPTransport) (*v2alpha2.Analysis, error)

Invoke sends payload to endpoint and gets response back

func Logger added in v0.1.31

func Logger(ctx context.Context) logr.Logger

Logger gets the logger from the context.

func OriginalStatus added in v0.1.31

func OriginalStatus(ctx context.Context) *v2alpha2.ExperimentStatus

OriginalStatus gets the status from the context

func ReadConfig added in v0.1.31

func ReadConfig(cfg *Iter8Config) error

ReadConfig reads the configuration from a combination of files and the environment

Types

type Analytics added in v0.1.31

type Analytics struct {
	Endpoint string `yaml:"endpoint" envconfig:"ITER8_ANALYTICS_ENDPOINT"`
}

Analytics captures details of analytics endpoint(s)

type ContextKey added in v0.1.31

type ContextKey string

ContextKey variables can be used to retrieve values from context object

type ExperimentReconciler

type ExperimentReconciler struct {
	client.Client
	Log           logr.Logger
	Scheme        *runtime.Scheme
	RestConfig    *rest.Config
	EventRecorder record.EventRecorder
	Iter8Config   Iter8Config
	HTTP          HTTPTransport
	ReleaseEvents chan event.GenericEvent
	JobManager    JobManager
}

ExperimentReconciler reconciles a Experiment object

func (*ExperimentReconciler) AreTasksValid added in v0.1.31

func (r *ExperimentReconciler) AreTasksValid(ctx context.Context, instance *v2alpha2.Experiment) bool

AreTasksValid ensures that each task either has a valid task string or a valid run string but not both

func (*ExperimentReconciler) GetHandler

func (r *ExperimentReconciler) GetHandler(instance *v2alpha2.Experiment, t HandlerType) *string

GetHandler returns handler of a given type

func (*ExperimentReconciler) GetHandlerStatus

func (r *ExperimentReconciler) GetHandlerStatus(ctx context.Context, instance *v2alpha2.Experiment, handler *string, handlerInstance *int) HandlerStatusType

GetHandlerStatus determines a handlers status

func (*ExperimentReconciler) IsExperimentValid

func (r *ExperimentReconciler) IsExperimentValid(ctx context.Context, instance *v2alpha2.Experiment) bool

IsExperimentValid verifies that instance.Spec is valid; this should be done after late initialization TODO 1. If fixed_split, we have an initial split (or are we just assuming start handler does it?) TODO 2. Warning if no criteria? TODO 3. For ab and abn there is a reward TODO 4. If rollbackOnFailure there is a rollback handler?

func (*ExperimentReconciler) IsHandlerLaunched

func (r *ExperimentReconciler) IsHandlerLaunched(ctx context.Context, instance *v2alpha2.Experiment, handler string, handlerInstance *int) (*batchv1.Job, error)

IsHandlerLaunched returns the handler (job) if one has been launched Otherwise it returns nil

func (*ExperimentReconciler) IsVersionInfoValid

func (r *ExperimentReconciler) IsVersionInfoValid(ctx context.Context, instance *v2alpha2.Experiment) bool

IsVersionInfoValid verifies that Spec.versionInfo is valid DONE Verify that versionInfo is present DONE Verify that the number of versions (spec.versionInfo) is suitable to the spec.strategy.testingPattern DONE Verify that the names of the versions are all unique DONE Verify that the number of rewards (spec.criteria.rewards) is suitable to spec.strategy.testingPattern DONE Verify that each fieldpath starts with '.' TODO Verify any ObjectReferences are existing objects in the cluster

func (*ExperimentReconciler) LaunchHandler

func (r *ExperimentReconciler) LaunchHandler(ctx context.Context, instance *v2alpha2.Experiment, handler string, handlerInstance *int) error

LaunchHandler lauches the job that implements a particular handler

func (*ExperimentReconciler) ReadMetric

func (r *ExperimentReconciler) ReadMetric(ctx context.Context, instance *v2alpha2.Experiment, namespace string, name string, metricMap map[string]*v2alpha2.Metric) bool

ReadMetric reads a metric from the cluster using the name as the key If the name is of the form "namespace/name", look in namespace for name. Otherwise look for name. If not found, look in namespace for name. If not found return NotFound error

func (*ExperimentReconciler) ReadMetrics

func (r *ExperimentReconciler) ReadMetrics(ctx context.Context, instance *v2alpha2.Experiment) bool

ReadMetrics reads needed metrics from cluster and caches them in the experiment result is false if an error occurred reading metrics

func (*ExperimentReconciler) Reconcile

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

Reconcile attempts to align the resource with the spec

func (*ExperimentReconciler) SetupWithManager

func (r *ExperimentReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager is the method called when setting up the experiment reconciler with the controller manager.

type HTTPTransport added in v0.1.31

type HTTPTransport interface {
	Post(url, contentType string, body []byte) ([]byte, int, error)
}

HTTPTransport ..

type HandlerStatusType

type HandlerStatusType string

HandlerStatusType is the type of a handler status

const (
	// HandlerStatusNoHandler indicates that there is no handler
	HandlerStatusNoHandler HandlerStatusType = "NoHandler"
	// HandlerStatusNotLaunched indicates that the handler has not been lauched
	HandlerStatusNotLaunched HandlerStatusType = "NotLaunched"
	// HandlerStatusRunning indicates that the handler is executing
	HandlerStatusRunning HandlerStatusType = "Running"
	// HandlerStatusFailed indicates that the handler failed during execution
	HandlerStatusFailed HandlerStatusType = "Failed"
	// HandlerStatusComplete indicates that the handler has successfully executed to completion
	HandlerStatusComplete HandlerStatusType = "Complete"
)

type HandlerType

type HandlerType string

HandlerType types of handlers

type Iter8Config added in v0.1.31

type Iter8Config struct {
	Analytics   `json:"analytics" yaml:"analytics"`
	Namespace   string `envconfig:"ITER8_NAMESPACE"`
	HandlersDir string `envconfig:"HANDLERS_DIR"`
}

Iter8Config describes structure of configuration file

type Iter8ConfigBuilder added in v0.1.31

type Iter8ConfigBuilder Iter8Config

Iter8ConfigBuilder type for building new config by hand

func NewIter8Config added in v0.1.31

func NewIter8Config() Iter8ConfigBuilder

NewIter8Config returns a new config builder

func (Iter8ConfigBuilder) Build added in v0.1.31

func (b Iter8ConfigBuilder) Build() Iter8Config

Build ..

func (Iter8ConfigBuilder) WithEndpoint added in v0.1.31

func (b Iter8ConfigBuilder) WithEndpoint(endpoint string) Iter8ConfigBuilder

WithEndpoint ..

func (Iter8ConfigBuilder) WithHandlersDir added in v0.1.31

func (b Iter8ConfigBuilder) WithHandlersDir(handlersDir string) Iter8ConfigBuilder

WithHandlersDir ..

func (Iter8ConfigBuilder) WithNamespace added in v0.1.31

func (b Iter8ConfigBuilder) WithNamespace(namespace string) Iter8ConfigBuilder

WithNamespace ..

type Iter8Log added in v0.1.33

type Iter8Log struct {
	IsIter8Log          bool             `json:"isIter8Log" yaml:"isIter8Log"`
	ExperimentName      string           `json:"experimentName" yaml:"experimentName"`
	ExperimentNamespace string           `json:"experimentNamespace" yaml:"experimentNamespace"`
	Source              Iter8LogSource   `json:"source" yaml:"source"`
	Priority            Iter8LogPriority `json:"priority" yaml:"priority"`
	Message             string           `json:"message" yaml:"message"`
	// Precedence = 0 ... for start action.
	// Precedence = number of completed loops + 1 ... for loop action, and finish action.
	// Above definition of precedence will evolve as controller and analytics Iter8logs are implemented.
	// Precedence is not intended to be seen/used by the end-user. It is one a field used for ensuring Iter8logs are output in the chronological order.
	Precedence int `json:"precedence" yaml:"precedence"`
}

func (*Iter8Log) JSON added in v0.1.33

func (il *Iter8Log) JSON() string

JSON returns the JSON string representation of the Iter8log

type Iter8LogPriority added in v0.1.33

type Iter8LogPriority uint8

Iter8LogPriority variables and constants can be used for setting Iter8Log priority value

type Iter8LogSource added in v0.1.33

type Iter8LogSource string

Iter8LogSource variables and constants can be used for setting Iter8Log source value

type JobManager added in v0.1.24

type JobManager interface {
	Get(ctx context.Context, ref types.NamespacedName, job *batchv1.Job) error
}

JobManager enables mocking of handler jobs during tests

Jump to

Keyboard shortcuts

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