Documentation
¶
Index ¶
- type Action
- func NewAddMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewCleanOutMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewRemoveMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewRenewTLSCACertificateAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewRenewTLSCertificateAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewRotateMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewSetCurrentImageAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewShutdownMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewUpgradeMemberAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- func NewWaitForMemberUpAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
- type ActionContext
- type Context
- type PlanBuilderContext
- type Reconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action 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) // Timeout returns the amount of time after which this action will timeout. Timeout() time.Duration // Return the MemberID used / created in this action MemberID() string }
Action executes a single Plan item.
func NewAddMemberAction ¶
NewAddMemberAction creates a new Action that implements the given planned AddMember action.
func NewCleanOutMemberAction ¶
NewCleanOutMemberAction creates a new Action that implements the given planned CleanOutMember action.
func NewRemoveMemberAction ¶
NewRemoveMemberAction creates a new Action that implements the given planned RemoveMember action.
func NewRenewTLSCACertificateAction ¶
func NewRenewTLSCACertificateAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
NewRenewTLSCACertificateAction creates a new Action that implements the given planned RenewTLSCACertificate action.
func NewRenewTLSCertificateAction ¶
func NewRenewTLSCertificateAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
NewRenewTLSCertificateAction creates a new Action that implements the given planned RenewTLSCertificate action.
func NewRotateMemberAction ¶
NewRotateMemberAction creates a new Action that implements the given planned RotateMember action.
func NewSetCurrentImageAction ¶
func NewSetCurrentImageAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
NewSetCurrentImageAction creates a new Action that implements the given planned SetCurrentImage action.
func NewShutdownMemberAction ¶
NewShutdownMemberAction creates a new Action that implements the given planned ShutdownMember action.
func NewUpgradeMemberAction ¶
NewUpgradeMemberAction creates a new Action that implements the given planned UpgradeMember action.
func NewWaitForMemberUpAction ¶
func NewWaitForMemberUpAction(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action
NewWaitForMemberUpAction creates a new Action that implements the given planned WaitForMemberUp action.
type ActionContext ¶
type ActionContext interface { // Gets the specified mode of deployment GetMode() api.DeploymentMode // 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) // GetServerClient returns a cached client for a specific server. GetServerClient(ctx context.Context, group api.ServerGroup, id string) (driver.Client, error) // GetAgencyClients returns a client connection for every agency member. GetAgencyClients(ctx context.Context) ([]driver.Connection, error) // GetAgency returns a connection to the entire agency. GetAgency(ctx context.Context) (agency.Agency, error) // GetSyncServerClient returns a cached client for a specific arangosync server. GetSyncServerClient(ctx context.Context, group api.ServerGroup, id string) (client.API, error) // 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) // 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(group api.ServerGroup, id string) (string, error) // UpdateMember updates the deployment status wrt the given member. UpdateMember(member api.MemberStatus) error // RemoveMemberByID removes a member with given id. RemoveMemberByID(id string) 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 // RemovePodFinalizers removes all the finalizers from the Pod with given name in the namespace // of the deployment. If the pod does not exist, the error is ignored. RemovePodFinalizers(podName string) error // DeleteTLSKeyfile removes the Secret containing the TLS keyfile for the given member. // If the secret does not exist, the error is ignored. DeleteTLSKeyfile(group api.ServerGroup, member api.MemberStatus) error // DeleteTLSCASecret removes the Secret containing the TLS CA certificate. DeleteTLSCASecret() error // GetImageInfo returns the image info for an image with given name. // Returns: (info, infoFound) GetImageInfo(imageName string) (api.ImageInfo, bool) // SetCurrentImage changes the CurrentImage field in the deployment // status to the given image. SetCurrentImage(imageInfo api.ImageInfo) error }
ActionContext provides methods to the Action implementations to control their context.
type Context ¶
type Context interface { // GetAPIObject returns the deployment as k8s object. GetAPIObject() k8sutil.APIObject // 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 // 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) // GetServerClient returns a cached client for a specific server. GetServerClient(ctx context.Context, group api.ServerGroup, id string) (driver.Client, error) // GetAgencyClients returns a client connection for every agency member. // If the given predicate is not nil, only agents are included where the given predicate returns true. GetAgencyClients(ctx context.Context, predicate func(id string) bool) ([]driver.Connection, error) // GetAgency returns a connection to the entire agency. GetAgency(ctx context.Context) (agency.Agency, error) // GetSyncServerClient returns a cached client for a specific arangosync server. GetSyncServerClient(ctx context.Context, group api.ServerGroup, id string) (client.API, error) // CreateEvent creates a given event. // On error, the error is logged. CreateEvent(evt *k8sutil.Event) // 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(group api.ServerGroup, id string) (string, 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 // RemovePodFinalizers removes all the finalizers from the Pod with given name in the namespace // of the deployment. If the pod does not exist, the error is ignored. RemovePodFinalizers(podName string) error // GetOwnedPods returns a list of all pods owned by the deployment. GetOwnedPods() ([]v1.Pod, error) // GetPvc gets a PVC by the given name, in the samespace of the deployment. GetPvc(pvcName string) (*v1.PersistentVolumeClaim, error) // GetTLSKeyfile returns the keyfile encoded TLS certificate+key for // the given member. GetTLSKeyfile(group api.ServerGroup, member api.MemberStatus) (string, error) // DeleteTLSKeyfile removes the Secret containing the TLS keyfile for the given member. // If the secret does not exist, the error is ignored. DeleteTLSKeyfile(group api.ServerGroup, member api.MemberStatus) error // GetTLSCA returns the TLS CA certificate in the secret with given name. // Returns: publicKey, privateKey, ownerByDeployment, error GetTLSCA(secretName string) (string, string, bool, error) // DeleteSecret removes the Secret with given name. // If the secret does not exist, the error is ignored. DeleteSecret(secretName string) error // GetExpectedPodArguments creates command line arguments for a server in the given group with given ID. GetExpectedPodArguments(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup, agents api.MemberStatusList, id string) []string }
Context provides methods to the reconcile package.
type PlanBuilderContext ¶
type PlanBuilderContext interface { // GetTLSKeyfile returns the keyfile encoded TLS certificate+key for // the given member. GetTLSKeyfile(group api.ServerGroup, member api.MemberStatus) (string, error) // GetTLSCA returns the TLS CA certificate in the secret with given name. // Returns: publicKey, privateKey, ownerByDeployment, error GetTLSCA(secretName string) (string, string, bool, error) // CreateEvent creates a given event. // On error, the error is logged. CreateEvent(evt *k8sutil.Event) // GetPvc gets a PVC by the given name, in the samespace of the deployment. GetPvc(pvcName string) (*v1.PersistentVolumeClaim, error) // GetExpectedPodArguments creates command line arguments for a server in the given group with given ID. GetExpectedPodArguments(apiObject metav1.Object, deplSpec api.DeploymentSpec, group api.ServerGroup, agents api.MemberStatusList, id string) []string }
PlanBuilderContext contains context methods provided to plan builders.
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(log zerolog.Logger, context Context) *Reconciler
NewReconciler creates a new reconciler with given context.
func (*Reconciler) CreatePlan ¶
func (d *Reconciler) CreatePlan() error
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.
Source Files
¶
- action.go
- action_add_member.go
- action_cleanout_member.go
- action_context.go
- action_remove_member.go
- action_renew_tls_ca_certificate.go
- action_renew_tls_certificate.go
- action_rotate_member.go
- action_shutdown_member.go
- action_upgrade_current_image.go
- action_upgrade_member.go
- action_wait_for_member_up.go
- context.go
- errors.go
- plan_builder.go
- plan_builder_context.go
- plan_builder_storage.go
- plan_builder_tls.go
- plan_executor.go
- reconciler.go
- timeouts.go