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 Dec 20, 2024
1 parent c690d46 commit ab197e9
Show file tree
Hide file tree
Showing 28 changed files with 1,066 additions and 38 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 service?
// job: use job based approach
// service: service itself shall migrate the db
// none: no db migration 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 @@ -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
Loading

0 comments on commit ab197e9

Please sign in to comment.