PGDGroup parting v1

Deletion and finalizers

When deleting a PGD Group, the operator will start parting every node in the group first. It will connect to an active instance and part every node in the target group. Once a node is parted, it will not participate in replication and consensus operations. To make sure the node is correctly parted before being deleted, the operator uses the k8s.pgd.enterprisedb.io/partNodes finalizer. Please refer to the kubernetes document on finalizers for context.

Note

If a namespace holding a PGD Group is deleted directly, we can't ensure the deleting and parting sequence is carried out correctly. Before deleting a namespace, it is recommended to delete all the contained PGD groups.

Time limit

When parting a node, the operator needs to connect to an active instance to execute the bdr.part_node function. To avoid this operation hanging, a time limit for the finalizer is used; by default, it is 300 seconds. After the time limit expires, the finalizer will be removed, and the node will be deleted anyway, potentially leaving stale metadata in the global PGD catalog. This time limit can be configured through spec.failingFinalizerTimeLimitSeconds, which is specified in seconds.

Skip finalizer

For testing purposes only, the operator also provides an annotation to skip the finalizer: k8s.pgd.enterprisedb.io/noFinalizers. When this annotation is added to a PGDGroup, the finalizer will be skipped when the PGDGroup is being deleted, and the nodes will not be parted from the PGD cluster.

PGDGroup cleanup

Cleanup parted node

Once the PGDGroup is deleted, its metadata will remain in the catalog in PARTED state in the bdr.node_summary table. The PGD4K operator defines a CRD named PGDGroupCleanup to help clean up the PARTED PGDGroup.

In the example below, the PGDGroupCleanup executes locally from region-a, and will clean up all of region-b, with the pre-requisite that all the nodes must be in the PARTED state.

apiVersion: pgd.k8s.enterprisedb.io/v1beta1
kind: PGDGroupCleanup
metadata:
  name: region-b-cleanup
spec:
  executor: region-a
  target: region-b

Please note that if the target group (region-b in the example) contains nodes not in a PARTED state, the Group Cleanup will stop in phase PGDGroupCleanup - Target PGDGroup is not parted, waiting for it to be parted before executing PGDGroupCleanup. In cases of extreme need, we can add the force option.

Warning

Using force can leave the PGD cluster in an inconsistent state. Use it only to recover from failures in which you can't part the group nodes any other way.

apiVersion: pgd.k8s.enterprisedb.io/v1beta1
kind: PGDGroupCleanup
metadata:
  name: region-b-cleanup
spec:
  force: true
  executor: region-a
  target: region-b