Skip to content

Commit 1ea7e77

Browse files
Allow Scaledown of Original Primary After Upgrade (#2891)
1 parent aaa283a commit 1ea7e77

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

cmd/pgo-rmdata/process.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,15 @@ func Delete(request Request) error {
7070
log.Error(err)
7171
}
7272
// delete the pgreplica CRD
73-
if err := request.Clientset.
74-
CrunchydataV1().Pgreplicas(request.Namespace).
73+
if err := request.Clientset.CrunchydataV1().Pgreplicas(request.Namespace).
7574
Delete(ctx, request.ReplicaName, metav1.DeleteOptions{}); err != nil {
76-
// If the name of the replica being deleted matches the scope for the cluster, then
77-
// we assume it was the original primary and the pgreplica deletion will fail with
78-
// a not found error. In this case we allow the rmdata process to continue despite
79-
// the error. This allows for the original primary to be scaled down once it is
80-
// is no longer a primary, and has become a replica.
81-
if !(request.ReplicaName == request.ClusterPGHAScope && kerror.IsNotFound(err)) {
75+
// if the pgreplica is not found, assume we're scaling down the original primary and
76+
// continue with removing the replica
77+
if !kerror.IsNotFound(err) {
8278
log.Error(err)
83-
return nil
79+
} else {
80+
log.Debug("pgreplica not found, assuming scale down of original primary")
8481
}
85-
log.Debug("replica name matches PGHA scope, assuming scale down of original primary" +
86-
"and therefore ignoring error attempting to delete nonexistent pgreplica")
8782
}
8883

8984
err = removeReplica(request)

0 commit comments

Comments
 (0)