Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkp committed Dec 20, 2024
1 parent ab197e9 commit 450006b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 37 deletions.

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

2 changes: 2 additions & 0 deletions packages/sonataflow-operator/api/zz_generated.deepcopy.go

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)
kogitoDBMigratorToolImageTag: "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
17 changes: 0 additions & 17 deletions packages/sonataflow-operator/config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
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 @@ -63,6 +63,7 @@ type ControllersCfg struct {
JobsServiceEphemeralImageTag string `yaml:"jobsServiceEphemeralImageTag,omitempty"`
DataIndexPostgreSQLImageTag string `yaml:"dataIndexPostgreSQLImageTag,omitempty"`
DataIndexEphemeralImageTag string `yaml:"dataIndexEphemeralImageTag,omitempty"`
KogitoDBMigratorToolImageTag string `yaml:"kogitoDBMigratorToolImageTag,omitempty"`
SonataFlowBaseBuilderImageTag string `yaml:"sonataFlowBaseBuilderImageTag,omitempty"`
SonataFlowDevModeImageTag string `yaml:"sonataFlowDevModeImageTag,omitempty"`
BuilderConfigMapName string `yaml:"builderConfigMapName,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package platform
import (
"context"
"errors"
"fmt"
"strconv"
"strings"

Expand All @@ -31,9 +32,13 @@ import (
"k8s.io/klog/v2"
"k8s.io/utils/pointer"

"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/version"

operatorapi "github.com/apache/incubator-kie-tools/packages/sonataflow-operator/api/v1alpha08"
"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/container-builder/client"
"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/internal/controller/cfg"
"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/internal/controller/platform/services"
"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/internal/controller/profiles/common/constants"
"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/log"
)

Expand All @@ -58,6 +63,18 @@ const (
dbMigrationCmd = "./migration.sh"
dbMigrationJobFailed = 1
dbMigrationJobSucceeded = 1

migrateDBDataIndex = "MIGRATE_DB_DATAINDEX"
quarkusDataSourceDataIndexJdbcURL = "QUARKUS_DATASOURCE_DATAINDEX_JDBC_URL"
quarkusDataSourceDataIndexUserName = "QUARKUS_DATASOURCE_DATAINDEX_USERNAME"
quarkusDataSourceDataIndexPassword = "QUARKUS_DATASOURCE_DATAINDEX_PASSWORD"
quarkusFlywayDataIndexSchemas = "QUARKUS_FLYWAY_DATAINDEX_SCHEMAS"

migrateDBJobsService = "MIGRATE_DB_JOBSSERVICE"
quarkusDataSourceJobsServiceJdbcURL = "QUARKUS_DATASOURCE_JOBSSERVICE_JDBC_URL"
quarkusDataSourceJobsServiceUserName = "QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME"
quarkusDataSourceJobsServicePassword = "QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD"
quarkusFlywayJobsServiceSchemas = "QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS"
)

type DBMigrationJobCfg struct {
Expand Down Expand Up @@ -121,11 +138,11 @@ func NewDBMigratorJobData(ctx context.Context, client client.Client, platform *o
quarkusDataSourceJobService := &QuarkusDataSource{}

if diJobsBasedDBMigration {
quarkusDataSourceDataIndex = getQuarkusDataSourceFromPersistence(ctx, platform, platform.Spec.Services.DataIndex.Persistence, "defaultDi")
quarkusDataSourceDataIndex = getQuarkusDataSourceFromPersistence(ctx, platform, platform.Spec.Services.DataIndex.Persistence, "data-index-service")
}

if jsJobsBasedDBMigration {
quarkusDataSourceJobService = getQuarkusDataSourceFromPersistence(ctx, platform, platform.Spec.Services.JobService.Persistence, "defaultJs")
quarkusDataSourceJobService = getQuarkusDataSourceFromPersistence(ctx, platform, platform.Spec.Services.JobService.Persistence, "jobs-service")
}

return &DBMigratorJob{
Expand All @@ -138,7 +155,7 @@ func NewDBMigratorJobData(ctx context.Context, client client.Client, platform *o
return nil
}

func getNewQuarkusDataSource(jdbcURL string, userName string, password string, schema string) *QuarkusDataSource {
func newQuarkusDataSource(jdbcURL string, userName string, password string, schema string) *QuarkusDataSource {
return &QuarkusDataSource{
JdbcUrl: jdbcURL,
Username: userName,
Expand All @@ -149,8 +166,8 @@ func getNewQuarkusDataSource(jdbcURL string, userName string, password string, s

func (dbmj DBMigratorJob) CreateJobDBMigration(platform *operatorapi.SonataFlowPlatform) *batchv1.Job {

diQuarkusDataSource := getNewQuarkusDataSource("", "", "", "")
jsQuarkusDataSource := getNewQuarkusDataSource("", "", "", "")
diQuarkusDataSource := newQuarkusDataSource("", "", "", "")
jsQuarkusDataSource := newQuarkusDataSource("", "", "", "")

if dbmj.DataIndexDataSource != nil {
diQuarkusDataSource.JdbcUrl = dbmj.DataIndexDataSource.JdbcUrl
Expand All @@ -166,7 +183,7 @@ func (dbmj DBMigratorJob) CreateJobDBMigration(platform *operatorapi.SonataFlowP
jsQuarkusDataSource.Schema = dbmj.JobsServiceDataSource.Schema
}

dbMigrationJobCfg := getDBMigrationJobCfg()
dbMigrationJobCfg := newDBMigrationJobCfg()
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: dbMigrationJobCfg.JobName,
Expand All @@ -181,43 +198,43 @@ func (dbmj DBMigratorJob) CreateJobDBMigration(platform *operatorapi.SonataFlowP
Image: dbMigrationJobCfg.ToolImageName,
Env: []corev1.EnvVar{
{
Name: "MIGRATE_DB_DATAINDEX",
Name: migrateDBDataIndex,
Value: strconv.FormatBool(dbmj.MigrateDBDataIndex),
},
{
Name: "QUARKUS_DATASOURCE_DATAINDEX_JDBC_URL",
Name: quarkusDataSourceDataIndexJdbcURL,
Value: diQuarkusDataSource.JdbcUrl,
},
{
Name: "QUARKUS_DATASOURCE_DATAINDEX_USERNAME",
Name: quarkusDataSourceDataIndexUserName,
Value: diQuarkusDataSource.Username,
},
{
Name: "QUARKUS_DATASOURCE_DATAINDEX_PASSWORD",
Name: quarkusDataSourceDataIndexPassword,
Value: diQuarkusDataSource.Password,
},
{
Name: "QUARKUS_FLYWAY_DATAINDEX_SCHEMAS",
Name: quarkusFlywayDataIndexSchemas,
Value: diQuarkusDataSource.Schema,
},
{
Name: "MIGRATE_DB_JOBSSERVICE",
Name: migrateDBJobsService,
Value: strconv.FormatBool(dbmj.MigrateDBJobsService),
},
{
Name: "QUARKUS_DATASOURCE_JOBSSERVICE_JDBC_URL",
Name: quarkusDataSourceJobsServiceJdbcURL,
Value: jsQuarkusDataSource.JdbcUrl,
},
{
Name: "QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME",
Name: quarkusDataSourceJobsServiceUserName,
Value: jsQuarkusDataSource.Username,
},
{
Name: "QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD",
Name: quarkusDataSourceJobsServicePassword,
Value: jsQuarkusDataSource.Password,
},
{
Name: "QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS",
Name: quarkusFlywayJobsServiceSchemas,
Value: jsQuarkusDataSource.Schema,
},
},
Expand Down Expand Up @@ -265,11 +282,22 @@ func UpdateSonataFlowPlatformDBMigrationPhase(dbMigrationStatus *operatorapi.Son
return nil
}

func getDBMigrationJobCfg() *DBMigrationJobCfg {
func getKogitoDBMigratorToolImageName() string {

imgTag := cfg.GetCfg().KogitoDBMigratorToolImageTag

if imgTag == "" {
// returns "docker.io/apache/incubator-kie-kogito-db-migrator-tool:<tag>"
imgTag = fmt.Sprintf("%s-%s:%s", constants.ImageNamePrefix, constants.KogitoDBMigratorTool, version.GetImageTagVersion())
}
return imgTag
}

func newDBMigrationJobCfg() *DBMigrationJobCfg {
return &DBMigrationJobCfg{
JobName: dbMigrationJobName,
ContainerName: dbMigrationContainerName,
ToolImageName: dbMigratorToolImage,
ToolImageName: getKogitoDBMigratorToolImageName(),
MigrationCmd: dbMigrationCmd,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const (
JobServiceName = "jobs-service"
ImageNamePrefix = "docker.io/apache/incubator-kie-kogito"
DataIndexName = "data-index"
KogitoDBMigratorTool = "db-migrator-tool"

DefaultDatabaseName string = "sonataflow"
DefaultPostgreSQLPort int = 5432
Expand Down
2 changes: 2 additions & 0 deletions packages/sonataflow-operator/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28184,6 +28184,8 @@ data:
# 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)
kogitoDBMigratorToolImageTag: "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

0 comments on commit 450006b

Please sign in to comment.