reconcile

package
v0.0.0-...-bb45038 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 70 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BackOffCheck  api.BackOffKey = "check"
	LicenseCheck  api.BackOffKey = "license"
	TimezoneCheck api.BackOffKey = "timezone"
)
View Source
const (
	ActionShutdownJobExpiredTerminationTimeout = time.Minute
)
View Source
const (
	ActionTypeArangoMemberUpdatePodStatusChecksum = "checksum"
)
View Source
const CertificateRenewalMargin = 7 * 24 * time.Hour
View Source
const (
	DefaultStartFailureGracePeriod = 10 * time.Second
)

Variables

View Source
var (
	ObsoleteClusterConditions = []api.ConditionType{
		api.ConditionTypeMaintenanceMode,
	}
)

Functions

func EvaluateMemberRecreationCondition

func EvaluateMemberRecreationCondition(ctx context.Context,
	apiObject k8sutil.APIObject,
	spec api.DeploymentSpec, status api.DeploymentStatus,
	group api.ServerGroup, member api.MemberStatus,
	context PlanBuilderContext, evaluators ...MemberRecreationConditionEvaluator) (string, bool)

func GetActionTimeout

func GetActionTimeout(spec api.DeploymentSpec, t api.ActionType) api.Timeout

func GetAllActions

func GetAllActions() []api.ActionType

func GetTimezone

func GetTimezone(tz *string) (timezones.Timezone, bool)

func IsTimezoneValid

func IsTimezoneValid(cache secretv1.Inspector, name string, timezone timezones.Timezone) bool

Types

type Action

type Action interface {
	ActionCore

	// MemberID Return the MemberID used / created in this action
	MemberID() string
}

Action executes a single Plan item.

type ActionContext

type ActionContext interface {
	reconciler.DeploymentStatusUpdate
	reconciler.DeploymentAgencyMaintenance
	reconciler.DeploymentPodRenderer
	reconciler.ArangoAgencyGet
	reconciler.DeploymentInfoGetter
	reconciler.DeploymentDatabaseClient
	reconciler.KubernetesEventGenerator

	member.StateInspectorGetter

	sutil.ACSGetter

	Metrics() *Metrics

	ActionLocalsContext
	ActionProgressor

	// GetMemberStatusByID returns the current member status
	// for the member with given id.
	// Returns member status, true when found, or false
	// when no such member is found.
	GetMemberStatusByID(id string) (api.MemberStatus, bool)
	// GetMemberStatusAndGroupByID returns the current member status and group
	// for the member with given id.
	// Returns member status, true when found, or false
	// when no such member is found.
	GetMemberStatusAndGroupByID(id string) (api.MemberStatus, api.ServerGroup, bool)
	// CreateMember adds a new member to the given group.
	// If ID is non-empty, it will be used, otherwise a new ID is created.
	CreateMember(ctx context.Context, group api.ServerGroup, id string, mods ...CreateMemberMod) (string, error)
	// UpdateMember updates the deployment status wrt the given member.
	UpdateMember(ctx context.Context, member api.MemberStatus) error
	// RemoveMemberByID removes a member with given id.
	RemoveMemberByID(ctx context.Context, id string) error
	// GetImageInfo returns the image info for an image with given name.
	// Returns: (info, infoFound)
	GetImageInfo(imageName string) (api.ImageInfo, bool)
	// GetCurrentImageInfo returns the image info for an current image.
	// Returns: (info, infoFound)
	GetCurrentImageInfo() (api.ImageInfo, bool)
	// SetCurrentImage changes the CurrentImage field in the deployment
	// status to the given image.
	SetCurrentImage(ctx context.Context, imageInfo api.ImageInfo) error
	// DisableScalingCluster disables scaling DBservers and coordinators
	DisableScalingCluster(ctx context.Context) error
	// EnableScalingCluster enables scaling DBservers and coordinators
	EnableScalingCluster(ctx context.Context) error
	// UpdateClusterCondition update status of ArangoDeployment with defined modifier. If action returns True action is taken
	UpdateClusterCondition(ctx context.Context, conditionType api.ConditionType, status bool, reason, message string) error
	// GetBackup receives information about a backup resource
	GetBackup(ctx context.Context, backup string) (*backupApi.ArangoBackup, error)
	// GetName receives information about a deployment name
	GetName() string
	// SelectImage select currently used image by pod
	SelectImage(spec api.DeploymentSpec, status api.DeploymentStatus) (api.ImageInfo, bool)
}

ActionContext provides methods to the Action implementations to control their context.

type ActionCore

type ActionCore interface {
	// Start performs the start of the action.
	// Returns true if the action is completely finished, false in case
	// the start time needs to be recorded and a ready condition needs to be checked.
	Start(ctx context.Context) (bool, error)
	// CheckProgress checks the progress of the action.
	// Returns: ready, abort, error.
	CheckProgress(ctx context.Context) (bool, bool, error)
}

ActionCore executes a single Plan item.

func NewActionSuccess

func NewActionSuccess() ActionCore

NewActionSuccess returns action which always returns success.

type ActionLocalsContext

type ActionLocalsContext interface {
	CurrentLocals() api.PlanLocals

	Get(action api.Action, key api.PlanLocalKey) (string, bool)
	Add(key api.PlanLocalKey, value string, override bool) bool

	SetTime(key api.PlanLocalKey, t time.Time) bool
	GetTime(action api.Action, key api.PlanLocalKey) (time.Time, bool)

	BackoffExecution(action api.Action, key api.PlanLocalKey, duration time.Duration) bool
}

type ActionPVCResizeConfig

type ActionPVCResizeConfig struct {
	Concurrency int
}

func (*ActionPVCResizeConfig) Init

func (a *ActionPVCResizeConfig) Init(cmd *cobra.Command, section string) error

type ActionPlanAppender

type ActionPlanAppender interface {
	Action

	// ActionPlanAppender modify plan after action execution
	ActionPlanAppender(current api.Plan) (api.Plan, bool)
}

ActionPlanAppender modify plan after action execution

type ActionPost

type ActionPost interface {
	Action

	// Post execute after action is completed
	Post(ctx context.Context) error
}

ActionPost keep interface which is executed after action is completed.

type ActionPre

type ActionPre interface {
	Action

	// Pre execute after action is completed
	Pre(ctx context.Context) error
}

ActionPre keep interface which is executed before action is started.

type ActionProgressor

type ActionProgressor interface {
	// GetProgress returns progress of an action.
	GetProgress() string
	// SetProgress sets progress of an action.
	SetProgress(progress string)
}

ActionProgressor describe functions to follow a progress of an action.

type ActionReloadCachedStatus

type ActionReloadCachedStatus interface {
	Action

	// ReloadComponents return cache components to be reloaded
	ReloadComponents() (types.UID, []definitions.Component)
}

ActionReloadCachedStatus keeps information about CachedStatus reloading (executed after action has been executed)

type ActionStartFailureGracePeriod

type ActionStartFailureGracePeriod interface {
	Action

	// StartFailureGracePeriod returns information about failure grace period (defaults to 0)
	StartFailureGracePeriod() time.Duration
}

ActionStartFailureGracePeriod extend action definition to allow specifying start failure grace period

type ActionsConfig

type ActionsConfig struct {
	// PVCResize keeps configuration for action api.ActionTypePVCResize
	PVCResize ActionPVCResizeConfig
}
var ActionsConfigGlobal ActionsConfig

func (*ActionsConfig) Init

func (a *ActionsConfig) Init(cmd *cobra.Command) error

Init initializes all registered actions config options.

type Context

type Context interface {
	reconciler.DeploymentStatusUpdate
	reconciler.DeploymentAgencyMaintenance
	reconciler.DeploymentPodRenderer
	reconciler.DeploymentImageManager
	reconciler.ArangoAgencyGet
	reconciler.ArangoApplier
	reconciler.DeploymentInfoGetter
	reconciler.DeploymentDatabaseClient
	reconciler.KubernetesEventGenerator

	member.StateInspectorGetter

	sutil.ACSGetter

	// CreateMember adds a new member to the given group.
	// If ID is non-empty, it will be used, otherwise a new ID is created.
	// Returns ID, error
	CreateMember(ctx context.Context, group api.ServerGroup, id string, mods ...CreateMemberMod) (string, error)
	// DisableScalingCluster disables scaling DBservers and coordinators
	DisableScalingCluster(ctx context.Context) error
	// EnableScalingCluster enables scaling DBservers and coordinators
	EnableScalingCluster(ctx context.Context) error
	// GetBackup receives information about a backup resource
	GetBackup(ctx context.Context, backup string) (*backupApi.ArangoBackup, error)
	// GetAuthentication return authentication for members
	GetAuthentication() conn.Auth
}

Context provides methods to the reconcile package.

type CreateMemberMod

type CreateMemberMod func(s *api.DeploymentStatus, g api.ServerGroup, m *api.MemberStatus) error

type MemberRecreationConditionEvaluator

type MemberRecreationConditionEvaluator func(ctx context.Context,
	apiObject k8sutil.APIObject,
	spec api.DeploymentSpec, status api.DeploymentStatus,
	group api.ServerGroup, member api.MemberStatus,
	context PlanBuilderContext) (bool, string, error)

type Metrics

type Metrics struct {
	Rebalancer MetricsRebalancer
}

func (*Metrics) GetRebalancer

func (m *Metrics) GetRebalancer() *MetricsRebalancer

type MetricsRebalancer

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

func (*MetricsRebalancer) AddFailures

func (m *MetricsRebalancer) AddFailures(i int)

func (*MetricsRebalancer) AddMoves

func (m *MetricsRebalancer) AddMoves(moves int)

func (*MetricsRebalancer) AddSuccesses

func (m *MetricsRebalancer) AddSuccesses(i int)

func (*MetricsRebalancer) SetCurrent

func (m *MetricsRebalancer) SetCurrent(current int)

func (*MetricsRebalancer) SetEnabled

func (m *MetricsRebalancer) SetEnabled(enabled bool)

type PlanAppender

type PlanAppender interface {
	Apply(pb planBuilder) PlanAppender
	ApplyWithCondition(c planBuilderCondition, pb planBuilder) PlanAppender
	ApplySubPlan(pb planBuilderSubPlan, plans ...planBuilder) PlanAppender

	ApplyIfEmpty(pb planBuilder) PlanAppender
	ApplyWithConditionIfEmpty(c planBuilderCondition, pb planBuilder) PlanAppender
	ApplySubPlanIfEmpty(pb planBuilderSubPlan, plans ...planBuilder) PlanAppender

	ApplyWithBackOff(key api.BackOffKey, delay time.Duration, pb planBuilder) PlanAppender
	ApplyIfEmptyWithBackOff(key api.BackOffKey, delay time.Duration, pb planBuilder) PlanAppender

	BackOff() api.BackOff

	Plan() api.Plan
}

type PlanBuilderContext

PlanBuilderContext contains context methods provided to plan builders.

type RebalanceAction

type RebalanceAction struct {
	Database   string `json:"database"`
	Collection string `json:"collection"`

	Shard string `json:"shard"`
	From  string `json:"from"`
	To    string `json:"to"`

	DependsOn []int `json:"depends_on,omitempty"`
}

type RebalanceActions

type RebalanceActions []RebalanceAction

type Reconciler

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

Reconciler is the service that takes care of bring the a deployment in line with its (changed) specification.

func NewReconciler

func NewReconciler(namespace, name string, context Context) *Reconciler

NewReconciler creates a new reconciler with given context.

func (*Reconciler) CheckDeployment

func (r *Reconciler) CheckDeployment(ctx context.Context) error

CheckDeployment checks for obviously broken things and fixes them immediately

func (*Reconciler) CollectMetrics

func (r *Reconciler) CollectMetrics(m metrics.PushMetric)

func (*Reconciler) CreatePlan

func (d *Reconciler) CreatePlan(ctx context.Context) (error, bool)

CreatePlan considers the current specification & status of the deployment creates a plan to get the status in line with the specification. If a plan already exists, nothing is done.

func (*Reconciler) ExecutePlan

func (d *Reconciler) ExecutePlan(ctx context.Context) (bool, error)

ExecutePlan tries to execute the plan as far as possible. Returns true when it has to be called again soon. False otherwise.

func (*Reconciler) WrapLogger

func (r *Reconciler) WrapLogger(in *zerolog.Event) *zerolog.Event

type ScaleFilter

type ScaleFilter interface {
	Filter(in ScaleFilterFunc) ScaleFilter
	Select(in ScaleSelectFunc) ScaleFilter
	Get() (api.MemberStatus, error)
}

type ScaleFilterFunc

type ScaleFilterFunc func(context PlanBuilderContext, status api.DeploymentStatus, group api.ServerGroup, in api.MemberStatusList) (api.MemberStatusList, bool, error)

type ScaleSelectFunc

type ScaleSelectFunc func(context PlanBuilderContext, status api.DeploymentStatus, group api.ServerGroup, in api.MemberStatusList) (api.MemberStatus, bool, error)

type WithPlanBuilder

type WithPlanBuilder interface {
	Apply(p planBuilder) api.Plan
	ApplyWithCondition(c planBuilderCondition, p planBuilder) api.Plan
	ApplySubPlan(p planBuilderSubPlan, plans ...planBuilder) api.Plan
}

func NewWithPlanBuilder

func NewWithPlanBuilder(ctx context.Context, apiObject k8sutil.APIObject,
	spec api.DeploymentSpec, status api.DeploymentStatus,
	context PlanBuilderContext) WithPlanBuilder

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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