Skip to content

Commit

Permalink
Begin db migrator changes to sonataflow-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkp committed Feb 3, 2025
1 parent bc53b02 commit 7f1d3d2
Show file tree
Hide file tree
Showing 35 changed files with 1,338 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

package v1alpha08

type DBMigrationStrategyType string

const (
DBMigrationStrategyService DBMigrationStrategyType = "service"
DBMigrationStrategyJob DBMigrationStrategyType = "job"
DBMigrationStrategyNone DBMigrationStrategyType = "none"
)

// 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
Expand Down Expand Up @@ -54,10 +62,13 @@ type PersistenceOptionsSpec struct {
// +optional
PostgreSQL *PersistencePostgreSQL `json:"postgresql,omitempty"`

// Whether to migrate database on service startup?
// DB Migration approach for data-index and jobs-service. Use the following values as described.
// job: use job based approach provided by the SonataFlow operator.
// service: service itself shall migrate the db and will not use SonataFlow operator.
// none: no database migration functionality needed.
// +optional
// +default: false
MigrateDBOnStartUp bool `json:"migrateDBOnStartUp"`
// +kubebuilder:default:=service
DBMigrationStrategy string `json:"dbMigrationStrategy,omitempty"`
}

// PersistencePostgreSQL configure postgresql connection for service(s).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ const (
PlatformDuplicatedReason = "Duplicated"
)

type DBMigrationStatus string

const (
DBMigrationStatusStarted DBMigrationStatus = "Started"
DBMigrationStatusInProgress DBMigrationStatus = "In-Progress"
DBMigrationStatusSucceeded DBMigrationStatus = "Succeeded"
DBMigrationStatusFailed DBMigrationStatus = "Failed"

MessageDBMigrationStatusStarted string = "Started the database migrations for the services"
MessageDBMigrationStatusInProgress string = "The database migrations for the services are in-progress"
MessageDBMigrationStatusSucceeded string = "The database migrations for the services are successful"
MessageDBMigrationStatusFailed string = "The database migrations for the services have failed"

ReasonDBMigrationStatusStarted string = "Started by SonataFlow operator"
ReasonDBMigrationStatusInProgress string = "The database migration job is in-progress"
ReasonDBMigrationStatusSucceeded string = "The database migration job completed as expected"
ReasonDBMigrationStatusFailed string = "The database may be unreachable, invalid credentials supplied or flyway migration failed. Please check logs for further details."
)

type SonataFlowPlatformDBMigrationPhase struct {
Status DBMigrationStatus `json:"dbMigrationStatus,omitempty"`
Message string `json:"message,omitempty"`
Reason string `json:"reason,omitempty"`
}

// SonataFlowPlatformStatus defines the observed state of SonataFlowPlatform
// +k8s:openapi-gen=true
type SonataFlowPlatformStatus struct {
Expand All @@ -123,6 +148,8 @@ type SonataFlowPlatformStatus struct {
// Triggers list of triggers created for the SonataFlowPlatform
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="triggers"
Triggers []SonataFlowPlatformTriggerRef `json:"triggers,omitempty"`
//+operator-sdk:csv:customresourcedefinitions:type=status,displayName="dbMigrationStatus"
SonataFlowPlatformDBMigrationPhase *SonataFlowPlatformDBMigrationPhase `json:"sonataFlowPlatformDBMigrationPhase,omitempty"`
}

// SonataFlowPlatformTriggerRef defines a trigger created for the SonataFlowPlatform.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobsServiceEphemeralImageTag: "docker.io/apache/incubator-kie-kogito-jobs-servic
# The Data Index image to use, if empty the operator will use the default Apache Community one based on the current operator's version
dataIndexPostgreSQLImageTag: "docker.io/apache/incubator-kie-kogito-data-index-postgresql:main"
dataIndexEphemeralImageTag: "docker.io/apache/incubator-kie-kogito-data-index-ephemeral:main"
# The Kogito PostgreSQL DB Migrator image to use (TBD: to replace with apache image)
dbMigratorToolImageTag: "quay.io/rhkp/incubator-kie-kogito-service-db-migration-postgresql:latest"
# SonataFlow base builder image used in the internal Dockerfile to build workflow applications in preview profile
# Order of precedence is:
# 1. SonataFlowPlatform in the given namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ spec:
- description: Info generic information related to the Platform
displayName: info
path: info
- displayName: dbMigrationStatus
path: sonataFlowPlatformDBMigrationPhase
- description: Triggers list of triggers created for the SonataFlowPlatform
displayName: triggers
path: triggers
Expand Down
12 changes: 12 additions & 0 deletions packages/sonataflow-operator/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type ControllersCfg struct {
JobsServiceEphemeralImageTag string `yaml:"jobsServiceEphemeralImageTag,omitempty"`
DataIndexPostgreSQLImageTag string `yaml:"dataIndexPostgreSQLImageTag,omitempty"`
DataIndexEphemeralImageTag string `yaml:"dataIndexEphemeralImageTag,omitempty"`
DbMigratorToolImageTag string `yaml:"dbMigratorToolImageTag,omitempty"`
SonataFlowBaseBuilderImageTag string `yaml:"sonataFlowBaseBuilderImageTag,omitempty"`
SonataFlowDevModeImageTag string `yaml:"sonataFlowDevModeImageTag,omitempty"`
BuilderConfigMapName string `yaml:"builderConfigMapName,omitempty"`
Expand Down
Loading

0 comments on commit 7f1d3d2

Please sign in to comment.