Skip to content

Commit 3effe3b

Browse files
authored
Merge pull request #7 from aboutbits/ab-449-fix-flaky-tests-and-properly-clean-up-resources
AB-449 Fix flaky tests and properly clean up resources
2 parents e1f7fc9 + 958e0f0 commit 3effe3b

33 files changed

+487
-253
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
build-and-release:
2626
needs: test
2727
runs-on: ubuntu-24.04
28-
timeout-minutes: 15
28+
timeout-minutes: 5
2929
steps:
3030
- uses: actions/checkout@v6
3131
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
name: Tests (PostgreSQL ${{ matrix.postgres-version }})
99
runs-on: ubuntu-24.04
10-
timeout-minutes: 5
10+
timeout-minutes: 10
1111
strategy:
1212
fail-fast: false
1313
matrix:

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ checkstyle = "13.0.0"
1919
datafaker = "2.5.3"
2020
errorProne = "2.46.0"
2121
errorPronePlugin = "4.4.0"
22-
nullAway = "0.13.0"
22+
nullAway = "0.13.1"
2323

2424
[plugins]
2525
# https://github.com/allegro/axion-release-plugin

operator/src/main/java/it/aboutbits/postgresql/core/ClusterReference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class ClusterReference {
1414
@Required
1515
@ValidationRule(
16-
value = "self.size() > 0",
16+
value = "self.trim().size() > 0",
1717
message = "The ClusterReference name must not be empty."
1818
)
1919
private String name = "";

operator/src/main/java/it/aboutbits/postgresql/core/SecretRef.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class SecretRef {
1414
@Required
1515
@ValidationRule(
16-
value = "self.size() > 0",
16+
value = "self.trim().size() > 0",
1717
message = "The SecretRef name must not be empty."
1818
)
1919
private String name = "";

operator/src/main/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionReconciler.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ public UpdateControl<ClusterConnection> reconcile(
2626
) {
2727
var status = initializeStatus(resource);
2828

29+
var name = resource.getMetadata().getName();
30+
var namespace = resource.getMetadata().getNamespace();
31+
32+
log.info(
33+
"Reconciling ClusterConnection [resource={}/{}, status.phase={}]",
34+
namespace,
35+
name,
36+
status.getPhase()
37+
);
38+
2939
try (var dsl = contextFactory.getDSLContext(resource)) {
3040
var version = dsl.fetchSingle("select version()").into(String.class);
3141

operator/src/main/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionSpec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public class ClusterConnectionSpec {
1919
@Required
2020
@ValidationRule(
21-
value = "self.size() > 0",
21+
value = "self.trim().size() > 0",
2222
message = "The ClusterConnection host must not be empty."
2323
)
2424
private String host = "";
@@ -30,7 +30,7 @@ public class ClusterConnectionSpec {
3030

3131
@Required
3232
@ValidationRule(
33-
value = "self.size() > 0",
33+
value = "self.trim().size() > 0",
3434
message = "The ClusterConnection database must not be empty."
3535
)
3636
private String database = "postgres";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public DeleteControl cleanup(
119119
context.getClient().resource(resource).patchStatus();
120120

121121
return DeleteControl.noFinalizerRemoval()
122-
.rescheduleAfter(1, TimeUnit.SECONDS);
122+
.rescheduleAfter(100, TimeUnit.MILLISECONDS);
123123
}
124124

125125
// 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/database/DatabaseSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class DatabaseSpec {
2222
message = "The Database name is immutable. Allowing to rename the Database name using 'alter database <old_name> rename to <new_name>' would add unwanted side-effects to the Operator."
2323
)
2424
@ValidationRule(
25-
value = "self.size() > 0",
25+
value = "self.trim().size() > 0",
2626
message = "The Database name must not be empty."
2727
)
2828
private String name = "";

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public DeleteControl cleanup(
141141
context.getClient().resource(resource).patchStatus();
142142

143143
return DeleteControl.noFinalizerRemoval()
144-
.rescheduleAfter(1, TimeUnit.SECONDS);
144+
.rescheduleAfter(100, TimeUnit.MILLISECONDS);
145145
}
146146

147147
var clusterRef = spec.getClusterRef();
@@ -164,9 +164,10 @@ public DeleteControl cleanup(
164164
.rescheduleAfter(60, TimeUnit.SECONDS);
165165
}
166166

167+
var database = spec.getDatabase();
167168
var clusterConnection = clusterConnectionOptional.get();
168169

169-
try (var dsl = contextFactory.getDSLContext(clusterConnection)) {
170+
try (var dsl = contextFactory.getDSLContext(clusterConnection, database)) {
170171
dsl.transaction(cfg -> {
171172
var tx = cfg.dsl();
172173

0 commit comments

Comments
 (0)