instancecontroller

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceReadyTimeout                 = 120 * time.Minute
	DatabaseInstanceReadyTimeoutSeeded   = 30 * time.Minute
	DatabaseInstanceReadyTimeoutUnseeded = 60 * time.Minute // 60 minutes because it can take 50+ minutes to create an unseeded CDB

	DefaultStsPatchingTimeout = 25 * time.Minute
)
View Source
const (

	// StandbyReconcileInterval is the reconcile interval for a standby instance.
	StandbyReconcileInterval = time.Second * 60
)

Variables

View Source
var CheckStatusInstanceFunc = controllers.CheckStatusInstanceFunc

Functions

func AcquireInstanceMaintenanceLock

func AcquireInstanceMaintenanceLock(ctx context.Context, k8sClient client.Client, inst *v1alpha1.Instance, owner string) error

AcquireInstanceMaintenanceLock gives caller an exclusive maintenance access to the specified instance object. 'inst' points to an existing instance object (will be updated after the call) 'owner' identifies the owning controller e.g. 'instancecontroller' Convention: If the call succeeds the caller can safely assume that it has exclusive access now. If the call fails the caller needs to retry acquiring the lock.

Function is idempotent, caller can acquire the lock multiple times.

Note: The call will commit the instance object to k8s (with all changes), updating the supplied 'inst' object and making all other references stale.

func AgentSVC

func AgentSVC(inst v1alpha1.Instance) *corev1.Service

func CheckSinglePvc

func CheckSinglePvc(ctx context.Context, r client.Reader, key client.ObjectKey) error

check pvc spec

func CloneMap

func CloneMap(source map[string]string) map[string]string

func DbDaemonSVC

func DbDaemonSVC(inst v1alpha1.Instance) *corev1.Service

func FilterDiskWithSizeChanged

func FilterDiskWithSizeChanged(old, new []corev1.PersistentVolumeClaim, log logr.Logger) []*corev1.PersistentVolumeClaim

FilterDiskWithSizeChanged compare an old STS to a new STS and identify volumes that changed from old to new.

func InstanceLB

func InstanceLB(inst v1alpha1.Instance) *corev1.Service

func IsDeleting

func IsDeleting(instance *v1alpha1.Instance) bool

func IsPatchingStateMachineEntryCondition

func IsPatchingStateMachineEntryCondition(enabledServices map[commonv1alpha1.Service]bool, activeImages map[string]string, spImages map[string]string, lastFailedImages map[string]string, instanceReadyCond *v1.Condition, dbInstanceCond *v1.Condition) bool

func IsReadyWithObj

func IsReadyWithObj(sts *appsv1.StatefulSet) (ready bool, msg string)

IsReadyWithObj returns true if the statefulset has a non-zero number of desired replicas and has the same number of actual pods running and ready.

func IsStopped

func IsStopped(instance *v1alpha1.Instance) bool

func Patch

func Patch(ctx context.Context, cli client.Client, newCliObj client.Object, oldCliObj client.Object) error

Patch attempts to patch the given object.

func PvcsCanBeExpanded

func PvcsCanBeExpanded(ctx context.Context, r client.Reader, sts *appsv1.StatefulSet,
	pvcs []*corev1.PersistentVolumeClaim,
) error

pvcsCanBeExpanded checks all the pvcs has a storage class that can be expanded, and return an error if any one PVC cannot be expanded.

func ReleaseInstanceMaintenanceLock

func ReleaseInstanceMaintenanceLock(ctx context.Context, k8sClient client.Client, inst *v1alpha1.Instance, owner string) error

ReleaseInstanceMaintenanceLock releases exclusive maintenance access to the specified instance object. 'inst' points to an existing instance object (will be updated after the call) 'owner' identifies the owning controller e.g. 'instancecontroller' Convention: If the call succeeds the caller can safely assume that lock was released. If the call fails the caller needs to retry releasing the lock.

Call is idempotent, caller can release it multiple times. If caller's not owning the lock the call will return success without affecting the ownership.

Note: The call will commit the instance object to k8s (with all changes), updating the supplied 'inst' object and making all other references stale.

Types

type InstanceReconciler

type InstanceReconciler struct {
	client.Client
	Log           logr.Logger
	SchemeVal     *runtime.Scheme
	Images        map[string]string
	Recorder      record.EventRecorder
	InstanceLocks *sync.Map

	DatabaseClientFactory controllers.DatabaseClientFactory
}

InstanceReconciler reconciles an Instance object.

func (*InstanceReconciler) Reconcile

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

func (*InstanceReconciler) Scheme

func (r *InstanceReconciler) Scheme() *runtime.Scheme

func (*InstanceReconciler) SetupWithManager

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

Jump to

Keyboard shortcuts

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