rhkp commented on code in PR #2790:
URL:
https://github.com/apache/incubator-kie-tools/pull/2790#discussion_r1918867587
##########
packages/sonataflow-operator/internal/controller/platform/k8s.go:
##########
@@ -62,20 +63,86 @@ func (action *serviceAction) CanHandle(platform
*operatorapi.SonataFlowPlatform)
return platform.Status.IsReady()
}
+func (action *serviceAction) createOrUpdateDBMigrationJob(ctx context.Context,
client client.Client, platform *operatorapi.SonataFlowPlatform, pshDI
services.PlatformServiceHandler, pshJS services.PlatformServiceHandler)
(*DBMigratorJob, error) {
+ dbMigratorJob := NewDBMigratorJobData(ctx, action.client, platform,
pshDI, pshJS)
+
+ // Invoke DB Migration only if both or either DI/JS services are
requested, in addition to DBMigrationStrategyJob
+ if dbMigratorJob != nil {
+ klog.V(log.I).InfoS("Starting DB Migration Job: ")
+
+ job := dbMigratorJob.CreateJobDBMigration(platform)
+ if op, err := controllerutil.CreateOrUpdate(ctx, client, job,
func() error {
+ return nil
+ }); err != nil {
+ return dbMigratorJob, err
+ } else {
+ klog.V(log.I).InfoS("DB Migration Job successfully
created on cluster", "operation", op)
+ }
+ }
+ return dbMigratorJob, nil
+}
+
+func (action *serviceAction) handleDBMigrationJob(ctx context.Context,
platform *operatorapi.SonataFlowPlatform, psDI services.PlatformServiceHandler,
psJS services.PlatformServiceHandler) (*operatorapi.SonataFlowPlatform, error) {
+
+ dbMigratorJob, err := action.createOrUpdateDBMigrationJob(ctx,
action.client, platform, psDI, psJS)
+ if err != nil {
+ return nil, err
+ }
+ if dbMigratorJob != nil {
+ klog.V(log.E).InfoS("Created DB migration job")
+ dbMigratorJobStatus, err :=
dbMigratorJob.ReconcileDBMigrationJob(ctx, action.client, platform)
+ if err != nil {
+ return nil, err
+ }
+ if dbMigratorJobStatus.Failed == 1 {
+ return nil, errors.New("DB migration job failed")
+ } else if dbMigratorJobStatus.Succeeded == 1 {
+ return platform, nil
+ } else {
+ // DB migration is still running
+ return nil, nil
+ }
+ }
+
+ return platform, nil
+}
+
+func (action *serviceAction) isJobsBasedDBMigration(platform
*operatorapi.SonataFlowPlatform, pshDI services.PlatformServiceHandler, pshJS
services.PlatformServiceHandler) bool {
Review Comment:
Moved to db_migrator_job.go and now won't belong to serviceAction.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]