Skip to content

Commit b4f4dc8

Browse files
committed
fix CRD cleanup method having issues with PATCH status as the resourceVersion is not synchronized in the operator primary cache
1 parent 867633f commit b4f4dc8

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

operator/src/main/java/it/aboutbits/postgresql/crd/database/DatabaseReconciler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ public DeleteControl cleanup(
117117
}
118118

119119
context.getClient().resource(resource).patchStatus();
120+
121+
return DeleteControl.noFinalizerRemoval()
122+
.rescheduleAfter(1, TimeUnit.SECONDS);
120123
}
121124

122125
// We do not actually delete the database if the reclaimPolicy is set to RETAIN, we only delete the CR instance

operator/src/main/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilegeReconciler.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ public DeleteControl cleanup(
136136
.setMessage("DefaultPrivilege deletion in progress");
137137

138138
context.getClient().resource(resource).patchStatus();
139+
140+
return DeleteControl.noFinalizerRemoval()
141+
.rescheduleAfter(1, TimeUnit.SECONDS);
139142
}
140143

141144
var clusterRef = spec.getClusterRef();
@@ -166,11 +169,13 @@ public DeleteControl cleanup(
166169

167170
var currentDefaultPrivileges = defaultPrivilegeService.determineCurrentDefaultPrivileges(tx, spec);
168171

169-
defaultPrivilegeService.revoke(
170-
tx,
171-
spec,
172-
currentDefaultPrivileges
173-
);
172+
if (!currentDefaultPrivileges.isEmpty()) {
173+
defaultPrivilegeService.revoke(
174+
tx,
175+
spec,
176+
currentDefaultPrivileges
177+
);
178+
}
174179
});
175180

176181
return DeleteControl.defaultDelete();

operator/src/main/java/it/aboutbits/postgresql/crd/grant/GrantReconciler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ public DeleteControl cleanup(
141141
.setMessage("Grant deletion in progress");
142142

143143
context.getClient().resource(resource).patchStatus();
144+
145+
return DeleteControl.noFinalizerRemoval()
146+
.rescheduleAfter(1, TimeUnit.SECONDS);
144147
}
145148

146149
var clusterRef = spec.getClusterRef();

operator/src/main/java/it/aboutbits/postgresql/crd/role/RoleReconciler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public DeleteControl cleanup(
147147
.setMessage("Role deletion in progress");
148148

149149
context.getClient().resource(resource).patchStatus();
150+
151+
return DeleteControl.noFinalizerRemoval()
152+
.rescheduleAfter(1, TimeUnit.SECONDS);
150153
}
151154

152155
var clusterRef = spec.getClusterRef();

operator/src/main/java/it/aboutbits/postgresql/crd/schema/SchemaReconciler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public DeleteControl cleanup(
119119
}
120120

121121
context.getClient().resource(resource).patchStatus();
122+
123+
return DeleteControl.noFinalizerRemoval()
124+
.rescheduleAfter(1, TimeUnit.SECONDS);
122125
}
123126

124127
// We do not actually delete the schema if the reclaimPolicy is set to RETAIN, we only delete the CR instance

0 commit comments

Comments
 (0)