resources

package
v0.0.0-...-d3ccc4f Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	// GetAPIObject returns the deployment as k8s object.
	GetAPIObject() k8sutil.APIObject
	// GetServerGroupIterator returns the deployment as ServerGroupIterator.
	GetServerGroupIterator() ServerGroupIterator
	// GetSpec returns the current specification of the deployment
	GetSpec() api.DeploymentSpec
	// GetStatus returns the current status of the deployment
	GetStatus() (api.DeploymentStatus, int32)
	// UpdateStatus replaces the status of the deployment with the given status and
	// updates the resources in k8s.
	UpdateStatus(status api.DeploymentStatus, lastVersion int32, force ...bool) error
	// GetKubeCli returns the kubernetes client
	GetKubeCli() kubernetes.Interface
	// GetLifecycleImage returns the image name containing the lifecycle helper (== name of operator image)
	GetLifecycleImage() string
	// GetAlpineImage returns the image name containing the alpine environment
	GetAlpineImage() string
	// GetNamespace returns the namespace that contains the deployment
	GetNamespace() string
	// CreateEvent creates a given event.
	// On error, the error is logged.
	CreateEvent(evt *k8sutil.Event)
	// GetOwnedPods returns a list of all pods owned by the deployment.
	GetOwnedPods() ([]v1.Pod, error)
	// GetOwnedPVCs returns a list of all PVCs owned by the deployment.
	GetOwnedPVCs() ([]v1.PersistentVolumeClaim, error)
	// CleanupPod deletes a given pod with force and explicit UID.
	// If the pod does not exist, the error is ignored.
	CleanupPod(p v1.Pod) error
	// DeletePod deletes a pod with given name in the namespace
	// of the deployment. If the pod does not exist, the error is ignored.
	DeletePod(podName string) error
	// DeletePvc deletes a persistent volume claim with given name in the namespace
	// of the deployment. If the pvc does not exist, the error is ignored.
	DeletePvc(pvcName string) error
	// GetAgencyClients returns a client connection for every agency member.
	GetAgencyClients(ctx context.Context, predicate func(memberID string) bool) ([]driver.Connection, error)
	// GetDatabaseClient returns a cached client for the entire database (cluster coordinators or single server),
	// creating one if needed.
	GetDatabaseClient(ctx context.Context) (driver.Client, error)
}

Context provides all functions needed by the Resources service to perform its service.

type Resources

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

Resources is a service that creates low level resources for members and inspects low level resources, put the inspection result in members.

func NewResources

func NewResources(log zerolog.Logger, context Context) *Resources

NewResources creates a new Resources service, used to create and inspect low level resources such as pods and services.

func (*Resources) CleanupRemovedMembers

func (r *Resources) CleanupRemovedMembers() error

CleanupRemovedMembers removes all arangod members that are no longer part of ArangoDB deployment.

func (*Resources) CleanupTerminatedPods

func (r *Resources) CleanupTerminatedPods() (util.Interval, error)

CleanupTerminatedPods removes all pods in Terminated state that belong to a member in Created state. Returns: Interval_till_next_inspection, error

func (*Resources) EnsurePVCs

func (r *Resources) EnsurePVCs() error

EnsurePVCs creates all PVC's listed in member status

func (*Resources) EnsurePods

func (r *Resources) EnsurePods() error

EnsurePods creates all Pods listed in member status

func (*Resources) EnsureSecrets

func (r *Resources) EnsureSecrets() error

EnsureSecrets creates all secrets needed to run the given deployment

func (*Resources) EnsureServices

func (r *Resources) EnsureServices() error

EnsureServices creates all services needed to service the deployment

func (*Resources) GetExpectedPodArguments

func (r *Resources) GetExpectedPodArguments(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup,
	agents api.MemberStatusList, id string) []string

GetExpectedPodArguments creates command line arguments for a server in the given group with given ID.

func (*Resources) InspectPVCs

func (r *Resources) InspectPVCs(ctx context.Context) (util.Interval, error)

InspectPVCs lists all PVCs that belong to the given deployment and updates the member status of the deployment accordingly.

func (*Resources) InspectPods

func (r *Resources) InspectPods(ctx context.Context) (util.Interval, error)

InspectPods lists all pods that belong to the given deployment and updates the member status of the deployment accordingly. Returns: Interval_till_next_inspection, error

func (*Resources) RunDeploymentHealthLoop

func (r *Resources) RunDeploymentHealthLoop(stopCh <-chan struct{})

RunDeploymentHealthLoop creates a loop to fetch the health of the deployment. The loop ends when the given channel is closed.

func (*Resources) ValidateSecretHashes

func (r *Resources) ValidateSecretHashes() error

ValidateSecretHashes checks the hash of used secrets against the stored ones. If a hash is different, the deployment is marked with a SecretChangedCondition and the operator will no touch it until this is resolved.

type ServerGroupIterator

type ServerGroupIterator interface {
	// ForeachServerGroup calls the given callback for all server groups.
	// If the callback returns an error, this error is returned and no other server
	// groups are processed.
	// Groups are processed in this order: agents, single, dbservers, coordinators, syncmasters, syncworkers
	ForeachServerGroup(cb func(group api.ServerGroup, spec api.ServerGroupSpec, status *api.MemberStatusList) error, status *api.DeploymentStatus) error
}

ServerGroupIterator provides a helper to callback on every server group of the deployment.

Jump to

Keyboard shortcuts

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