Skip to content

Commit 0a95e22

Browse files
committed
fix: SGScript and SGCluster script entry version are resetted to 0 if part of a reconciliation of another CR
1 parent 1e33760 commit 0a95e22

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

stackgres-k8s/src/operator/src/main/java/io/stackgres/operator/conciliation/factory/shardedcluster/StackGresShardedClusterForCitusUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ static StackGresScript getCoordinatorScript(
201201
.build())
202202
.editSpec()
203203
.withScripts(
204-
getCitusUpdateShardsScript(context))
204+
getCitusUpdateShardsScript(context, 0))
205205
.endSpec()
206206
.build();
207207
}
208208

209209
private static StackGresScriptEntry getCitusUpdateShardsScript(
210-
StackGresShardedClusterContext context) {
210+
StackGresShardedClusterContext context, int id) {
211211
StackGresShardedCluster cluster = context.getShardedCluster();
212212
final StackGresScriptEntry script = new StackGresScriptEntryBuilder()
213-
.withId(0)
213+
.withId(id)
214214
.withName("citus-update-shards")
215215
.withRetryOnError(true)
216216
.withDatabase(cluster.getSpec().getDatabase())

stackgres-k8s/src/operator/src/main/java/io/stackgres/operator/conciliation/factory/shardedcluster/StackGresShardedClusterForShardingSphereUtil.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ static StackGresScript getCoordinatorScript(
246246
.build())
247247
.editSpec()
248248
.withScripts(
249-
getShardingSphereCreateDatabaseScript(context),
250-
getShardingSphereInitScript(context),
251-
getShardingSphereUpdateShardsScript(context))
249+
getShardingSphereCreateDatabaseScript(context, 0),
250+
getShardingSphereInitScript(context, 1),
251+
getShardingSphereUpdateShardsScript(context, 2))
252252
.endSpec()
253253
.build();
254254
}
@@ -264,15 +264,16 @@ static StackGresScript getShardsScript(
264264
.build())
265265
.editSpec()
266266
.withScripts(
267-
getShardingSphereCreateDatabaseScript(context))
267+
getShardingSphereCreateDatabaseScript(context, 0))
268268
.endSpec()
269269
.build();
270270
}
271271

272272
private static StackGresScriptEntry getShardingSphereCreateDatabaseScript(
273-
StackGresShardedClusterContext context) {
273+
StackGresShardedClusterContext context, int id) {
274274
StackGresShardedCluster cluster = context.getShardedCluster();
275275
final StackGresScriptEntry script = new StackGresScriptEntryBuilder()
276+
.withId(id)
276277
.withName("shardingsphere-create-database")
277278
.withRetryOnError(true)
278279
.withScript(Unchecked.supplier(() -> Resources
@@ -286,9 +287,10 @@ private static StackGresScriptEntry getShardingSphereCreateDatabaseScript(
286287
}
287288

288289
private static StackGresScriptEntry getShardingSphereInitScript(
289-
StackGresShardedClusterContext context) {
290+
StackGresShardedClusterContext context, int id) {
290291
StackGresShardedCluster cluster = context.getShardedCluster();
291292
final StackGresScriptEntry script = new StackGresScriptEntryBuilder()
293+
.withId(id)
292294
.withName("shardingsphere-init")
293295
.withRetryOnError(true)
294296
.withDatabase(cluster.getSpec().getDatabase())
@@ -328,9 +330,10 @@ static Secret getInitSecret(
328330
}
329331

330332
private static StackGresScriptEntry getShardingSphereUpdateShardsScript(
331-
StackGresShardedClusterContext context) {
333+
StackGresShardedClusterContext context, int id) {
332334
StackGresShardedCluster cluster = context.getShardedCluster();
333335
final StackGresScriptEntry script = new StackGresScriptEntryBuilder()
336+
.withId(id)
334337
.withName("shardingsphere-update-shards")
335338
.withRetryOnError(true)
336339
.withDatabase(cluster.getSpec().getDatabase())

0 commit comments

Comments
 (0)