scheduler

package
v0.20.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// OptionsWaitForDestroy Wait for the destroy to finish before returning
	OptionsWaitForDestroy = "WAIT_FOR_DESTROY"
	// OptionsWaitForResourceLeak Wait for all the resources to be cleaned up after destroying
	OptionsWaitForResourceLeakCleanup = "WAIT_FOR_RESOURCE_LEAK_CLEANUP"
	SecretVault                       = "vault"
	SecretK8S                         = "k8s"
)

Options specifies keys for a key-value pair that can be passed to scheduler methods

Variables

This section is empty.

Functions

func Register

func Register(name string, d Driver) error

Register registers the given scheduler driver

Types

type AppConfig

type AppConfig struct {
	Replicas     int    `yaml:"replicas"`
	VolumeSize   string `yaml:"volume_size"`
	WorkloadSize string `yaml:"workload_size"`
}

AppConfig custom settings

type Context

type Context struct {
	// UID unique object identifier
	UID string
	// App defines a k8s application specification
	App *spec.AppSpec
	// ScheduleOptions are options that callers to pass to influence the apps that get schduled
	ScheduleOptions ScheduleOptions
	// SkipVolumeValidation for cases when use volume driver other than portworx
	SkipVolumeValidation bool
	// SkipClusterScopedObject for cases of multi-cluster backup when Storage class does not restored
	SkipClusterScopedObject bool
	// RefreshStorageEndpoint force refresh the storage driver endpoint
	RefreshStorageEndpoint bool
	// ReadinessTimeout time within which context is expected to be up
	ReadinessTimeout time.Duration
}

Context holds the execution context of a test task.

func (*Context) DeepCopy

func (in *Context) DeepCopy() *Context

DeepCopy create a copy of Context

func (*Context) GetID

func (in *Context) GetID() string

GetID returns the unique ID for the context. This encompasses the instance ID provided by users during schedule of the context and the ID of the app specs

type DeleteTasksOptions

type DeleteTasksOptions struct {
	api.TriggerOptions
}

DeleteTasksOptions are options supplied to the DeleteTasks API

type Driver

type Driver interface {
	spec.Parser

	// Init initializes the scheduler driver
	Init(schedOpts InitOptions) error

	// String returns the string name of this driver.
	String() string

	// IsNodeReady checks if node is in ready state. Returns nil if ready.
	IsNodeReady(n node.Node) error

	// GetNodesForApp returns nodes on which given app context is running
	GetNodesForApp(*Context) ([]node.Node, error)

	// Schedule starts applications and returns a context for each one of them
	Schedule(instanceID string, opts ScheduleOptions) ([]*Context, error)

	// WaitForRunning waits for application to start running.
	WaitForRunning(cc *Context, timeout, retryInterval time.Duration) error

	// AddTasks adds tasks to an existing context
	AddTasks(*Context, ScheduleOptions) error

	// UpdateTasksID updates task IDs in the given context
	UpdateTasksID(*Context, string) error

	// Destroy removes a application. It does not delete the volumes of the task.
	Destroy(*Context, map[string]bool) error

	// WaitForDestroy waits for application to destroy.
	WaitForDestroy(*Context, time.Duration) error

	// DeleteTasks deletes all tasks of the application (not the application). DeleteTasksOptions is optional.
	DeleteTasks(*Context, *DeleteTasksOptions) error

	// GetVolumeDriverVolumeName returns name of volume which is refered by volume driver
	GetVolumeDriverVolumeName(name string, namespace string) (string, error)

	// GetVolumeParameters Returns a maps, each item being a volume and it's options
	GetVolumeParameters(*Context) (map[string]map[string]string, error)

	// ValidateVolumes validates storage volumes in the provided context
	ValidateVolumes(cc *Context, timeout, retryInterval time.Duration, options *VolumeOptions) error

	// DeleteVolumes will delete all storage volumes for the given context
	DeleteVolumes(*Context, *VolumeOptions) ([]*volume.Volume, error)

	// GetVolumes returns all storage volumes for the given context
	GetVolumes(*Context) ([]*volume.Volume, error)

	// ResizeVolume resizes all the volumes of a given context
	ResizeVolume(*Context, string) ([]*volume.Volume, error)

	// GetSnapshots returns all storage snapshots for the given context
	GetSnapshots(*Context) ([]*volume.Snapshot, error)

	// Describe generates a bundle that can be used by support - logs, cores, states, etc
	Describe(*Context) (string, error)

	// ScaleApplication scales the current applications using the new scales from the GetScaleFactorMap.
	ScaleApplication(*Context, map[string]int32) error

	// GetScaleFactorMap gets a map of current applications to their new scales, based on "factor"
	GetScaleFactorMap(*Context) (map[string]int32, error)

	// StopSchedOnNode stops scheduler service on the given node
	StopSchedOnNode(n node.Node) error

	// StartSchedOnNode starts scheduler service on the given node
	StartSchedOnNode(n node.Node) error

	// RefreshNodeRegistry refreshes node registry
	RefreshNodeRegistry() error

	// RescanSpecs specified in specDir
	RescanSpecs(specDir, storageDriver string) error

	// EnableSchedulingOnNode enable apps to be scheduled to a given node
	EnableSchedulingOnNode(n node.Node) error

	// DisableSchedulingOnNode disable apps to be scheduled to a given node
	DisableSchedulingOnNode(n node.Node) error

	// PrepareNodeToDecommission prepares a given node for decommissioning
	PrepareNodeToDecommission(n node.Node, provisioner string) error

	// IsScalable check if a given spec is scalable or not
	IsScalable(spec interface{}) bool

	// ValidateVolumeSnapshotRestore return nil if snapshot is restored successuflly to
	// parent volumes
	ValidateVolumeSnapshotRestore(*Context, time.Time) error

	// GetTokenFromConfigMap gets token for a volume
	GetTokenFromConfigMap(string) (string, error)

	// AddLabelOnNode adds key value labels on the node
	AddLabelOnNode(node.Node, string, string) error

	// IsAutopilotEnabledForVolume checks if autopilot enabled for a given volume
	IsAutopilotEnabledForVolume(*volume.Volume) bool

	// SaveSchedulerLogsToFile gathers all scheduler logs into a file
	SaveSchedulerLogsToFile(node.Node, string) error

	// CreateAutopilotRule creates the AutopilotRule object
	CreateAutopilotRule(apRule apapi.AutopilotRule) (*apapi.AutopilotRule, error)

	// UpdateAutopilotRule updates the AutopilotRule
	UpdateAutopilotRule(apapi.AutopilotRule) (*apapi.AutopilotRule, error)

	// ListAutopilotRules lists AutopilotRules
	ListAutopilotRules() (*apapi.AutopilotRuleList, error)

	// GetEvents should return all the events from the scheduler since the time torpedo started
	GetEvents() map[string][]Event

	// ValidateAutopilotEvents validates events for PVCs injected by autopilot
	ValidateAutopilotEvents(ctx *Context) error

	// GetWorkloadSizeFromAppSpec gets workload size from an application spec
	GetWorkloadSizeFromAppSpec(ctx *Context) (uint64, error)

	// SetConfig sets connnection config (e.g. kubeconfig in case of k8s) for scheduler driver
	SetConfig(configPath string) error
}

Driver must be implemented to provide test support to various schedulers.

func Get

func Get(name string) (Driver, error)

Get returns a registered scheduler test provider.

type ErrFailedToAddLabelOnNode

type ErrFailedToAddLabelOnNode struct {
	// Key is the label key
	Key string
	// Value is the label value
	Value string
	// Node is the node where label should be added
	Node node.Node
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToAddLabelOnNode error type for failing to add label on node

func (*ErrFailedToAddLabelOnNode) Error

func (e *ErrFailedToAddLabelOnNode) Error() string

type ErrFailedToDecommissionNode

type ErrFailedToDecommissionNode struct {
	// Node where the service is not starting
	Node node.Node
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToDecommissionNode error type when fail to decommission a node

func (*ErrFailedToDecommissionNode) Error

type ErrFailedToDeleteTasks

type ErrFailedToDeleteTasks struct {
	// App is the app for which we failed to delete the tasks
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToDeleteTasks error type for failing to delete the tasks for an app

func (*ErrFailedToDeleteTasks) Error

func (e *ErrFailedToDeleteTasks) Error() string

type ErrFailedToDeleteVolumeDirForPod

type ErrFailedToDeleteVolumeDirForPod struct {
	// App is the app whose volume directories are not deleted
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToDeleteVolumeDirForPod error type for failing to delete volume dir path for pods

func (*ErrFailedToDeleteVolumeDirForPod) Error

type ErrFailedToDestroyApp

type ErrFailedToDestroyApp struct {
	// App is the app that failed to destroy
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToDestroyApp error type for failing to destroy an app

func (*ErrFailedToDestroyApp) Error

func (e *ErrFailedToDestroyApp) Error() string

type ErrFailedToDestroyPod

type ErrFailedToDestroyPod struct {
	// App is the app that failed to destroy
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToDestroyPod error type for failing to validate destory of a pod

func (*ErrFailedToDestroyPod) Error

func (e *ErrFailedToDestroyPod) Error() string

type ErrFailedToDestroyStorage

type ErrFailedToDestroyStorage struct {
	// App is the app that failed to destroy
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToDestroyStorage error type for failing to destroy an app's storage

func (*ErrFailedToDestroyStorage) Error

func (e *ErrFailedToDestroyStorage) Error() string

type ErrFailedToGetAppStatus

type ErrFailedToGetAppStatus struct {
	// App is the app for which we want to get the status
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetAppStatus error type for failing to get app's status

func (*ErrFailedToGetAppStatus) Error

func (e *ErrFailedToGetAppStatus) Error() string

type ErrFailedToGetConfigMap

type ErrFailedToGetConfigMap struct {
	// Name of config map
	Name string
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetConfigMap error type for failing to get config map

func (*ErrFailedToGetConfigMap) Error

func (e *ErrFailedToGetConfigMap) Error() string

type ErrFailedToGetCustomSpec

type ErrFailedToGetCustomSpec struct {
	// Name of config map
	Name string
	// Cause is the underlying cause of the error
	Cause string
	// Type is the underlying type of CRD objects
	Type interface{}
}

ErrFailedToGetCustomSpec error type for failing to get config map

func (*ErrFailedToGetCustomSpec) Error

func (e *ErrFailedToGetCustomSpec) Error() string

type ErrFailedToGetEvents

type ErrFailedToGetEvents struct {
	// Type is the resource type which we want to get the events
	Type string
	// Name of object
	Name string
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetEvents error when we are unable to get events

func (*ErrFailedToGetEvents) Error

func (e *ErrFailedToGetEvents) Error() string

type ErrFailedToGetNodesForApp

type ErrFailedToGetNodesForApp struct {
	// App is the app that failed to get to get nodes
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetNodesForApp error type for failing to get nodes on which app is running

func (*ErrFailedToGetNodesForApp) Error

func (e *ErrFailedToGetNodesForApp) Error() string

type ErrFailedToGetPodStatus

type ErrFailedToGetPodStatus struct {
	// App is the app for which we want to get the status
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetPodStatus error type for failing to get pod's status

func (*ErrFailedToGetPodStatus) Error

func (e *ErrFailedToGetPodStatus) Error() string

type ErrFailedToGetSecret

type ErrFailedToGetSecret struct {
	// App is the spec for which we want to get the secret
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetSecret error when we are unable to get the defined secret

func (*ErrFailedToGetSecret) Error

func (e *ErrFailedToGetSecret) Error() string

type ErrFailedToGetStorage

type ErrFailedToGetStorage struct {
	// App is the app whose storage could not be retrieved
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetStorage error type for failing to get an app's storage

func (*ErrFailedToGetStorage) Error

func (e *ErrFailedToGetStorage) Error() string

type ErrFailedToGetStorageStatus

type ErrFailedToGetStorageStatus struct {
	// App whose storage status couldn't be obtained
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetStorageStatus error type for failing to get the status of the app's storage

func (*ErrFailedToGetStorageStatus) Error

type ErrFailedToGetVolumeParameters

type ErrFailedToGetVolumeParameters struct {
	// App is the app for which we failed to get volume parameters
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToGetVolumeParameters error type for failing to get an app's volume paramters

func (*ErrFailedToGetVolumeParameters) Error

type ErrFailedToResizeStorage

type ErrFailedToResizeStorage struct {
	// App is the app whose storage could not be retrieved
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToResizeStorage error type for failing to update an app's storage

func (*ErrFailedToResizeStorage) Error

func (e *ErrFailedToResizeStorage) Error() string

type ErrFailedToScheduleApp

type ErrFailedToScheduleApp struct {
	// App is the app that failed to schedule
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToScheduleApp error type for failing to schedule an app

func (*ErrFailedToScheduleApp) Error

func (e *ErrFailedToScheduleApp) Error() string

type ErrFailedToSchedulePod

type ErrFailedToSchedulePod struct {
	// Pod is the pod that failed to schedule
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToSchedulePod error type for failing to schedule a pod

func (*ErrFailedToSchedulePod) Error

func (e *ErrFailedToSchedulePod) Error() string

type ErrFailedToStartSchedOnNode

type ErrFailedToStartSchedOnNode struct {
	// Node where the service is not starting
	Node node.Node
	// SystemService responsible for scheduling
	SystemService string
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToStartSchedOnNode error type when fail to start scheduler service on the node

func (*ErrFailedToStartSchedOnNode) Error

type ErrFailedToStopSchedOnNode

type ErrFailedToStopSchedOnNode struct {
	// Node where the service is not stopped
	Node node.Node
	// SystemService responsible for scheduling
	SystemService string
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToStopSchedOnNode error type when fail to stop scheduler service on the node

func (*ErrFailedToStopSchedOnNode) Error

type ErrFailedToUpdateApp

type ErrFailedToUpdateApp struct {
	// App is the app whose validation failed
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToUpdateApp error type for failing to update an app

func (*ErrFailedToUpdateApp) Error

func (e *ErrFailedToUpdateApp) Error() string

type ErrFailedToValidateApp

type ErrFailedToValidateApp struct {
	// App is the app whose validation failed
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToValidateApp error type for failing to validate an app

func (*ErrFailedToValidateApp) Error

func (e *ErrFailedToValidateApp) Error() string

type ErrFailedToValidateAppDestroy

type ErrFailedToValidateAppDestroy struct {
	// App is the app that failed to destroy
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToValidateAppDestroy error type for failing to validate destory of an app

func (*ErrFailedToValidateAppDestroy) Error

type ErrFailedToValidateCustomSpec

type ErrFailedToValidateCustomSpec struct {
	// Name of CRD object
	Name string
	// Cause is the underlying cause of the error
	Cause string
	// Type is the underlying type of CRD objects
	Type interface{}
}

ErrFailedToValidateCustomSpec error type when CRD objects does not applied successfully

func (*ErrFailedToValidateCustomSpec) Error

type ErrFailedToValidatePod

type ErrFailedToValidatePod struct {
	// App is the app whose validation failed
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToValidatePod error type for failing to validate a pod

func (*ErrFailedToValidatePod) Error

func (e *ErrFailedToValidatePod) Error() string

type ErrFailedToValidatePodDestroy

type ErrFailedToValidatePodDestroy struct {
	// App is the app that failed to destroy
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToValidatePodDestroy error type for failing to validate destroy of an pod

func (*ErrFailedToValidatePodDestroy) Error

type ErrFailedToValidateStorage

type ErrFailedToValidateStorage struct {
	// App is the app whose storage validation failed
	App *spec.AppSpec
	// Cause is the underlying cause of the error
	Cause string
}

ErrFailedToValidateStorage error type for failing to validate an app's storage

func (*ErrFailedToValidateStorage) Error

type ErrNodeNotReady

type ErrNodeNotReady struct {
	// Node is not which is not ready
	Node node.Node
	// Cause is the underlying cause of the error
	Cause string
}

ErrNodeNotReady error type when a node is not ready

func (*ErrNodeNotReady) Error

func (e *ErrNodeNotReady) Error() string

type Event

type Event struct {
	Message   string
	EventTime v1.MicroTime
	Count     int32
	LastSeen  v1.Time
	Kind      string
	Type      string
}

Event collects kubernetes events data for further validation

type InitOptions

type InitOptions struct {

	// SpecDir app spec directory
	SpecDir string
	// VolDriverName volume driver name
	VolDriverName string
	// NodeDriverName node driver name
	NodeDriverName string
	// ConfigMap  identifies what config map should be used to
	SecretConfigMapName string
	// CustomAppConfig custom settings for apps
	CustomAppConfig map[string]AppConfig
	// StorageProvisioner name
	StorageProvisioner string
	// SecretType secret used for encryption keys
	SecretType string
	// VaultAddress vault api address
	VaultAddress string
	// VaultToken vault authentication token
	VaultToken string
}

InitOptions initialization options

type ScheduleOptions

type ScheduleOptions struct {
	// AppKeys identified a list of applications keys that users wants to schedule (Optional)
	AppKeys []string
	// Nodes restricts the applications to get scheduled only on these nodes (Optional)
	Nodes []node.Node
	// StorageProvisioner identifies what storage provider should be used
	StorageProvisioner string
	// ConfigMap  identifies what config map should be used to
	ConfigMap string
	// AutopilotRule identifies options for autopilot (Optional)
	AutopilotRule apapi.AutopilotRule
	// Scheduler  identifies what scheduler will be used
	Scheduler string
	// Labels is a map of {key,value} pairs for labeling spec objects
	Labels map[string]string
}

ScheduleOptions are options that callers to pass to influence the apps that get schduled

type UpgradeAutopilotOptions

type UpgradeAutopilotOptions struct {
	api.TriggerOptions
}

UpgradeAutopilotOptions are options supplied to the UpgradeAutopilot API

type VolumeOptions

type VolumeOptions struct {
	// SkipClusterScopedObjects skips volume operations on cluster scoped objects like storage class
	SkipClusterScopedObjects bool
}

VolumeOptions are options supplied to the scheduler Volume APIs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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