Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KOGITO-9980] Add persistence to SonataflowPlatform CRD #372

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4fbbb92
[KOGITO-9980] Add persistence structures in sonataflowplatform and so…
jordigilh Jan 12, 2024
76c26aa
Add logic for platform services and workflows to use the platform per…
jordigilh Jan 12, 2024
55b9cc6
Added e2e tests for both platform and workflows leveraging on their o…
jordigilh Jan 12, 2024
4757a09
Change namespace in persistence service reference to be optional to a…
jordigilh Jan 26, 2024
705846b
Extend e2e tests to cover for workflow CR using platform CR to provid…
jordigilh Jan 26, 2024
11d3123
Move image references in test to use ubi9/ubi-micro:latest
jordigilh Jan 26, 2024
e49a12b
Add descriptive message when unit test Test_Handler_WorkflowMinimalAn…
jordigilh Jan 26, 2024
f7d9b88
Fix flaky test Test_Handler_WorkflowMinimalAndPropsAndSpecAndGeneric
jordigilh Jan 26, 2024
7eba3f2
Collect cluster events and list all namespace/pods after running e2e …
jordigilh Jan 29, 2024
5655e61
Changes based on latest feedback from Ricardo
jordigilh Jan 29, 2024
69d0793
Remove duplicated tests
jordigilh Jan 30, 2024
71799ff
Aligned Persistence with Services, including adding support for JDBC …
jordigilh Jan 31, 2024
d235ca1
refactor platform CR retrieval
jordigilh Feb 2, 2024
3a4a5cc
Remove focus test function
jordigilh Feb 4, 2024
785ad19
Refactor logic to retrieve platform CR when deploying workflow to inj…
jordigilh Feb 5, 2024
77a9134
Updates based on latest changes and revert some unwanted changes that…
jordigilh Feb 5, 2024
f98eb50
Add additional check for nil values in platform spec and service spec…
jordigilh Feb 6, 2024
e69129c
Revert unnecessary change in variable name
jordigilh Feb 7, 2024
216f826
Change platform persistence to remove database schema and update code…
jordigilh Feb 8, 2024
0a22b9c
Changed logic in workflow to use persistence = nil as a signal to the…
jordigilh Feb 14, 2024
214e0b2
Refactored ConfigurePersistence() in JobServiceHandler to use functio…
jordigilh Feb 15, 2024
9865cca
Fix e2e tests and add 'time.Minute' timeout to waitFor condition
jordigilh Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ jobs:
run: |
make test-e2e

- name: Retrieve cluster events and list pods
if: failure()
run: |
kubectl get events
kubectl get pod -A

- name: Export kind logs
if: always()
run: |
Expand Down
102 changes: 102 additions & 0 deletions api/v1alpha08/sonataflow_persistence_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2024 Apache Software Foundation (ASF)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha08

// PlatformPersistenceOptionsSpec configures the DataBase in the platform spec. This specification can
// be used by workflows and platform services when they don't provide one of their own.
// +optional
// +kubebuilder:validation:MaxProperties=1
jordigilh marked this conversation as resolved.
Show resolved Hide resolved
type PlatformPersistenceOptionsSpec struct {
// Connect configured services to a postgresql database.
// +optional
PostgreSQL *PlatformPersistencePostgreSQL `json:"postgresql,omitempty"`
}

// PlatformPersistencePostgreSQL configure postgresql connection in a platform to be shared
// by platform services and workflows when required.
// +kubebuilder:validation:MinProperties=2
// +kubebuilder:validation:MaxProperties=2
type PlatformPersistencePostgreSQL struct {
// Secret reference to the database user credentials
SecretRef PostgreSQLSecretOptions `json:"secretRef"`
// Service reference to postgresql datasource. Mutually exclusive to jdbcUrl.
// +optional
ServiceRef *SQLServiceOptions `json:"serviceRef,omitempty"`
// PostgreSql JDBC URL. Mutually exclusive to serviceRef.
// e.g. "jdbc:postgresql://host:port/database?currentSchema=data-index-service"
// +optional
JdbcUrl string `json:"jdbcUrl,omitempty"`
}

// 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
type PersistencePostgreSQL struct {
// Secret reference to the database user credentials
SecretRef PostgreSQLSecretOptions `json:"secretRef"`
// Service reference to postgresql datasource. Mutually exclusive to jdbcUrl.
// +optional
ServiceRef *PostgreSQLServiceOptions `json:"serviceRef,omitempty"`
// PostgreSql JDBC URL. Mutually exclusive to serviceRef.
// e.g. "jdbc:postgresql://host:port/database?currentSchema=data-index-service"
// +optional
JdbcUrl string `json:"jdbcUrl,omitempty"`
}

// PostgreSQLSecretOptions use credential secret for postgresql connection.
type PostgreSQLSecretOptions struct {
// Name of the postgresql credentials secret.
Name string `json:"name"`
// Defaults to POSTGRESQL_USER
// +optional
UserKey string `json:"userKey,omitempty"`
// Defaults to POSTGRESQL_PASSWORD
// +optional
PasswordKey string `json:"passwordKey,omitempty"`
}

type SQLServiceOptions struct {
// Name of the postgresql k8s service.
Name string `json:"name"`
// Namespace of the postgresql k8s service. Defaults to the SonataFlowPlatform's local namespace.
// +optional
Namespace string `json:"namespace,omitempty"`
// Port to use when connecting to the postgresql k8s service. Defaults to 5432.
// +optional
Port *int `json:"port,omitempty"`
// Name of postgresql database to be used. Defaults to "sonataflow"
// +optional
DatabaseName string `json:"databaseName,omitempty"`
}

// PostgreSQLServiceOptions use k8s service to configure postgresql jdbc url.
type PostgreSQLServiceOptions struct {
*SQLServiceOptions `json:",inline"`
// Schema of postgresql database to be used. Defaults to "data-index-service"
// +optional
DatabaseSchema string `json:"databaseSchema,omitempty"`
}
5 changes: 2 additions & 3 deletions api/v1alpha08/sonataflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,8 @@ type SonataFlowSpec struct {
// PodTemplate describes the deployment details of this SonataFlow instance.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="podTemplate"
PodTemplate PodTemplateSpec `json:"podTemplate,omitempty"`
// Persists service to a datasource of choice. Ephemeral by default.
// +optional
Persistence *PersistenceOptions `json:"persistence,omitempty"`
// Persistence defines the database persistence configuration for the workflow
Persistence *PersistenceOptionsSpec `json:"persistence,omitempty"`
}

// SonataFlowStatus defines the observed state of SonataFlow
Expand Down
55 changes: 1 addition & 54 deletions api/v1alpha08/sonataflowplatform_services_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,61 +32,8 @@ type ServiceSpec struct {
Enabled *bool `json:"enabled,omitempty"`
// Persists service to a datasource of choice. Ephemeral by default.
// +optional
Persistence *PersistenceOptions `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"`
}

// PersistenceOptions configure the services to persist to a datasource of choice
// +kubebuilder:validation:MaxProperties=1
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
type PersistenceOptions 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
type PersistencePostgreSql struct {
// Secret reference to the database user credentials
SecretRef PostgreSqlSecretOptions `json:"secretRef"`
// Service reference to postgresql datasource. Mutually exclusive to jdbcUrl.
// +optional
ServiceRef *PostgreSqlServiceOptions `json:"serviceRef,omitempty"`
// PostgreSql JDBC URL. Mutually exclusive to serviceRef.
// e.g. "jdbc:postgresql://host:port/database?currentSchema=data-index-service"
// +optional
JdbcUrl string `json:"jdbcUrl,omitempty"`
}

// PostgreSqlSecretOptions use credential secret for postgresql connection.
type PostgreSqlSecretOptions struct {
// Name of the postgresql credentials secret.
Name string `json:"name"`
// Defaults to POSTGRESQL_USER
// +optional
UserKey string `json:"userKey,omitempty"`
// Defaults to POSTGRESQL_PASSWORD
// +optional
PasswordKey string `json:"passwordKey,omitempty"`
}

// PostgreSqlServiceOptions use k8s service to configure postgresql jdbc url.
type PostgreSqlServiceOptions struct {
// Name of the postgresql k8s service.
Name string `json:"name"`
// Namespace of the postgresql k8s service. Defaults to the SonataFlowPlatform's local namespace.
// +optional
Namespace string `json:"namespace,omitempty"`
// Port to use when connecting to the postgresql k8s service. Defaults to 5432.
// +optional
Port *int `json:"port,omitempty"`
// Name of postgresql database to be used. Defaults to "sonataflow"
// +optional
DatabaseName string `json:"databaseName,omitempty"`
// Schema of postgresql database to be used. Defaults to "data-index-service"
// +optional
DatabaseSchema string `json:"databaseSchema,omitempty"`
}
5 changes: 5 additions & 0 deletions api/v1alpha08/sonataflowplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ type SonataFlowPlatformSpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Services"
Services *ServicesPlatformSpec `json:"services,omitempty"`
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
// 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 *PlatformPersistenceOptionsSpec `json:"persistence,omitempty"`
}
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved

// PlatformCluster is the kind of orchestration cluster the platform is installed into
Expand Down
Loading
Loading