Skip to content

Commit

Permalink
Move MigrateDBOnStartUp flag under persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkp committed Jul 24, 2024
1 parent 6d28d55 commit d16000f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
5 changes: 4 additions & 1 deletion api/v1alpha08/sonataflow_persistence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ type PlatformPersistencePostgreSQL struct {
// the operator will add the necessary JDBC properties to in the workflow's application.properties so that it can communicate
// with the persistence service based on the spec provided here.
// +optional
// +kubebuilder:validation:MaxProperties=1
// +kubebuilder:validation:MaxProperties=2
type PersistenceOptionsSpec struct {
// Connect configured services to a postgresql database.
// +optional
PostgreSQL *PersistencePostgreSQL `json:"postgresql,omitempty"`

// Whether to migrate database on service startup?
MigrateDBOnStartUp bool `json:"migrateDBOnStartUp"`
}

// PersistencePostgreSQL configure postgresql connection for service(s).
Expand Down
2 changes: 0 additions & 2 deletions api/v1alpha08/sonataflowplatform_services_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ type ServiceSpec struct {
// PodTemplate describes the deployment details of this platform service instance.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="podTemplate"
PodTemplate PodTemplateSpec `json:"podTemplate,omitempty"`
// Whether to migrate database on service startup?
MigrateDBOnStartUp bool `json:"migrateDBOnStartUp,omitempty"`
}
20 changes: 12 additions & 8 deletions config/crd/bases/sonataflow.org_sonataflowplatforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,14 @@ spec:
description: 'Determines whether workflows without the `sonataflow.org/profile:
dev` annotation should be configured to use this service'
type: boolean
migrateDBOnStartUp:
description: Whether to migrate database on service startup?
type: boolean
persistence:
description: Persists service to a datasource of choice. Ephemeral
by default.
maxProperties: 1
maxProperties: 2
properties:
migrateDBOnStartUp:
description: Whether to migrate database on service startup?
type: boolean
postgresql:
description: Connect configured services to a postgresql
database.
Expand Down Expand Up @@ -629,6 +629,8 @@ spec:
required:
- secretRef
type: object
required:
- migrateDBOnStartUp
type: object
podTemplate:
description: PodTemplate describes the deployment details
Expand Down Expand Up @@ -8440,14 +8442,14 @@ spec:
description: 'Determines whether workflows without the `sonataflow.org/profile:
dev` annotation should be configured to use this service'
type: boolean
migrateDBOnStartUp:
description: Whether to migrate database on service startup?
type: boolean
persistence:
description: Persists service to a datasource of choice. Ephemeral
by default.
maxProperties: 1
maxProperties: 2
properties:
migrateDBOnStartUp:
description: Whether to migrate database on service startup?
type: boolean
postgresql:
description: Connect configured services to a postgresql
database.
Expand Down Expand Up @@ -8504,6 +8506,8 @@ spec:
required:
- secretRef
type: object
required:
- migrateDBOnStartUp
type: object
podTemplate:
description: PodTemplate describes the deployment details
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/sonataflow.org_sonataflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2106,8 +2106,11 @@ spec:
persistence:
description: Persistence defines the database persistence configuration
for the workflow
maxProperties: 1
maxProperties: 2
properties:
migrateDBOnStartUp:
description: Whether to migrate database on service startup?
type: boolean
postgresql:
description: Connect configured services to a postgresql database.
maxProperties: 2
Expand Down Expand Up @@ -2161,6 +2164,8 @@ spec:
required:
- secretRef
type: object
required:
- migrateDBOnStartUp
type: object
podTemplate:
description: PodTemplate describes the deployment details of this
Expand Down
4 changes: 2 additions & 2 deletions controllers/platform/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (d DataIndexHandler) ConfigurePersistence(containerSpec *corev1.Container)
c := containerSpec.DeepCopy()
c.Image = d.GetServiceImageName(constants.PersistenceTypePostgreSQL)
c.Env = append(c.Env, persistence.ConfigurePostgreSQLEnv(p.PostgreSQL, d.GetServiceName(), d.platform.Namespace)...)
migrateDBOnStart := strconv.FormatBool(d.platform.Spec.Services.DataIndex.MigrateDBOnStartUp)
migrateDBOnStart := strconv.FormatBool(d.platform.Spec.Services.DataIndex.Persistence.MigrateDBOnStartUp)
// specific to DataIndex
c.Env = append(c.Env, corev1.EnvVar{Name: quarkusHibernateORMDatabaseGeneration, Value: "update"}, corev1.EnvVar{Name: quarkusFlywayMigrateAtStart, Value: migrateDBOnStart})

Expand Down Expand Up @@ -392,7 +392,7 @@ func (j JobServiceHandler) ConfigurePersistence(containerSpec *corev1.Container)
p := persistence.RetrievePostgreSQLConfiguration(j.platform.Spec.Services.JobService.Persistence, j.platform.Spec.Persistence, j.GetServiceName())
c.Env = append(c.Env, persistence.ConfigurePostgreSQLEnv(p.PostgreSQL, j.GetServiceName(), j.platform.Namespace)...)
// Specific to Job Service
migrateDBOnStart := strconv.FormatBool(j.platform.Spec.Services.JobService.MigrateDBOnStartUp)
migrateDBOnStart := strconv.FormatBool(j.platform.Spec.Services.JobService.Persistence.MigrateDBOnStartUp)
c.Env = append(c.Env, corev1.EnvVar{Name: "QUARKUS_FLYWAY_MIGRATE_AT_START", Value: migrateDBOnStart})
c.Env = append(c.Env, corev1.EnvVar{Name: "KOGITO_JOBS_SERVICE_LOADJOBERRORSTRATEGY", Value: "FAIL_SERVICE"})
return c
Expand Down

0 comments on commit d16000f

Please sign in to comment.