control

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PodJobAnnotationPrefix defines the prefix key for a job data (json serialized) in the annotations of the pod
	PodJobAnnotationPrefix = "control.k8ssandra.io/job"
)

*

Jobs executing something on every pod in the datacenter

*

Variables

View Source
var (
	JobRunningRequeue  = 10 * time.Second
	TaskRunningRequeue = time.Duration(5 * time.Second)
)

These are vars to allow modifications for testing

Functions

func JobStatusToPodAnnotations

func JobStatusToPodAnnotations(taskId string, annotations map[string]string, jobStatus JobStatus) error

func SetCondition

func SetCondition(task *api.CassandraTask, condition api.JobConditionType, status metav1.ConditionStatus, message string) bool

Types

type AsyncTaskExecutorFunc

type AsyncTaskExecutorFunc func(httphelper.NodeMgmtClient, *corev1.Pod, *TaskConfiguration) (string, error)

AsyncTaskExecutorFunc is called for all methods that support async processing

type CassandraTaskReconciler

type CassandraTaskReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

CassandraTaskReconciler reconciles a CassandraJob object

func (*CassandraTaskReconciler) HasCondition

func (r *CassandraTaskReconciler) HasCondition(task api.CassandraTask, condition api.JobConditionType, status metav1.ConditionStatus) bool

func (*CassandraTaskReconciler) Reconcile

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

func (*CassandraTaskReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type JobStatus

type JobStatus struct {
	Id      string `json:"id,omitempty"`
	Status  string `json:"status,omitempty"`
	Handler string `json:"handler,omitempty"`
	Retries int    `json:"retries,omitempty"`
}

func GetJobStatusFromPodAnnotations

func GetJobStatusFromPodAnnotations(taskId string, annotations map[string]string) (JobStatus, error)

GetJobStatusFromPodAnnotations gets the json serialized pod job statusfrom Pod.Annotations and converts it to the Affinity type in api.

type PodFilterFunc

type PodFilterFunc func(*corev1.Pod, *TaskConfiguration) bool

PodFilterFunc approves or rejects the target pod for processing purposes.

type ProcessFunc

type ProcessFunc func(*TaskConfiguration) error

ProcessFunc is a function that's run before the pods are being processed individually, or after the pods have been processed.

type SyncTaskExecutorFunc

type SyncTaskExecutorFunc func(httphelper.NodeMgmtClient, *corev1.Pod, *TaskConfiguration) error

SyncTaskExecutorFunc is called as a backup if async one isn't supported

type TaskConfiguration

type TaskConfiguration struct {
	// Meta / status
	Id            string
	TaskStartTime *metav1.Time
	Datacenter    *cassapi.CassandraDatacenter
	Context       context.Context

	// Input parameters
	RestartPolicy corev1.RestartPolicy
	Arguments     api.JobArguments

	// Execution functionality per pod
	AsyncFeature httphelper.Feature
	AsyncFunc    AsyncTaskExecutorFunc
	SyncFunc     SyncTaskExecutorFunc
	PodFilter    PodFilterFunc

	// Functions not targeting the pod
	ValidateFunc   ValidatorFunc
	PreProcessFunc ProcessFunc

	// Status tracking
	Completed int
}

TaskConfiguration sets the command's functions to execute

func (*TaskConfiguration) Filter

func (t *TaskConfiguration) Filter(pod *corev1.Pod) bool

func (*TaskConfiguration) PreProcess

func (t *TaskConfiguration) PreProcess() error

func (*TaskConfiguration) Validate

func (t *TaskConfiguration) Validate() (bool, error)

type ValidatorFunc

type ValidatorFunc func(*TaskConfiguration) (bool, error)

ValidatorFunc validates that necessary parameters are set for the task. If false is returned, the task has failed the validation and the error has the details. If true is returned, the error is transient and should be retried.

Jump to

Keyboard shortcuts

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