Documentation
¶
Overview ¶
Package controller contains the function in PGK that reacts to events in the cluster.
Index ¶
- Variables
- type InstanceReconciler
- func (r *InstanceReconciler) GetClient() ctrl.Client
- func (r *InstanceReconciler) GetCluster(ctx context.Context) (*apiv1.Cluster, error)
- func (r *InstanceReconciler) GetExecutedCondition() *concurrency.Executed
- func (r *InstanceReconciler) GetSecret(ctx context.Context, name string) (*corev1.Secret, error)
- func (r *InstanceReconciler) Instance() *postgres.Instance
- func (r *InstanceReconciler) IsDBUp(ctx context.Context) error
- func (r *InstanceReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
- func (r *InstanceReconciler) RefreshSecrets(ctx context.Context, cluster *apiv1.Cluster) bool
Constants ¶
This section is empty.
Variables ¶
var RetryUntilWalReceiverDown = wait.Backoff{ Duration: 1 * time.Second, Steps: math.MaxInt32, }
RetryUntilWalReceiverDown is the default retry configuration that is used to wait for the WAL receiver process to be down
Functions ¶
This section is empty.
Types ¶
type InstanceReconciler ¶
type InstanceReconciler struct {
// contains filtered or unexported fields
}
InstanceReconciler can reconcile the status of the PostgreSQL cluster with the one of this PostgreSQL instance. Also the configuration in the ConfigMap is applied when needed
func NewInstanceReconciler ¶
func NewInstanceReconciler( instance *postgres.Instance, client ctrl.Client, server *metricserver.MetricsServer, ) *InstanceReconciler
NewInstanceReconciler creates a new instance reconciler
func (*InstanceReconciler) GetClient ¶
func (r *InstanceReconciler) GetClient() ctrl.Client
GetClient returns the dynamic client that is being used for a certain reconciler
func (*InstanceReconciler) GetCluster ¶
GetCluster gets the managed cluster through the client
func (*InstanceReconciler) GetExecutedCondition ¶
func (r *InstanceReconciler) GetExecutedCondition() *concurrency.Executed
GetExecutedCondition returns the condition that can be checked in order to be sure initialization has been done
func (*InstanceReconciler) Instance ¶
func (r *InstanceReconciler) Instance() *postgres.Instance
Instance get the PostgreSQL instance that this reconciler is working on
func (*InstanceReconciler) IsDBUp ¶
func (r *InstanceReconciler) IsDBUp(ctx context.Context) error
IsDBUp checks whether the superuserdb is reachable and returns an error if that's not the case
func (*InstanceReconciler) Reconcile ¶
func (r *InstanceReconciler) Reconcile( ctx context.Context, request reconcile.Request, ) (reconcile.Result, error)
Reconcile is the main reconciliation loop for the instance TODO this function needs to be refactor
func (*InstanceReconciler) RefreshSecrets ¶
RefreshSecrets is called when the PostgreSQL secrets are changed and will refresh the contents of the file inside the Pod, without reloading the actual PostgreSQL instance.
It returns a boolean flag telling if something changed. Usually the invoker will check that flag and reload the PostgreSQL instance it is up.
This function manages its own errors by logging them, so the user cannot easily tell if the operation has been done completely. The rationale behind this is:
when invoked at the startup of the instance manager, PostgreSQL is not up. If this raise an error, then PostgreSQL won't be able to start correctly (TLS certs are missing, i.e.), making no difference between returning an error or not
when invoked inside the reconciliation loop, if the operation raise an error, it's pointless to retry. The only way to recover from such an error is wait for the CNPG operator to refresh the resource version of the secrets to be used, and in that case a reconciliation loop will be started again.