You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by wm...@apache.org on 2026/01/11 13:37:26 UTC
(incubator-kie-tools) branch main updated: incubator-kie-tools-3389: SonataFlow operator generates wrong hibernate schema initialization option for the data-index-postgresql deployments (#3390)
This is an automated email from the ASF dual-hosted git repository.
wmedvedeo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new 2f55fa130d3 incubator-kie-tools-3389: SonataFlow operator generates wrong hibernate schema initialization option for the data-index-postgresql deployments (#3390)
2f55fa130d3 is described below
commit 2f55fa130d31653e2415659c3d7ccb0bf8e36ba4
Author: Walter Medvedeo <wm...@gmail.com>
AuthorDate: Sun Jan 11 14:37:23 2026 +0100
incubator-kie-tools-3389: SonataFlow operator generates wrong hibernate schema initialization option for the data-index-postgresql deployments (#3390)
---
.../src/main/resources/application.properties | 3 +-
.../controller/platform/db_migrator_job.go | 154 ++++++++++++---------
.../controller/platform/services/services.go | 12 +-
3 files changed, 96 insertions(+), 73 deletions(-)
diff --git a/packages/kogito-db-migrator-tool/src/main/resources/application.properties b/packages/kogito-db-migrator-tool/src/main/resources/application.properties
index 1f38fe58149..74904db779e 100644
--- a/packages/kogito-db-migrator-tool/src/main/resources/application.properties
+++ b/packages/kogito-db-migrator-tool/src/main/resources/application.properties
@@ -23,7 +23,8 @@ quarkus.datasource.dataindex.db-kind=postgresql
quarkus.datasource.dataindex.username=postgres
quarkus.datasource.dataindex.password=postgres
quarkus.datasource.dataindex.jdbc.url=jdbc:postgresql://localhost:5432/postgres
-quarkus.flyway.dataindex.locations=classpath:postgresql/data-index,classpath:postgresql/persistence-commons
+quarkus.flyway.dataindex.ignore-migration-patterns=versioned:missing
+quarkus.flyway.dataindex.locations=classpath:postgresql/data-index
quarkus.flyway.dataindex.schemas=data-index-service
quarkus.flyway.dataindex.migrate-at-start=false
quarkus.flyway.dataindex.clean-at-start=false
diff --git a/packages/sonataflow-operator/internal/controller/platform/db_migrator_job.go b/packages/sonataflow-operator/internal/controller/platform/db_migrator_job.go
index 5b26c1df59c..a045197cce5 100644
--- a/packages/sonataflow-operator/internal/controller/platform/db_migrator_job.go
+++ b/packages/sonataflow-operator/internal/controller/platform/db_migrator_job.go
@@ -80,6 +80,8 @@ const (
quarkusDataSourceJobsServiceUserName = "QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME"
quarkusDataSourceJobsServicePassword = "QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD"
quarkusFlywayJobsServiceSchemas = "QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS"
+ defaultPostgreSqlUserKey = "POSTGRESQL_USER"
+ defaultPostgreSqlPassworkdKey = "POSTGRESQL_PASSWORD"
)
type DBMigrationJobCfg struct {
@@ -106,8 +108,14 @@ func getQuarkusDSFromServicePersistence(platform *operatorapi.SonataFlowPlatform
env := persistence.ConfigurePostgreSQLEnv(persistenceOptionsSpec.PostgreSQL, defaultSchemaName, platform.Namespace, false)
quarkusDataSource.JdbcUrl = getJdbcUrl(env)
quarkusDataSource.SecretRefName = persistenceOptionsSpec.PostgreSQL.SecretRef.Name
- quarkusDataSource.SecretUserKey = persistenceOptionsSpec.PostgreSQL.SecretRef.UserKey
- quarkusDataSource.SecretPasswordKey = persistenceOptionsSpec.PostgreSQL.SecretRef.PasswordKey
+ quarkusDataSource.SecretUserKey = defaultPostgreSqlUserKey
+ if len(persistenceOptionsSpec.PostgreSQL.SecretRef.UserKey) > 0 {
+ quarkusDataSource.SecretUserKey = persistenceOptionsSpec.PostgreSQL.SecretRef.UserKey
+ }
+ quarkusDataSource.SecretPasswordKey = defaultPostgreSqlPassworkdKey
+ if len(persistenceOptionsSpec.PostgreSQL.SecretRef.PasswordKey) > 0 {
+ quarkusDataSource.SecretPasswordKey = persistenceOptionsSpec.PostgreSQL.SecretRef.PasswordKey
+ }
quarkusDataSource.Schema = persistence.GetDBSchemaName(persistenceOptionsSpec.PostgreSQL, defaultSchemaName)
return quarkusDataSource
}
@@ -121,8 +129,14 @@ func getQuarkusDSFromPlatformPersistence(platform *operatorapi.SonataFlowPlatfor
env := persistence.ConfigurePostgreSQLEnv(postgresql, defaultSchemaName, platform.Namespace, false)
quarkusDataSource.JdbcUrl = getJdbcUrl(env)
quarkusDataSource.SecretRefName = platform.Spec.Persistence.PostgreSQL.SecretRef.Name
- quarkusDataSource.SecretUserKey = platform.Spec.Persistence.PostgreSQL.SecretRef.UserKey
- quarkusDataSource.SecretPasswordKey = platform.Spec.Persistence.PostgreSQL.SecretRef.PasswordKey
+ quarkusDataSource.SecretUserKey = defaultPostgreSqlUserKey
+ if len(platform.Spec.Persistence.PostgreSQL.SecretRef.UserKey) > 0 {
+ quarkusDataSource.SecretUserKey = platform.Spec.Persistence.PostgreSQL.SecretRef.UserKey
+ }
+ quarkusDataSource.SecretPasswordKey = defaultPostgreSqlPassworkdKey
+ if len(platform.Spec.Persistence.PostgreSQL.SecretRef.PasswordKey) > 0 {
+ quarkusDataSource.SecretPasswordKey = platform.Spec.Persistence.PostgreSQL.SecretRef.PasswordKey
+ }
quarkusDataSource.Schema = persistence.GetDBSchemaName(postgresql, defaultSchemaName)
return quarkusDataSource
}
@@ -280,6 +294,75 @@ func createJobDBMigration(platform *operatorapi.SonataFlowPlatform, dbmj *DBMigr
lbl, _ := getServicesLabelsMap(platform.Name, platform.Namespace, fmt.Sprintf("%s-%s", "sonataflow-db-job", dbMigrationJobCfg.JobName), dbMigrationJobCfg.JobName, fmt.Sprintf("%s-%s", platform.Name, dbMigrationJobCfg.JobName), platform.Name, "sonataflow-operator")
+ envVars := make([]corev1.EnvVar, 0)
+ envVars = append(envVars, corev1.EnvVar{
+ Name: migrateDBDataIndex,
+ Value: strconv.FormatBool(dbmj.MigrateDBDataIndex),
+ })
+ if dbmj.MigrateDBDataIndex {
+ envVars = append(envVars,
+ corev1.EnvVar{
+ Name: quarkusDataSourceDataIndexJdbcURL,
+ Value: diQuarkusDataSource.JdbcUrl,
+ },
+ corev1.EnvVar{
+ Name: quarkusDataSourceDataIndexUserName,
+ ValueFrom: &corev1.EnvVarSource{
+ SecretKeyRef: &corev1.SecretKeySelector{
+ Key: diQuarkusDataSource.SecretUserKey,
+ LocalObjectReference: diDBSecretRef,
+ },
+ },
+ },
+ corev1.EnvVar{
+ Name: quarkusDataSourceDataIndexPassword,
+ ValueFrom: &corev1.EnvVarSource{
+ SecretKeyRef: &corev1.SecretKeySelector{
+ Key: diQuarkusDataSource.SecretPasswordKey,
+ LocalObjectReference: diDBSecretRef,
+ },
+ },
+ },
+ corev1.EnvVar{
+ Name: quarkusFlywayDataIndexSchemas,
+ Value: diQuarkusDataSource.Schema,
+ })
+ }
+
+ envVars = append(envVars, corev1.EnvVar{
+ Name: migrateDBJobsService,
+ Value: strconv.FormatBool(dbmj.MigrateDBJobsService),
+ })
+ if dbmj.MigrateDBJobsService {
+ envVars = append(envVars,
+ corev1.EnvVar{
+ Name: quarkusDataSourceJobsServiceJdbcURL,
+ Value: jsQuarkusDataSource.JdbcUrl,
+ },
+ corev1.EnvVar{
+ Name: quarkusDataSourceJobsServiceUserName,
+ ValueFrom: &corev1.EnvVarSource{
+ SecretKeyRef: &corev1.SecretKeySelector{
+ Key: jsQuarkusDataSource.SecretUserKey,
+ LocalObjectReference: jsDBSecretRef,
+ },
+ },
+ },
+ corev1.EnvVar{
+ Name: quarkusDataSourceJobsServicePassword,
+ ValueFrom: &corev1.EnvVarSource{
+ SecretKeyRef: &corev1.SecretKeySelector{
+ Key: jsQuarkusDataSource.SecretPasswordKey,
+ LocalObjectReference: jsDBSecretRef,
+ },
+ },
+ },
+ corev1.EnvVar{
+ Name: quarkusFlywayJobsServiceSchemas,
+ Value: jsQuarkusDataSource.Schema,
+ })
+ }
+
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: dbMigrationJobCfg.JobName,
@@ -293,68 +376,7 @@ func createJobDBMigration(platform *operatorapi.SonataFlowPlatform, dbmj *DBMigr
{
Name: dbMigrationJobCfg.ContainerName,
Image: dbMigrationJobCfg.ToolImageName,
- Env: []corev1.EnvVar{
- {
- Name: migrateDBDataIndex,
- Value: strconv.FormatBool(dbmj.MigrateDBDataIndex),
- },
- {
- Name: quarkusDataSourceDataIndexJdbcURL,
- Value: diQuarkusDataSource.JdbcUrl,
- },
- {
- Name: quarkusDataSourceDataIndexUserName,
- ValueFrom: &corev1.EnvVarSource{
- SecretKeyRef: &corev1.SecretKeySelector{
- Key: diQuarkusDataSource.SecretUserKey,
- LocalObjectReference: diDBSecretRef,
- },
- },
- },
- {
- Name: quarkusDataSourceDataIndexPassword,
- ValueFrom: &corev1.EnvVarSource{
- SecretKeyRef: &corev1.SecretKeySelector{
- Key: diQuarkusDataSource.SecretPasswordKey,
- LocalObjectReference: diDBSecretRef,
- },
- },
- },
- {
- Name: quarkusFlywayDataIndexSchemas,
- Value: diQuarkusDataSource.Schema,
- },
- {
- Name: migrateDBJobsService,
- Value: strconv.FormatBool(dbmj.MigrateDBJobsService),
- },
- {
- Name: quarkusDataSourceJobsServiceJdbcURL,
- Value: jsQuarkusDataSource.JdbcUrl,
- },
- {
- Name: quarkusDataSourceJobsServiceUserName,
- ValueFrom: &corev1.EnvVarSource{
- SecretKeyRef: &corev1.SecretKeySelector{
- Key: jsQuarkusDataSource.SecretUserKey,
- LocalObjectReference: jsDBSecretRef,
- },
- },
- },
- {
- Name: quarkusDataSourceJobsServicePassword,
- ValueFrom: &corev1.EnvVarSource{
- SecretKeyRef: &corev1.SecretKeySelector{
- Key: jsQuarkusDataSource.SecretPasswordKey,
- LocalObjectReference: jsDBSecretRef,
- },
- },
- },
- {
- Name: quarkusFlywayJobsServiceSchemas,
- Value: jsQuarkusDataSource.Schema,
- },
- },
+ Env: envVars,
},
},
RestartPolicy: "Never",
diff --git a/packages/sonataflow-operator/internal/controller/platform/services/services.go b/packages/sonataflow-operator/internal/controller/platform/services/services.go
index 00f077c803f..0c7507f7241 100644
--- a/packages/sonataflow-operator/internal/controller/platform/services/services.go
+++ b/packages/sonataflow-operator/internal/controller/platform/services/services.go
@@ -53,9 +53,9 @@ import (
)
const (
- quarkusHibernateORMDatabaseGeneration string = "QUARKUS_HIBERNATE_ORM_DATABASE_GENERATION"
- quarkusFlywayMigrateAtStart string = "QUARKUS_FLYWAY_MIGRATE_AT_START"
- WaitingKnativeEventing = "WaitingKnativeEventing"
+ quarkusFlywayMigrateAtStart = "QUARKUS_FLYWAY_MIGRATE_AT_START"
+ kogitoJobsServiceLoadJobsErrorStrategy = "KOGITO_JOBS_SERVICE_LOADJOBERRORSTRATEGY"
+ WaitingKnativeEventing = "WaitingKnativeEventing"
)
type PlatformServiceHandler interface {
@@ -296,7 +296,7 @@ func (d *DataIndexHandler) ConfigurePersistence(containerSpec *corev1.Container)
dbMigrationStrategyService := isDBMigrationStrategyService(d.platform.Spec.Services.DataIndex.Persistence)
// specific to DataIndex
- c.Env = append(c.Env, corev1.EnvVar{Name: quarkusHibernateORMDatabaseGeneration, Value: "update"}, corev1.EnvVar{Name: quarkusFlywayMigrateAtStart, Value: dbMigrationStrategyService})
+ c.Env = append(c.Env, corev1.EnvVar{Name: quarkusFlywayMigrateAtStart, Value: dbMigrationStrategyService})
return c
}
return containerSpec
@@ -489,8 +489,8 @@ func (j *JobServiceHandler) ConfigurePersistence(containerSpec *corev1.Container
dbMigrationStrategyService := isDBMigrationStrategyService(j.platform.Spec.Services.JobService.Persistence)
// Specific to Job Service
- c.Env = append(c.Env, corev1.EnvVar{Name: "QUARKUS_FLYWAY_MIGRATE_AT_START", Value: dbMigrationStrategyService})
- c.Env = append(c.Env, corev1.EnvVar{Name: "KOGITO_JOBS_SERVICE_LOADJOBERRORSTRATEGY", Value: "FAIL_SERVICE"})
+ c.Env = append(c.Env, corev1.EnvVar{Name: quarkusFlywayMigrateAtStart, Value: dbMigrationStrategyService})
+ c.Env = append(c.Env, corev1.EnvVar{Name: kogitoJobsServiceLoadJobsErrorStrategy, Value: "FAIL_SERVICE"})
return c
}
return containerSpec
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org