Skip to content

Commit 47d0a9b

Browse files
andrewlecuyerJonathan S. Katz
authored andcommitted
Allow Scaledown of Original Primary After Upgrade (#2891)
1 parent 9c91ffe commit 47d0a9b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

cmd/pgo-rmdata/process.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,16 @@ func Delete(request Request) {
5959
log.Error(err)
6060
}
6161
// delete the pgreplica CRD
62-
if err := request.Clientset.
63-
CrunchydataV1().Pgreplicas(request.Namespace).
62+
if err := request.Clientset.CrunchydataV1().Pgreplicas(request.Namespace).
6463
Delete(ctx, request.ReplicaName, metav1.DeleteOptions{}); err != nil {
65-
// If the name of the replica being deleted matches the scope for the cluster, then
66-
// we assume it was the original primary and the pgreplica deletion will fail with
67-
// a not found error. In this case we allow the rmdata process to continue despite
68-
// the error. This allows for the original primary to be scaled down once it is
69-
// is no longer a primary, and has become a replica.
70-
if !(request.ReplicaName == request.ClusterPGHAScope && kerror.IsNotFound(err)) {
64+
// if the pgreplica is not found, assume we're scaling down the original primary and
65+
// continue with removing the replica
66+
if !kerror.IsNotFound(err) {
7167
log.Error(err)
7268
return
69+
} else {
70+
log.Debug("pgreplica not found, assuming scale down of original primary")
7371
}
74-
log.Debug("replica name matches PGHA scope, assuming scale down of original primary" +
75-
"and therefore ignoring error attempting to delete nonexistent pgreplica")
7672
}
7773

7874
err = removeReplica(request)

0 commit comments

Comments
 (0)