diff --git a/api/v1alpha08/sonataflow_persistence_types.go b/api/v1alpha08/sonataflow_persistence_types.go index f93b7a4ca..fa39772cc 100644 --- a/api/v1alpha08/sonataflow_persistence_types.go +++ b/api/v1alpha08/sonataflow_persistence_types.go @@ -14,6 +14,18 @@ package v1alpha08 +// PersistenceOptionsSpec configures the DataBase support for both platform services and workflows. For services, it allows +// configuring a generic database connectivity if the service does not come with its own configured. In case of workflows, +// 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 +type PersistenceOptionsSpec struct { + // Connect configured services to a postgresql database. + // +optional + PostgreSQL *PersistencePostgreSQL `json:"postgresql,omitempty"` +} + // PersistencePostgreSQL configure postgresql connection for service(s). // +kubebuilder:validation:MinProperties=2 // +kubebuilder:validation:MaxProperties=2 diff --git a/api/v1alpha08/sonataflow_types.go b/api/v1alpha08/sonataflow_types.go index 644fb0a3a..04aa5440c 100644 --- a/api/v1alpha08/sonataflow_types.go +++ b/api/v1alpha08/sonataflow_types.go @@ -658,7 +658,7 @@ type SonataFlowSpec struct { //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="podTemplate" PodTemplate PodTemplateSpec `json:"podTemplate,omitempty"` // Persistence defines the database persistence configuration for the workflow - Persistence *PersistencePlatformSpec `json:"persistence,omitempty"` + Persistence *PersistenceOptionsSpec `json:"persistence,omitempty"` } // SonataFlowStatus defines the observed state of SonataFlow diff --git a/api/v1alpha08/sonataflowplatform_services_types.go b/api/v1alpha08/sonataflowplatform_services_types.go index ae5e4a99c..a16bc2782 100644 --- a/api/v1alpha08/sonataflowplatform_services_types.go +++ b/api/v1alpha08/sonataflowplatform_services_types.go @@ -32,7 +32,7 @@ type ServiceSpec struct { Enabled *bool `json:"enabled,omitempty"` // Persists service to a datasource of choice. Ephemeral by default. // +optional - Persistence *PersistencePlatformSpec `json:"persistence,omitempty"` + Persistence *PersistenceOptionsSpec `json:"persistence,omitempty"` // PodTemplate describes the deployment details of this platform service instance. //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="podTemplate" PodTemplate PodTemplateSpec `json:"podTemplate,omitempty"` diff --git a/api/v1alpha08/sonataflowplatform_types.go b/api/v1alpha08/sonataflowplatform_types.go index b59b53bcf..71f2d6217 100644 --- a/api/v1alpha08/sonataflowplatform_types.go +++ b/api/v1alpha08/sonataflowplatform_types.go @@ -45,23 +45,12 @@ type SonataFlowPlatformSpec struct { // Only workflows without the `sonataflow.org/profile: dev` annotation will be configured to use these service(s). // Setting this will override the use of any cluster-scoped services that might be defined via `SonataFlowClusterPlatform`. // +optional - Services ServicesPlatformSpec `json:"services,omitempty"` + Services *ServicesPlatformSpec `json:"services,omitempty"` // Persistence defines the platform persistence configuration. When this field is set, // the configuration is used as the persistence for platform services and sonataflow instances // that don't provide one of their own. // +optional - Persistence *PersistencePlatformSpec `json:"persistence,omitempty"` -} - -// PersistencePlatformSpec configures the DataBase support for both platform services and workflows. For services, it allows -// configuring a generic database connectivity if the service does not come with its own configured. In case of workflows, -// 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 -type PersistencePlatformSpec struct { - // Connect configured services to a postgresql database. - // +optional - PostgreSQL *PersistencePostgreSQL `json:"postgresql,omitempty"` + Persistence *PersistenceOptionsSpec `json:"persistence,omitempty"` } // PlatformCluster is the kind of orchestration cluster the platform is installed into diff --git a/api/v1alpha08/zz_generated.deepcopy.go b/api/v1alpha08/zz_generated.deepcopy.go index 157c23c07..fe3b1913c 100644 --- a/api/v1alpha08/zz_generated.deepcopy.go +++ b/api/v1alpha08/zz_generated.deepcopy.go @@ -320,7 +320,7 @@ func (in *Flow) DeepCopy() *Flow { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistencePlatformSpec) DeepCopyInto(out *PersistencePlatformSpec) { +func (in *PersistenceOptionsSpec) DeepCopyInto(out *PersistenceOptionsSpec) { *out = *in if in.PostgreSQL != nil { in, out := &in.PostgreSQL, &out.PostgreSQL @@ -329,12 +329,12 @@ func (in *PersistencePlatformSpec) DeepCopyInto(out *PersistencePlatformSpec) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistencePlatformSpec. -func (in *PersistencePlatformSpec) DeepCopy() *PersistencePlatformSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceOptionsSpec. +func (in *PersistenceOptionsSpec) DeepCopy() *PersistenceOptionsSpec { if in == nil { return nil } - out := new(PersistencePlatformSpec) + out := new(PersistenceOptionsSpec) in.DeepCopyInto(out) return out } @@ -645,7 +645,7 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { } if in.Persistence != nil { in, out := &in.Persistence, &out.Persistence - *out = new(PersistencePlatformSpec) + *out = new(PersistenceOptionsSpec) (*in).DeepCopyInto(*out) } in.PodTemplate.DeepCopyInto(&out.PodTemplate) @@ -1027,10 +1027,14 @@ func (in *SonataFlowPlatformSpec) DeepCopyInto(out *SonataFlowPlatformSpec) { *out = *in in.Build.DeepCopyInto(&out.Build) out.DevMode = in.DevMode - in.Services.DeepCopyInto(&out.Services) + if in.Services != nil { + in, out := &in.Services, &out.Services + *out = new(ServicesPlatformSpec) + (*in).DeepCopyInto(*out) + } if in.Persistence != nil { in, out := &in.Persistence, &out.Persistence - *out = new(PersistencePlatformSpec) + *out = new(PersistenceOptionsSpec) (*in).DeepCopyInto(*out) } } @@ -1081,7 +1085,7 @@ func (in *SonataFlowSpec) DeepCopyInto(out *SonataFlowSpec) { in.PodTemplate.DeepCopyInto(&out.PodTemplate) if in.Persistence != nil { in, out := &in.Persistence, &out.Persistence - *out = new(PersistencePlatformSpec) + *out = new(PersistenceOptionsSpec) (*in).DeepCopyInto(*out) } } diff --git a/bundle/manifests/sonataflow.org_sonataflowplatforms.yaml b/bundle/manifests/sonataflow.org_sonataflowplatforms.yaml index be9a64a73..3278706b4 100644 --- a/bundle/manifests/sonataflow.org_sonataflowplatforms.yaml +++ b/bundle/manifests/sonataflow.org_sonataflowplatforms.yaml @@ -425,6 +425,7 @@ spec: When this field is set, the configuration is used as the persistence for platform services and sonataflow instances that don't provide one of their own. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql database. @@ -498,6 +499,7 @@ spec: persistence: description: Persists service to a datasource of choice. Ephemeral by default. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql @@ -8369,6 +8371,7 @@ spec: persistence: description: Persists service to a datasource of choice. Ephemeral by default. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql diff --git a/bundle/manifests/sonataflow.org_sonataflows.yaml b/bundle/manifests/sonataflow.org_sonataflows.yaml index 23bd17a76..76c704fb3 100644 --- a/bundle/manifests/sonataflow.org_sonataflows.yaml +++ b/bundle/manifests/sonataflow.org_sonataflows.yaml @@ -2105,6 +2105,7 @@ spec: persistence: description: Persistence defines the database persistence configuration for the workflow + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql database. diff --git a/config/crd/bases/sonataflow.org_sonataflowplatforms.yaml b/config/crd/bases/sonataflow.org_sonataflowplatforms.yaml index 25e4f505b..b2dd3cc42 100644 --- a/config/crd/bases/sonataflow.org_sonataflowplatforms.yaml +++ b/config/crd/bases/sonataflow.org_sonataflowplatforms.yaml @@ -426,6 +426,7 @@ spec: When this field is set, the configuration is used as the persistence for platform services and sonataflow instances that don't provide one of their own. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql database. @@ -499,6 +500,7 @@ spec: persistence: description: Persists service to a datasource of choice. Ephemeral by default. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql @@ -8370,6 +8372,7 @@ spec: persistence: description: Persists service to a datasource of choice. Ephemeral by default. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql diff --git a/config/crd/bases/sonataflow.org_sonataflows.yaml b/config/crd/bases/sonataflow.org_sonataflows.yaml index 65dd887ff..e5214329e 100644 --- a/config/crd/bases/sonataflow.org_sonataflows.yaml +++ b/config/crd/bases/sonataflow.org_sonataflows.yaml @@ -2106,6 +2106,7 @@ spec: persistence: description: Persistence defines the database persistence configuration for the workflow + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql database. diff --git a/controllers/platform/platformutils.go b/controllers/platform/platformutils.go index 9249bed01..ae14c40e9 100644 --- a/controllers/platform/platformutils.go +++ b/controllers/platform/platformutils.go @@ -111,13 +111,15 @@ func setPlatformDefaults(p *operatorapi.SonataFlowPlatform, verbose bool) error } // When dataIndex object set, default to enabled if bool not set - var enable = true - if p.Spec.Services.DataIndex != nil && p.Spec.Services.DataIndex.Enabled == nil { - p.Spec.Services.DataIndex.Enabled = &enable - } - // When the JobService field has a value, default to enabled if the `Enabled` field's value is nil - if p.Spec.Services.JobService != nil && p.Spec.Services.JobService.Enabled == nil { - p.Spec.Services.JobService.Enabled = &enable + if p.Spec.Services != nil { + var enable = true + if p.Spec.Services.DataIndex != nil && p.Spec.Services.DataIndex.Enabled == nil { + p.Spec.Services.DataIndex.Enabled = &enable + } + // When the JobService field has a value, default to enabled if the `Enabled` field's value is nil + if p.Spec.Services.JobService != nil && p.Spec.Services.JobService.Enabled == nil { + p.Spec.Services.JobService.Enabled = &enable + } } setStatusAdditionalInfo(p) diff --git a/controllers/platform/services/properties_services_test.go b/controllers/platform/services/properties_services_test.go index c0983b0b7..46ea31a44 100644 --- a/controllers/platform/services/properties_services_test.go +++ b/controllers/platform/services/properties_services_test.go @@ -173,6 +173,9 @@ func generatePlatform(opts ...plfmOptionFn) *operatorapi.SonataFlowPlatform { func setJobServiceEnabledValue(v *bool) plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.JobService == nil { p.Spec.Services.JobService = &operatorapi.ServiceSpec{} } @@ -182,6 +185,9 @@ func setJobServiceEnabledValue(v *bool) plfmOptionFn { func setDataIndexEnabledValue(v *bool) plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.DataIndex == nil { p.Spec.Services.DataIndex = &operatorapi.ServiceSpec{} } @@ -191,6 +197,9 @@ func setDataIndexEnabledValue(v *bool) plfmOptionFn { func emptyDataIndexServiceSpec() plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.DataIndex == nil { p.Spec.Services.DataIndex = &operatorapi.ServiceSpec{} } @@ -199,6 +208,9 @@ func emptyDataIndexServiceSpec() plfmOptionFn { func emptyJobServiceSpec() plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.JobService == nil { p.Spec.Services.JobService = &operatorapi.ServiceSpec{} } @@ -219,11 +231,14 @@ func setPlatformName(name string) plfmOptionFn { func setJobServiceJDBC(jdbc string) plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.JobService == nil { p.Spec.Services.JobService = &operatorapi.ServiceSpec{} } if p.Spec.Services.JobService.Persistence == nil { - p.Spec.Services.JobService.Persistence = &operatorapi.PersistencePlatformSpec{} + p.Spec.Services.JobService.Persistence = &operatorapi.PersistenceOptionsSpec{} } if p.Spec.Services.JobService.Persistence.PostgreSQL == nil { p.Spec.Services.JobService.Persistence.PostgreSQL = &operatorapi.PersistencePostgreSQL{} @@ -234,11 +249,14 @@ func setJobServiceJDBC(jdbc string) plfmOptionFn { func setDataIndexJDBC(jdbc string) plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.DataIndex == nil { p.Spec.Services.DataIndex = &operatorapi.ServiceSpec{} } if p.Spec.Services.DataIndex.Persistence == nil { - p.Spec.Services.DataIndex.Persistence = &operatorapi.PersistencePlatformSpec{} + p.Spec.Services.DataIndex.Persistence = &operatorapi.PersistenceOptionsSpec{} } if p.Spec.Services.DataIndex.Persistence.PostgreSQL == nil { p.Spec.Services.DataIndex.Persistence.PostgreSQL = &operatorapi.PersistencePostgreSQL{} diff --git a/controllers/platform/services/services.go b/controllers/platform/services/services.go index d75a5a6bb..b5e25d264 100644 --- a/controllers/platform/services/services.go +++ b/controllers/platform/services/services.go @@ -459,7 +459,7 @@ func isJobServiceSet(platform *operatorapi.SonataFlowPlatform) bool { } func isServicesSet(platform *operatorapi.SonataFlowPlatform) bool { - return platform != nil && (platform.Spec.Services.JobService != nil || platform.Spec.Services.DataIndex != nil) + return platform != nil && platform.Spec.Services != nil } func generateServiceURL(protocol string, namespace string, name string) string { diff --git a/controllers/profiles/common/object_creators_test.go b/controllers/profiles/common/object_creators_test.go index 9e1a29b4d..52b3160be 100644 --- a/controllers/profiles/common/object_creators_test.go +++ b/controllers/profiles/common/object_creators_test.go @@ -214,7 +214,7 @@ func TestMergePodSpec_WithPostgreSQL_and_JDBC_URL_field(t *testing.T) { }, }, }, - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, JdbcUrl: "jdbc:postgresql://host:port/database?currentSchema=workflow", @@ -304,7 +304,7 @@ func TestMergePodSpec_OverrideContainers_WithPostgreSQL_In_Workflow_CR(t *testin }, }, }, - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, ServiceRef: &v1alpha08.PostgreSQLServiceOptions{ @@ -375,7 +375,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_CR_And_Worflow_Requesti Namespace: "default", }, Spec: v1alpha08.SonataFlowPlatformSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{ Name: "foo_secret", @@ -396,7 +396,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_CR_And_Worflow_Requesti workflow := test.GetBaseSonataFlow(t.Name()) workflow.Spec = v1alpha08.SonataFlowSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{}, + Persistence: &v1alpha08.PersistenceOptionsSpec{}, } object, err := DeploymentCreator(workflow, p) assert.NoError(t, err) @@ -456,7 +456,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_And_In_Workflow_CR(t *t Namespace: "default", }, Spec: v1alpha08.SonataFlowPlatformSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{ Name: "foo_secret", @@ -493,7 +493,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_And_In_Workflow_CR(t *t }, }, }, - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, ServiceRef: &v1alpha08.PostgreSQLServiceOptions{ @@ -563,7 +563,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_But_Workflow_CR_Not_Req Namespace: "default", }, Spec: v1alpha08.SonataFlowPlatformSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{ Name: "foo_secret", @@ -605,7 +605,7 @@ func TestMergePodSpec_WithEphemeralPostgreSQL_And_Undefined_PostgreSQL_Image_In_ } workflow := test.GetBaseSonataFlow(t.Name()) workflow.Spec = v1alpha08.SonataFlowSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{}, + Persistence: &v1alpha08.PersistenceOptionsSpec{}, } _, err := DeploymentCreator(workflow, p) assert.Error(t, err) diff --git a/controllers/profiles/common/persistence/postgresql.go b/controllers/profiles/common/persistence/postgresql.go index 3ab969634..fca5ed82e 100644 --- a/controllers/profiles/common/persistence/postgresql.go +++ b/controllers/profiles/common/persistence/postgresql.go @@ -24,9 +24,7 @@ import ( ) const ( - defaultSchemaName = "default" - defaultDatabaseName = "sonataflow" - + defaultDatabaseName = "sonataflow" timeoutSeconds = 3 failureThreshold = 5 initialPeriodSeconds = 15 @@ -114,7 +112,7 @@ func ConfigurePostgreSQLEnv(postgresql *operatorapi.PersistencePostgreSQL, datab } } -func ConfigurePersistence(serviceContainer *corev1.Container, config *operatorapi.PersistencePlatformSpec, defaultSchema, namespace string) (*corev1.Container, error) { +func ConfigurePersistence(serviceContainer *corev1.Container, config *operatorapi.PersistenceOptionsSpec, defaultSchema, namespace string) (*corev1.Container, error) { if config == nil { return nil, fmt.Errorf("no persistence specification found") } diff --git a/controllers/profiles/common/properties/application_test.go b/controllers/profiles/common/properties/application_test.go index 815bbf494..a0106837c 100644 --- a/controllers/profiles/common/properties/application_test.go +++ b/controllers/profiles/common/properties/application_test.go @@ -203,7 +203,7 @@ func Test_appPropertyHandler_WithServicesWithUserOverrides(t *testing.T) { platform := test.GetBasePlatform() platform.Namespace = ns platform.Spec = operatorapi.SonataFlowPlatformSpec{ - Services: operatorapi.ServicesPlatformSpec{ + Services: &operatorapi.ServicesPlatformSpec{ DataIndex: &operatorapi.ServiceSpec{ Enabled: &enabled, }, @@ -622,6 +622,9 @@ func generatePlatform(opts ...plfmOptionFn) *operatorapi.SonataFlowPlatform { func setJobServiceEnabledValue(v *bool) plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.JobService == nil { p.Spec.Services.JobService = &operatorapi.ServiceSpec{} } @@ -631,6 +634,9 @@ func setJobServiceEnabledValue(v *bool) plfmOptionFn { func setDataIndexEnabledValue(v *bool) plfmOptionFn { return func(p *operatorapi.SonataFlowPlatform) { + if p.Spec.Services == nil { + p.Spec.Services = &operatorapi.ServicesPlatformSpec{} + } if p.Spec.Services.DataIndex == nil { p.Spec.Services.DataIndex = &operatorapi.ServiceSpec{} } @@ -656,7 +662,7 @@ func setJobServiceJDBC(jdbc string) plfmOptionFn { p.Spec.Services.JobService = &operatorapi.ServiceSpec{} } if p.Spec.Services.JobService.Persistence == nil { - p.Spec.Services.JobService.Persistence = &operatorapi.PersistencePlatformSpec{} + p.Spec.Services.JobService.Persistence = &operatorapi.PersistenceOptionsSpec{} } if p.Spec.Services.JobService.Persistence.PostgreSQL == nil { p.Spec.Services.JobService.Persistence.PostgreSQL = &operatorapi.PersistencePostgreSQL{} diff --git a/controllers/sonataflowplatform_controller_test.go b/controllers/sonataflowplatform_controller_test.go index 94ad9a8fe..855041e61 100644 --- a/controllers/sonataflowplatform_controller_test.go +++ b/controllers/sonataflowplatform_controller_test.go @@ -86,7 +86,7 @@ func TestSonataFlowPlatformController(t *testing.T) { namespace := t.Name() // Create a SonataFlowPlatform object with metadata and spec. ksp := test.GetBasePlatformInReadyPhase(namespace) - ksp.Spec.Services = v1alpha08.ServicesPlatformSpec{ + ksp.Spec.Services = &v1alpha08.ServicesPlatformSpec{ DataIndex: &v1alpha08.ServiceSpec{}, } @@ -136,7 +136,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NotContains(t, dep.Spec.Template.Spec.Containers[0].Env, env) // Check with persistence set - ksp.Spec.Services.DataIndex.Persistence = &v1alpha08.PersistencePlatformSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ + ksp.Spec.Services.DataIndex.Persistence = &v1alpha08.PersistenceOptionsSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, ServiceRef: &v1alpha08.PostgreSQLServiceOptions{Name: "test"}, }} @@ -165,7 +165,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Create a SonataFlowPlatform object with metadata and spec. ksp := test.GetBasePlatformInReadyPhase(namespace) var replicas int32 = 2 - ksp.Spec.Services = v1alpha08.ServicesPlatformSpec{ + ksp.Spec.Services = &v1alpha08.ServicesPlatformSpec{ DataIndex: &v1alpha08.ServiceSpec{ PodTemplate: v1alpha08.PodTemplateSpec{ Replicas: &replicas, @@ -223,7 +223,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Check with persistence set url := "jdbc:postgresql://host:1234/database?currentSchema=data-index-service" - ksp.Spec.Services.DataIndex.Persistence = &v1alpha08.PersistencePlatformSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ + ksp.Spec.Services.DataIndex.Persistence = &v1alpha08.PersistenceOptionsSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, JdbcUrl: url, }} @@ -258,11 +258,11 @@ func TestSonataFlowPlatformController(t *testing.T) { ksp := test.GetBasePlatformInReadyPhase(namespace) // Check with persistence set ksp.Spec = v1alpha08.SonataFlowPlatformSpec{ - Services: v1alpha08.ServicesPlatformSpec{ + Services: &v1alpha08.ServicesPlatformSpec{ DataIndex: &v1alpha08.ServiceSpec{}, JobService: &v1alpha08.ServiceSpec{}, }, - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "generic", UserKey: "POSTGRESQL_USER", PasswordKey: "POSTGRESQL_PASSWORD"}, ServiceRef: &v1alpha08.PostgreSQLServiceOptions{Name: "postgresql", Namespace: "default", Port: &postgreSQLPort, DatabaseName: "sonataflow"}, @@ -348,9 +348,9 @@ func TestSonataFlowPlatformController(t *testing.T) { urlDI := "jdbc:postgresql://localhost:5432/database?currentSchema=data-index-service" urlJS := "jdbc:postgresql://localhost:5432/database?currentSchema=job-service" ksp.Spec = v1alpha08.SonataFlowPlatformSpec{ - Services: v1alpha08.ServicesPlatformSpec{ + Services: &v1alpha08.ServicesPlatformSpec{ DataIndex: &v1alpha08.ServiceSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "dataIndex"}, JdbcUrl: urlDI, @@ -358,7 +358,7 @@ func TestSonataFlowPlatformController(t *testing.T) { }, }, JobService: &v1alpha08.ServiceSpec{ - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "job"}, JdbcUrl: urlJS, @@ -366,7 +366,7 @@ func TestSonataFlowPlatformController(t *testing.T) { }, }, }, - Persistence: &v1alpha08.PersistencePlatformSpec{ + Persistence: &v1alpha08.PersistenceOptionsSpec{ PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "generic", UserKey: "POSTGRESQL_USER", PasswordKey: "POSTGRESQL_PASSWORD"}, ServiceRef: &v1alpha08.PostgreSQLServiceOptions{Name: "postgresql", Namespace: "default", Port: &postgreSQLPort, DatabaseName: "sonataflow"}, @@ -461,7 +461,7 @@ func TestSonataFlowPlatformController(t *testing.T) { namespace := t.Name() // Create a SonataFlowPlatform object with metadata and spec. ksp := test.GetBasePlatformInReadyPhase(namespace) - ksp.Spec.Services = v1alpha08.ServicesPlatformSpec{ + ksp.Spec.Services = &v1alpha08.ServicesPlatformSpec{ JobService: &v1alpha08.ServiceSpec{}, } @@ -508,7 +508,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NotContains(t, dep.Spec.Template.Spec.Containers[0].Env, envDataIndex) // Check with persistence set - ksp.Spec.Services.JobService.Persistence = &v1alpha08.PersistencePlatformSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ + ksp.Spec.Services.JobService.Persistence = &v1alpha08.PersistenceOptionsSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, ServiceRef: &v1alpha08.PostgreSQLServiceOptions{Name: "test"}, }} @@ -538,7 +538,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Create a SonataFlowPlatform object with metadata and spec. ksp := test.GetBasePlatformInReadyPhase(namespace) var replicas int32 = 2 - ksp.Spec.Services = v1alpha08.ServicesPlatformSpec{ + ksp.Spec.Services = &v1alpha08.ServicesPlatformSpec{ JobService: &v1alpha08.ServiceSpec{ PodTemplate: v1alpha08.PodTemplateSpec{ Replicas: &replicas, @@ -593,7 +593,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Check with persistence set url := "jdbc:postgresql://host:1234/database?currentSchema=data-index-service" - ksp.Spec.Services.JobService.Persistence = &v1alpha08.PersistencePlatformSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ + ksp.Spec.Services.JobService.Persistence = &v1alpha08.PersistenceOptionsSpec{PostgreSQL: &v1alpha08.PersistencePostgreSQL{ SecretRef: v1alpha08.PostgreSQLSecretOptions{Name: "test"}, JdbcUrl: url, }} @@ -619,7 +619,7 @@ func TestSonataFlowPlatformController(t *testing.T) { namespace := t.Name() // Create a SonataFlowPlatform object with metadata and spec. ksp := test.GetBasePlatformInReadyPhase(namespace) - ksp.Spec.Services = v1alpha08.ServicesPlatformSpec{ + ksp.Spec.Services = &v1alpha08.ServicesPlatformSpec{ DataIndex: &v1alpha08.ServiceSpec{}, JobService: &v1alpha08.ServiceSpec{}, } @@ -687,7 +687,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Create a SonataFlowPlatform object with metadata and spec. ksp := test.GetBasePlatformInReadyPhase(namespace) - ksp.Spec.Services = v1alpha08.ServicesPlatformSpec{ + ksp.Spec.Services = &v1alpha08.ServicesPlatformSpec{ DataIndex: &v1alpha08.ServiceSpec{}, JobService: &v1alpha08.ServiceSpec{}, } @@ -785,7 +785,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.Equal(t, ksp2.Status.ClusterPlatformRef.Services.JobServiceRef.Url, psJs.GetLocalServiceBaseUrl()) assert.Equal(t, psJs.GetLocalServiceBaseUrl()+constants.JobServiceJobEventsPath, psJs2.GetServiceBaseUrl()+constants.JobServiceJobEventsPath) - ksp2.Spec.Services = v1alpha08.ServicesPlatformSpec{} + ksp2.Spec.Services = &v1alpha08.ServicesPlatformSpec{} assert.NoError(t, cl.Update(context.TODO(), ksp2)) _, err = r.Reconcile(context.TODO(), req2) diff --git a/operator.yaml b/operator.yaml index 284588ae7..68dcb7847 100644 --- a/operator.yaml +++ b/operator.yaml @@ -904,6 +904,7 @@ spec: When this field is set, the configuration is used as the persistence for platform services and sonataflow instances that don't provide one of their own. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql database. @@ -977,6 +978,7 @@ spec: persistence: description: Persists service to a datasource of choice. Ephemeral by default. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql @@ -8848,6 +8850,7 @@ spec: persistence: description: Persists service to a datasource of choice. Ephemeral by default. + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql @@ -18920,6 +18923,7 @@ spec: persistence: description: Persistence defines the database persistence configuration for the workflow + maxProperties: 1 properties: postgresql: description: Connect configured services to a postgresql database. diff --git a/test/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml b/test/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml index 0204e50f0..d746ac94b 100644 --- a/test/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml +++ b/test/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml @@ -17,11 +17,6 @@ kind: SonataFlowPlatform metadata: name: sonataflow-platform spec: - build: - template: - buildArgs: - - name: QUARKUS_EXTENSIONS - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:2.0.0-SNAPSHOT persistence: postgresql: secretRef: diff --git a/test/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml b/test/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml index a8013e600..90e361b86 100644 --- a/test/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml +++ b/test/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml @@ -18,10 +18,6 @@ metadata: name: sonataflow-platform spec: build: - template: - buildArgs: - - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:2.0.0-SNAPSHOT config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/test/testdata/workflow/persistence/from_platform/02-sonataflow_platform.yaml b/test/testdata/workflow/persistence/from_platform/02-sonataflow_platform.yaml index f4cb459db..9debf41df 100644 --- a/test/testdata/workflow/persistence/from_platform/02-sonataflow_platform.yaml +++ b/test/testdata/workflow/persistence/from_platform/02-sonataflow_platform.yaml @@ -29,10 +29,6 @@ spec: databaseName: sonataflow databaseSchema: myschema build: - template: - buildArgs: - - name: QUARKUS_EXTENSIONS - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-SNAPSHOT,org.kie.kogito:kogito-addons-quarkus-persistence-jdbc:999-SNAPSHOT,io.quarkus:quarkus-jdbc-postgresql:3.2.9.Final,io.quarkus:quarkus-agroal:3.2.9.Final config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml b/test/testdata/workflow/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml index 102195889..6aada1b6d 100644 --- a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml +++ b/test/testdata/workflow/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml @@ -29,10 +29,6 @@ spec: databaseName: db_name databaseSchema: myschema build: - template: - buildArgs: - - name: QUARKUS_EXTENSIONS - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-SNAPSHOT,org.kie.kogito:kogito-addons-quarkus-persistence-jdbc:999-SNAPSHOT,io.quarkus:quarkus-jdbc-postgresql:3.2.9.Final,io.quarkus:quarkus-agroal:3.2.9.Final config: strategyOptions: KanikoBuildCacheEnabled: "true"