This is an automated email from the ASF dual-hosted git repository.
ricardozanini pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-serverless-operator.git
The following commit(s) were added to refs/heads/main by this push:
new 506962ef Issue #312 - Create a new controllers config package for
handling global configuration options for admins (#416)
506962ef is described below
commit 506962efbb3b4ea1edad1287b265318407a5cc48
Author: Ricardo Zanini <[email protected]>
AuthorDate: Wed Mar 27 10:57:29 2024 -0300
Issue #312 - Create a new controllers config package for handling global
configuration options for admins (#416)
---
api/const.go | 25 -----
...operator-rhel8-builder-config_v1_configmap.yaml | 1 -
...aflow-operator-builder-config_v1_configmap.yaml | 1 -
...w-operator-controllers-config_v1_configmap.yaml | 34 +++++++
.../sonataflow-operator.clusterserviceversion.yaml | 58 +++++++-----
config/default/controllers_config_patch.yaml | 18 ++++
config/default/kustomization.yaml | 3 +
...rfile.yaml => SonataFlow-Builder.containerfile} | 0
config/manager/controllers_cfg.yaml | 28 ++++++
config/manager/kustomization.yaml | 15 ++-
...rfile.yaml => SonataFlow-Builder.containerfile} | 0
config/manager/osl/kustomization.yaml | 3 +-
container-builder/api/build_types.go | 2 +
container-builder/api/const.go | 25 -----
container-builder/builder/kaniko_vanilla.go | 1 +
container-builder/builder/kubernetes/builder.go | 2 +
.../builder/kubernetes/builder_kaniko.go | 3 +-
container-builder/builder/kubernetes/kaniko.go | 3 +-
.../builder/kubernetes/monitor_pod.go | 14 ---
container-builder/go.mod | 1 -
container-builder/go.sum | 2 -
container-builder/util/defaults/kaniko.go | 26 ------
controllers/builder/builder.go | 18 ++--
controllers/builder/config.go | 38 ++++----
controllers/builder/containerbuilder.go | 19 ++--
controllers/builder/openshiftbuilder.go | 2 +-
controllers/builder/openshiftbuilder_test.go | 16 ++--
controllers/cfg/controllers_cfg.go | 92 +++++++++++++++++++
controllers/cfg/controllers_cfg_test.go | 52 +++++++++++
.../cfg/testdata/controllers-cfg-invalid.yaml | 15 +++
controllers/cfg/testdata/controllers-cfg-test.yaml | 23 +++++
controllers/platform/initialize.go | 4 +-
controllers/platform/kaniko_cache.go | 19 ++--
controllers/platform/platform.go | 1 -
controllers/platform/platformutils.go | 11 +--
controllers/platform/platformutils_test.go | 4 +-
controllers/platform/services/services.go | 23 ++++-
.../profiles/common/constants/platform_services.go | 14 ++-
.../profiles/common/persistence/postgresql.go | 2 +-
controllers/profiles/dev/object_creators_dev.go | 14 +--
controllers/profiles/dev/profile_dev_test.go | 3 +-
controllers/sonataflowplatform_controller_test.go | 10 +-
controllers/workflowdef/image.go | 12 ++-
docs/CONTRIBUTING.md | 3 +-
go.mod | 1 -
go.sum | 2 -
hack/local/run-e2e.sh | 3 +
main.go | 7 ++
operator.yaml | 102 +++++++++++++--------
testbdd/installers/sonataflow_installer.go | 8 +-
utils/common.go | 2 -
51 files changed, 510 insertions(+), 275 deletions(-)
diff --git a/api/const.go b/api/const.go
deleted file mode 100644
index 519456b0..00000000
--- a/api/const.go
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.
- */
-
-package api
-
-const (
- // ComponentName just a name to identify this
package/component/application
- ComponentName = "sonataflow"
-)
diff --git
a/bundle.osl/manifests/logic-operator-rhel8-builder-config_v1_configmap.yaml
b/bundle.osl/manifests/logic-operator-rhel8-builder-config_v1_configmap.yaml
index 76405972..2e7edcea 100644
--- a/bundle.osl/manifests/logic-operator-rhel8-builder-config_v1_configmap.yaml
+++ b/bundle.osl/manifests/logic-operator-rhel8-builder-config_v1_configmap.yaml
@@ -1,6 +1,5 @@
apiVersion: v1
data:
- DEFAULT_BUILDER_RESOURCE_NAME: Dockerfile
DEFAULT_WORKFLOW_EXTENSION: .sw.json
Dockerfile: "FROM
registry.redhat.io/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8:latest
AS builder\n\n# variables that can be overridden by the builder\n# To add
a Quarkus
diff --git
a/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml
b/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml
index 2d787ee0..d04b6b62 100644
--- a/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml
+++ b/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml
@@ -1,6 +1,5 @@
apiVersion: v1
data:
- DEFAULT_BUILDER_RESOURCE_NAME: Dockerfile
DEFAULT_WORKFLOW_EXTENSION: .sw.json
Dockerfile: "FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS
builder\n\n#
variables that can be overridden by the builder\n# To add a Quarkus
extension
diff --git
a/bundle/manifests/sonataflow-operator-controllers-config_v1_configmap.yaml
b/bundle/manifests/sonataflow-operator-controllers-config_v1_configmap.yaml
new file mode 100644
index 00000000..a16e6be8
--- /dev/null
+++ b/bundle/manifests/sonataflow-operator-controllers-config_v1_configmap.yaml
@@ -0,0 +1,34 @@
+apiVersion: v1
+data:
+ controllers_cfg.yaml: |
+ # The default size of Kaniko PVC when using the internal operator builder
manager
+ defaultPvcKanikoSize: 1Gi
+ # How much time (in seconds) to wait for a devmode workflow to start.
+ # This information is used for the controller manager to create new
devmode containers and setup the healthcheck probes.
+ healthFailureThresholdDevMode: 50
+ # Default image used internally by the Operator Managed Kaniko builder to
create the warmup pods
+ kanikoDefaultWarmerImageTag: gcr.io/kaniko-project/warmer:v1.9.0
+ # Default image used internally by the Operator Managed Kaniko builder to
create the executor pods
+ kanikoExecutorImageTag: gcr.io/kaniko-project/executor:v1.9.0
+ # The Jobs Service image to use, if empty the operator will use the
default Apache Community one based on the current operator's version
+ jobsServicePostgreSQLImageTag: ""
+ jobsServiceEphemeralImageTag: ""
+ # 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: ""
+ dataIndexEphemeralTag: ""
+ # 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
+ # 2. This configuration
+ # 3. The FROM in the Dockerfile in the operator's namespace
"sonataflow-operator-builder-config" configMap.
+ # If 1 or 2, the FROM tag will be replaced by the tag se there.
+ # If empty the operator will use the default Apache Community one based on
the current operator's version.
+ sonataFlowBaseBuilderImageTag: ""
+ # The image to use to deploy SonataFlow workflow images in devmode profile.
+ # If empty the operator will use the default Apache Community one based on
the current operator's version.
+ sonataFlowDevModeImageTag: ""
+ # The default name of the builder configMap in the operator's namespace
+ builderConfigMapName: "sonataflow-operator-builder-config"
+kind: ConfigMap
+metadata:
+ name: sonataflow-operator-controllers-config
diff --git a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml
b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml
index a4ce43c4..b71c508b 100644
--- a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml
+++ b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml
@@ -727,31 +727,6 @@ spec:
control-plane: sonataflow-operator
spec:
containers:
- - args:
- - --secure-listen-address=0.0.0.0:8443
- - --upstream=http://127.0.0.1:8080/
- - --logtostderr=true
- - --v=0
- image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
- name: kube-rbac-proxy
- ports:
- - containerPort: 8443
- name: https
- protocol: TCP
- resources:
- limits:
- cpu: 500m
- memory: 128Mi
- requests:
- cpu: 5m
- memory: 64Mi
- securityContext:
- allowPrivilegeEscalation: false
- capabilities:
- drop:
- - ALL
- seccompProfile:
- type: RuntimeDefault
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
@@ -790,10 +765,43 @@ spec:
capabilities:
drop:
- ALL
+ volumeMounts:
+ - mountPath: /config/controllers_cfg.yaml
+ name: controllers-config
+ subPath: controllers_cfg.yaml
+ - args:
+ - --secure-listen-address=0.0.0.0:8443
+ - --upstream=http://127.0.0.1:8080/
+ - --logtostderr=true
+ - --v=0
+ image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
+ name: kube-rbac-proxy
+ ports:
+ - containerPort: 8443
+ name: https
+ protocol: TCP
+ resources:
+ limits:
+ cpu: 500m
+ memory: 128Mi
+ requests:
+ cpu: 5m
+ memory: 64Mi
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop:
+ - ALL
+ seccompProfile:
+ type: RuntimeDefault
securityContext:
runAsNonRoot: true
serviceAccountName: sonataflow-operator-controller-manager
terminationGracePeriodSeconds: 10
+ volumes:
+ - configMap:
+ name: sonataflow-operator-controllers-config
+ name: controllers-config
permissions:
- rules:
- apiGroups:
diff --git a/config/default/controllers_config_patch.yaml
b/config/default/controllers_config_patch.yaml
new file mode 100644
index 00000000..53947672
--- /dev/null
+++ b/config/default/controllers_config_patch.yaml
@@ -0,0 +1,18 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: controller-manager
+ namespace: system
+spec:
+ template:
+ spec:
+ containers:
+ - name: manager
+ volumeMounts:
+ - name: controllers-config
+ mountPath: /config/controllers_cfg.yaml
+ subPath: controllers_cfg.yaml
+ volumes:
+ - name: controllers-config
+ configMap:
+ name: controllers-config
diff --git a/config/default/kustomization.yaml
b/config/default/kustomization.yaml
index 613c7e3b..19bd8db3 100644
--- a/config/default/kustomization.yaml
+++ b/config/default/kustomization.yaml
@@ -34,6 +34,9 @@ patchesStrategicMerge:
# through a ComponentConfig type
#- manager_config_patch.yaml
+# Mount the custom controllers config
+- controllers_config_patch.yaml
+
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK]
prefix including the one in
# crd/kustomization.yaml
#- manager_webhook_patch.yaml
diff --git a/config/manager/sonataflow_builder_dockerfile.yaml
b/config/manager/SonataFlow-Builder.containerfile
similarity index 100%
rename from config/manager/sonataflow_builder_dockerfile.yaml
rename to config/manager/SonataFlow-Builder.containerfile
diff --git a/config/manager/controllers_cfg.yaml
b/config/manager/controllers_cfg.yaml
new file mode 100644
index 00000000..41f2f860
--- /dev/null
+++ b/config/manager/controllers_cfg.yaml
@@ -0,0 +1,28 @@
+# The default size of Kaniko PVC when using the internal operator builder
manager
+defaultPvcKanikoSize: 1Gi
+# How much time (in seconds) to wait for a devmode workflow to start.
+# This information is used for the controller manager to create new devmode
containers and setup the healthcheck probes.
+healthFailureThresholdDevMode: 50
+# Default image used internally by the Operator Managed Kaniko builder to
create the warmup pods
+kanikoDefaultWarmerImageTag: gcr.io/kaniko-project/warmer:v1.9.0
+# Default image used internally by the Operator Managed Kaniko builder to
create the executor pods
+kanikoExecutorImageTag: gcr.io/kaniko-project/executor:v1.9.0
+# The Jobs Service image to use, if empty the operator will use the default
Apache Community one based on the current operator's version
+jobsServicePostgreSQLImageTag: ""
+jobsServiceEphemeralImageTag: ""
+# 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: ""
+dataIndexEphemeralTag: ""
+# 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
+# 2. This configuration
+# 3. The FROM in the Dockerfile in the operator's namespace
"sonataflow-operator-builder-config" configMap.
+# If 1 or 2, the FROM tag will be replaced by the tag se there.
+# If empty the operator will use the default Apache Community one based on the
current operator's version.
+sonataFlowBaseBuilderImageTag: ""
+# The image to use to deploy SonataFlow workflow images in devmode profile.
+# If empty the operator will use the default Apache Community one based on the
current operator's version.
+sonataFlowDevModeImageTag: ""
+# The default name of the builder configMap in the operator's namespace
+builderConfigMapName: "sonataflow-operator-builder-config"
diff --git a/config/manager/kustomization.yaml
b/config/manager/kustomization.yaml
index bc6245f0..3cc8cc8e 100644
--- a/config/manager/kustomization.yaml
+++ b/config/manager/kustomization.yaml
@@ -2,16 +2,21 @@ resources:
- manager.yaml
generatorOptions:
disableNameSuffixHash: true
+# No need to generate this CM since we are not using it.
+# Must also uncomment config/manager/kustomization.yaml to mount it in the
controller
+
+#- files:
+# - controller_manager_config.yaml
+# name: manager-config
configMapGenerator:
- files:
- - controller_manager_config.yaml
- name: manager-config
-- files:
- - Dockerfile=sonataflow_builder_dockerfile.yaml
+ - Dockerfile=SonataFlow-Builder.containerfile
literals:
- - DEFAULT_BUILDER_RESOURCE_NAME=Dockerfile
- DEFAULT_WORKFLOW_EXTENSION=.sw.json
name: builder-config
+- files:
+ - controllers_cfg.yaml
+ name: controllers-config
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
diff --git a/config/manager/osl/sonataflow_builder_dockerfile.yaml
b/config/manager/osl/SonataFlow-Builder.containerfile
similarity index 100%
rename from config/manager/osl/sonataflow_builder_dockerfile.yaml
rename to config/manager/osl/SonataFlow-Builder.containerfile
diff --git a/config/manager/osl/kustomization.yaml
b/config/manager/osl/kustomization.yaml
index 52178c0d..8136aefa 100644
--- a/config/manager/osl/kustomization.yaml
+++ b/config/manager/osl/kustomization.yaml
@@ -9,9 +9,8 @@ configMapGenerator:
- controller_manager_config.yaml
name: manager-config
- files:
- - Dockerfile=sonataflow_builder_dockerfile.yaml
+ - Dockerfile=SonataFlow-Builder.containerfile
literals:
- - DEFAULT_BUILDER_RESOURCE_NAME=Dockerfile
- DEFAULT_WORKFLOW_EXTENSION=.sw.json
name: builder-config
diff --git a/container-builder/api/build_types.go
b/container-builder/api/build_types.go
index d631385f..a90b1825 100644
--- a/container-builder/api/build_types.go
+++ b/container-builder/api/build_types.go
@@ -125,6 +125,8 @@ type KanikoTask struct {
Cache KanikoTaskCache `json:"cache,omitempty"`
// AdditionalFlags -- List of additional flags for the Kaniko process
(see
https://github.com/GoogleContainerTools/kaniko/blob/main/README.md#additional-flags)
AdditionalFlags []string `json:"additionalFlags,omitempty"`
+ // Image used by the created Kaniko pod executor
+ KanikoExecutorImage string `json:"kanikoExecutorImage,omitempty"`
}
// KanikoTaskCache is used to configure Kaniko cache
diff --git a/container-builder/api/const.go b/container-builder/api/const.go
deleted file mode 100644
index b24b5d88..00000000
--- a/container-builder/api/const.go
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.
- */
-
-package api
-
-const (
- // ComponentName just a name to identify this
package/component/application
- ComponentName = "sonataflow-builder"
-)
diff --git a/container-builder/builder/kaniko_vanilla.go
b/container-builder/builder/kaniko_vanilla.go
index 5a729210..bad057f8 100644
--- a/container-builder/builder/kaniko_vanilla.go
+++ b/container-builder/builder/kaniko_vanilla.go
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package builder
import (
diff --git a/container-builder/builder/kubernetes/builder.go
b/container-builder/builder/kubernetes/builder.go
index f5d50473..a2c78bbc 100644
--- a/container-builder/builder/kubernetes/builder.go
+++ b/container-builder/builder/kubernetes/builder.go
@@ -40,6 +40,8 @@ type ContainerBuilderInfo struct {
FinalImageName string
BuildUniqueName string
Platform api.PlatformContainerBuild
+ // ContainerBuilderImageTag the image tag used internally to create the
pod builder (e.g. Kaniko Executor Builder image)
+ ContainerBuilderImageTag string
}
type resource struct {
diff --git a/container-builder/builder/kubernetes/builder_kaniko.go
b/container-builder/builder/kubernetes/builder_kaniko.go
index 35416689..0ab6c9b8 100644
--- a/container-builder/builder/kubernetes/builder_kaniko.go
+++ b/container-builder/builder/kubernetes/builder_kaniko.go
@@ -50,7 +50,8 @@ func (k kanikoSchedulerManager) CreateScheduler(info
ContainerBuilderInfo, ctx *
Image: info.FinalImageName,
Registry: info.Platform.Spec.Registry,
},
- Cache: api.KanikoTaskCache{},
+ Cache: api.KanikoTaskCache{},
+ KanikoExecutorImage: info.ContainerBuilderImageTag,
}
ctx.containerBuild = &api.ContainerBuild{
diff --git a/container-builder/builder/kubernetes/kaniko.go
b/container-builder/builder/kubernetes/kaniko.go
index a596a3d6..d2d542c5 100644
--- a/container-builder/builder/kubernetes/kaniko.go
+++ b/container-builder/builder/kubernetes/kaniko.go
@@ -28,7 +28,6 @@ import (
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/api"
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/client"
-
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/defaults"
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/minikube"
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/registry"
)
@@ -136,7 +135,7 @@ func addKanikoTaskToPod(ctx context.Context, c
client.Client, build *api.Contain
container := corev1.Container{
Name: strings.ToLower(task.Name),
- Image: defaults.KanikoExecutorImage,
+ Image: task.KanikoExecutorImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Args: args,
Env: env,
diff --git a/container-builder/builder/kubernetes/monitor_pod.go
b/container-builder/builder/kubernetes/monitor_pod.go
index 9a18aa7e..2a52275e 100644
--- a/container-builder/builder/kubernetes/monitor_pod.go
+++ b/container-builder/builder/kubernetes/monitor_pod.go
@@ -25,10 +25,6 @@ import (
"os"
"time"
- "github.com/hashicorp/go-version"
-
-
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/defaults"
-
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -99,16 +95,6 @@ func (action *monitorPodAction) Handle(ctx context.Context,
build *api.Container
if err = action.addTimeoutAnnotation(ctx, pod,
metav1.Now()); err != nil {
return nil, err
}
- // In latest Kaniko versions kill is no more available
in image's $PATH, do we still need it?
- // Send SIGTERM signal to running containers
- current, err :=
version.NewVersion(defaults.KanikoVersion)
- maxVersionSupportingKill, err :=
version.NewVersion(defaults.KanikoVersionSupportingKill)
- if current.LessThanOrEqual(maxVersionSupportingKill) {
- if err = action.sigterm(pod); err != nil {
- // Requeue
- return nil, err
- }
- }
}
case corev1.PodSucceeded:
diff --git a/container-builder/go.mod b/container-builder/go.mod
index fc52361c..fccb1499 100644
--- a/container-builder/go.mod
+++ b/container-builder/go.mod
@@ -6,7 +6,6 @@ require (
github.com/docker/docker v24.0.9+incompatible
github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11
github.com/google/uuid v1.3.1
- github.com/hashicorp/go-version v1.6.0
github.com/heroku/docker-registry-client
v0.0.0-20211012143308-9463674c8930
github.com/jpillora/backoff v1.0.0
github.com/mitchellh/go-homedir v1.1.0
diff --git a/container-builder/go.sum b/container-builder/go.sum
index b4e1a208..54cd5675 100644
--- a/container-builder/go.sum
+++ b/container-builder/go.sum
@@ -156,8 +156,6 @@ github.com/gorilla/mux v1.8.0/go.mod
h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
github.com/gorilla/websocket v1.4.2/go.mod
h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gostaticanalysis/analysisutil
v0.0.0-20190318220348-4088753ea4d3/go.mod
h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod
h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
-github.com/hashicorp/go-version v1.6.0
h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
-github.com/hashicorp/go-version v1.6.0/go.mod
h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod
h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
github.com/heroku/docker-registry-client v0.0.0-20211012143308-9463674c8930
h1:mNL9ktJqBuzPTV/QP/fKd4y1uOFvfiv6zhe0G7lg9OA=
github.com/heroku/docker-registry-client
v0.0.0-20211012143308-9463674c8930/go.mod
h1:Yho0S7KhsnHQRCC5lDraYF1SsLMeWtf/tKdufKu3TJA=
diff --git a/container-builder/util/defaults/kaniko.go
b/container-builder/util/defaults/kaniko.go
deleted file mode 100644
index df6c20da..00000000
--- a/container-builder/util/defaults/kaniko.go
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.
- */
-
-package defaults
-
-const (
- KanikoVersion = "1.9.0"
- KanikoVersionSupportingKill = "0.17.1"
- KanikoExecutorImage = "gcr.io/kaniko-project/executor:v" +
KanikoVersion
-)
diff --git a/controllers/builder/builder.go b/controllers/builder/builder.go
index 17db22a9..d7ef14db 100644
--- a/controllers/builder/builder.go
+++ b/controllers/builder/builder.go
@@ -35,10 +35,10 @@ import (
)
type buildManagerContext struct {
- ctx context.Context
- client client.Client
- platform *operatorapi.SonataFlowPlatform
- commonConfig *v1.ConfigMap
+ ctx context.Context
+ client client.Client
+ platform *operatorapi.SonataFlowPlatform
+ builderConfigMap *v1.ConfigMap
}
type BuildManager interface {
@@ -55,16 +55,16 @@ func NewBuildManager(ctx context.Context, client
client.Client, cliConfig *rest.
klog.V(log.E).ErrorS(err, "Error retrieving the active
platform. Workflow build cannot be performed!", "workflow", targetName)
return nil, err
}
- commonConfig, err := GetCommonConfigMap(client, targetNamespace)
+ builderConfig, err := GetBuilderConfigMap(client, targetNamespace)
if err != nil {
klog.V(log.E).ErrorS(err, "Failed to get common configMap for
Workflow Builder. Make sure that sonataflow-operator-builder-config is present
in the operator namespace.")
return nil, err
}
managerContext := buildManagerContext{
- ctx: ctx,
- client: client,
- platform: p,
- commonConfig: commonConfig,
+ ctx: ctx,
+ client: client,
+ platform: p,
+ builderConfigMap: builderConfig,
}
switch p.Status.Cluster {
case operatorapi.PlatformClusterOpenShift:
diff --git a/controllers/builder/config.go b/controllers/builder/config.go
index 77155a4f..d949a477 100644
--- a/controllers/builder/config.go
+++ b/controllers/builder/config.go
@@ -24,6 +24,7 @@ import (
"fmt"
"os"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -35,15 +36,13 @@ import (
)
const (
- envVarPodNamespaceName = "POD_NAMESPACE"
- // ConfigMapName is the default name for the Builder ConfigMap name
- ConfigMapName =
"sonataflow-operator-builder-config"
- configKeyDefaultExtension = "DEFAULT_WORKFLOW_EXTENSION"
- configKeyDefaultBuilderResourceName = "DEFAULT_BUILDER_RESOURCE_NAME"
+ envVarPodNamespaceName = "POD_NAMESPACE"
+ configKeyDefaultExtension = "DEFAULT_WORKFLOW_EXTENSION"
+ defaultBuilderResourceName = "Dockerfile"
)
-// GetCommonConfigMap retrieves the config map with the builder common
configuration information
-func GetCommonConfigMap(client client.Client, fallbackNS string)
(*corev1.ConfigMap, error) {
+// GetBuilderConfigMap retrieves the config map with the builder common
configuration information
+func GetBuilderConfigMap(client client.Client, fallbackNS string)
(*corev1.ConfigMap, error) {
namespace, found := os.LookupEnv(envVarPodNamespaceName)
if !found {
namespace = fallbackNS
@@ -59,43 +58,38 @@ func GetCommonConfigMap(client client.Client, fallbackNS
string) (*corev1.Config
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
- Name: ConfigMapName,
+ Name: cfg.GetCfg().BuilderConfigMapName,
Namespace: namespace,
},
Data: map[string]string{},
}
- err := client.Get(context.TODO(), types.NamespacedName{Name:
ConfigMapName, Namespace: namespace}, existingConfigMap)
+ builderConfigMapName := cfg.GetCfg().BuilderConfigMapName
+ err := client.Get(context.TODO(), types.NamespacedName{Name:
builderConfigMapName, Namespace: namespace}, existingConfigMap)
if err != nil {
- klog.V(log.E).ErrorS(err, "fetching configmap", "name",
ConfigMapName)
+ klog.V(log.E).ErrorS(err, "fetching configmap", "name",
builderConfigMapName)
return nil, err
}
- err = isValidBuilderCommonConfigMap(existingConfigMap)
+ err = isValidBuilderConfigMap(existingConfigMap)
if err != nil {
- klog.V(log.E).ErrorS(err, "configmap is not valid", "name",
ConfigMapName)
+ klog.V(log.E).ErrorS(err, "configmap is not valid", "name",
builderConfigMapName)
return existingConfigMap, err
}
return existingConfigMap, nil
}
-// isValidBuilderCommonConfigMap function that will verify that in the
builder config maps there are the required keys, and they aren't empty
-func isValidBuilderCommonConfigMap(configMap *corev1.ConfigMap) error {
-
+// isValidBuilderConfigMap function that will verify that in the builder
config maps there are the required keys, and they aren't empty
+func isValidBuilderConfigMap(configMap *corev1.ConfigMap) error {
// Verifying that the key to hold the extension for the workflow is
there and not empty
if len(configMap.Data[configKeyDefaultExtension]) == 0 {
return fmt.Errorf("unable to find %s key into builder config
map", configMap.Data[configKeyDefaultExtension])
}
- // Verifying that the key to hold the name of the Dockerfile for
building the workflow is there and not empty
- if len(configMap.Data[configKeyDefaultBuilderResourceName]) == 0 {
- return fmt.Errorf("unable to find %s key into builder config
map", configMap.Data[configKeyDefaultBuilderResourceName])
- }
-
// Verifying that the key to hold the content of the Dockerfile for
building the workflow is there and not empty
- if
len(configMap.Data[configMap.Data[configKeyDefaultBuilderResourceName]]) == 0 {
- return fmt.Errorf("unable to find %s key into builder config
map", configMap.Data[configKeyDefaultBuilderResourceName])
+ if len(configMap.Data[defaultBuilderResourceName]) == 0 {
+ return fmt.Errorf("unable to find %s key into builder config
map", configMap.Data[defaultBuilderResourceName])
}
return nil
}
diff --git a/controllers/builder/containerbuilder.go
b/controllers/builder/containerbuilder.go
index a3fc344a..c945f02d 100644
--- a/controllers/builder/containerbuilder.go
+++ b/controllers/builder/containerbuilder.go
@@ -22,6 +22,7 @@ package builder
import (
"time"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"k8s.io/klog/v2"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/workflowdef"
@@ -73,9 +74,10 @@ func (c *containerBuilderManager) Schedule(build
*operatorapi.SonataFlowBuild) e
Envs: build.Spec.Envs,
Resources: build.Spec.Resources,
},
- PublishTask: api.PublishTask{},
- Cache: kanikoTaskCache,
- AdditionalFlags: build.Spec.Arguments,
+ PublishTask: api.PublishTask{},
+ Cache: kanikoTaskCache,
+ AdditionalFlags: build.Spec.Arguments,
+ KanikoExecutorImage: cfg.GetCfg().KanikoExecutorImageTag,
}
var containerBuilder *api.ContainerBuild
var err error
@@ -137,7 +139,7 @@ func (c *containerBuilderManager)
scheduleNewKanikoBuildWithContainerFile(build
task: task,
workflowDefinition: workflowDef,
workflow: workflow,
- dockerfile:
platform.GetCustomizedDockerfile(c.commonConfig.Data[c.commonConfig.Data[configKeyDefaultBuilderResourceName]],
*c.platform),
+ dockerfile:
platform.GetCustomizedBuilderDockerfile(c.builderConfigMap.Data[defaultBuilderResourceName],
*c.platform),
imageTag: buildNamespacedImageTag(workflow),
}
@@ -173,7 +175,7 @@ func (c *containerBuilderManager) buildImage(buildInput
kanikoBuildInput) (*api.
},
}
- build, err := newBuild(buildInput, plat,
c.commonConfig.Data[configKeyDefaultExtension], cli)
+ build, err := newBuild(buildInput, plat,
c.builderConfigMap.Data[configKeyDefaultExtension], cli)
if err != nil {
klog.V(log.E).ErrorS(err, "error during build Image")
return nil, err
@@ -183,7 +185,12 @@ func (c *containerBuilderManager) buildImage(buildInput
kanikoBuildInput) (*api.
// Helper function to create a new container-builder build and schedule it
func newBuild(buildInput kanikoBuildInput, platform
api.PlatformContainerBuild, defaultExtension string, cli client.Client)
(*api.ContainerBuild, error) {
- buildInfo := builder.ContainerBuilderInfo{FinalImageName:
buildInput.imageTag, BuildUniqueName: buildInput.name, Platform: platform}
+ buildInfo := builder.ContainerBuilderInfo{
+ FinalImageName: buildInput.imageTag,
+ BuildUniqueName: buildInput.name,
+ Platform: platform,
+ ContainerBuilderImageTag: buildInput.task.KanikoExecutorImage,
+ }
newBuilder := builder.NewBuild(buildInfo).
WithClient(cli).
diff --git a/controllers/builder/openshiftbuilder.go
b/controllers/builder/openshiftbuilder.go
index 55c1fc2d..44077d46 100644
--- a/controllers/builder/openshiftbuilder.go
+++ b/controllers/builder/openshiftbuilder.go
@@ -150,7 +150,7 @@ func (o *openshiftBuilderManager) Schedule(build
*operatorapi.SonataFlowBuild) e
func (o *openshiftBuilderManager) newDefaultBuildConfig(build
*operatorapi.SonataFlowBuild, workflow *operatorapi.SonataFlow)
*buildv1.BuildConfig {
optimizationPol := buildv1.ImageOptimizationSkipLayers
- dockerFile :=
platform.GetCustomizedDockerfile(o.commonConfig.Data[o.commonConfig.Data[configKeyDefaultBuilderResourceName]],
*o.platform)
+ dockerFile :=
platform.GetCustomizedBuilderDockerfile(o.builderConfigMap.Data[defaultBuilderResourceName],
*o.platform)
return &buildv1.BuildConfig{
ObjectMeta: metav1.ObjectMeta{Namespace: build.Namespace, Name:
build.Name},
Spec: buildv1.BuildConfigSpec{
diff --git a/controllers/builder/openshiftbuilder_test.go
b/controllers/builder/openshiftbuilder_test.go
index 5dc21eaf..bd992c3b 100644
--- a/controllers/builder/openshiftbuilder_test.go
+++ b/controllers/builder/openshiftbuilder_test.go
@@ -47,10 +47,10 @@ func Test_openshiftBuilderManager_Reconcile(t *testing.T) {
buildClient := buildfake.NewSimpleClientset().BuildV1()
managerContext := buildManagerContext{
- ctx: context.TODO(),
- client: client,
- platform: platform,
- commonConfig: config,
+ ctx: context.TODO(),
+ client: client,
+ platform: platform,
+ builderConfigMap: config,
}
buildManager := newOpenShiftBuilderManagerWithClient(managerContext,
buildClient)
@@ -110,10 +110,10 @@ func Test_openshiftbuilder_externalCMs(t *testing.T) {
buildClient := buildfake.NewSimpleClientset().BuildV1()
managerContext := buildManagerContext{
- ctx: context.TODO(),
- client: client,
- platform: platform,
- commonConfig: config,
+ ctx: context.TODO(),
+ client: client,
+ platform: platform,
+ builderConfigMap: config,
}
buildManager := newOpenShiftBuilderManagerWithClient(managerContext,
buildClient)
diff --git a/controllers/cfg/controllers_cfg.go
b/controllers/cfg/controllers_cfg.go
new file mode 100644
index 00000000..05e409cf
--- /dev/null
+++ b/controllers/cfg/controllers_cfg.go
@@ -0,0 +1,92 @@
+// 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.
+
+// note: we use `cfg` instead of `config` or `configuration` in order to have
a shorter accessor in the codebase.
+
+package cfg
+
+import (
+ "bytes"
+ "os"
+
+ "github.com/apache/incubator-kie-kogito-serverless-operator/log"
+ "github.com/imdario/mergo"
+ "k8s.io/apimachinery/pkg/util/yaml"
+ "k8s.io/klog/v2"
+)
+
+const (
+ defaultConfigMountPath = "/config/controllers_cfg.yaml"
+)
+
+var controllersCfg *ControllersCfg
+
+var defaultControllersCfg = &ControllersCfg{
+ HealthFailureThresholdDevMode: 50,
+ DefaultPvcKanikoSize: "1Gi",
+ KanikoDefaultWarmerImageTag: "gcr.io/kaniko-project/warmer:v1.9.0",
+ KanikoExecutorImageTag: "gcr.io/kaniko-project/executor:v1.9.0",
+ BuilderConfigMapName: "sonataflow-operator-builder-config",
+}
+
+type ControllersCfg struct {
+ DefaultPvcKanikoSize string
`yaml:"defaultPvcKanikoSize,omitempty"`
+ HealthFailureThresholdDevMode int32
`yaml:"healthFailureThresholdDevMode,omitempty"`
+ KanikoDefaultWarmerImageTag string
`yaml:"kanikoDefaultWarmerImageTag,omitempty"`
+ KanikoExecutorImageTag string
`yaml:"kanikoExecutorImageTag,omitempty"`
+ JobsServicePostgreSQLImageTag string
`yaml:"jobsServicePostgreSQLImageTag,omitempty"`
+ JobsServiceEphemeralImageTag string
`yaml:"jobsServiceEphemeralImageTag,omitempty"`
+ DataIndexPostgreSQLImageTag string
`yaml:"dataIndexPostgreSQLImageTag,omitempty"`
+ DataIndexEphemeralImageTag string
`yaml:"dataIndexEphemeralImageTag,omitempty"`
+ SonataFlowBaseBuilderImageTag string
`yaml:"sonataFlowBaseBuilderImageTag,omitempty"`
+ SonataFlowDevModeImageTag string
`yaml:"sonataFlowDevModeImageTag,omitempty"`
+ BuilderConfigMapName string
`yaml:"builderConfigMapName,omitempty"`
+}
+
+// InitializeControllersCfg initializes the platform configuration for this
instance.
+// Must be called at the main initialization point.
+//
+// For the main initialization, the configuration is discarded since the
controllers will read the cache instance.
+// We keep the pointer return here to make sure we can access it from tests if
needed or implement an optional use the defaults if fail to read.
+func InitializeControllersCfg() (*ControllersCfg, error) {
+ return InitializeControllersCfgAt(defaultConfigMountPath)
+}
+
+// InitializeControllersCfgAt same as InitializeControllersCfg receiving a
path as input.
+func InitializeControllersCfgAt(configFilePath string) (*ControllersCfg,
error) {
+ controllersCfg = nil
+ yamlFile, err := os.ReadFile(configFilePath)
+ if err != nil {
+ klog.V(log.E).ErrorS(err, "Failed to read controllers config
file", "YAML file location", defaultConfigMountPath)
+ return defaultControllersCfg, err
+ }
+ err = yaml.NewYAMLOrJSONDecoder(bytes.NewReader(yamlFile),
100).Decode(&controllersCfg)
+ if err != nil {
+ klog.V(log.E).ErrorS(err, "Failed to unmarshal controllers
config file", "YAML file location", defaultConfigMountPath)
+ return defaultControllersCfg, err
+ }
+ if err = mergo.Merge(controllersCfg, defaultControllersCfg); err != nil
{
+ return defaultControllersCfg, err
+ }
+ return controllersCfg, nil
+}
+
+func GetCfg() *ControllersCfg {
+ // Guard to use defaults in local tests
+ // In runtime, main.go calls InitializeControllersCfg to set the cache.
+ if controllersCfg == nil {
+ return defaultControllersCfg
+ }
+ return controllersCfg
+}
diff --git a/controllers/cfg/controllers_cfg_test.go
b/controllers/cfg/controllers_cfg_test.go
new file mode 100644
index 00000000..d2d092dc
--- /dev/null
+++ b/controllers/cfg/controllers_cfg_test.go
@@ -0,0 +1,52 @@
+// 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 cfg
+
+import (
+ "os"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestInitializeControllersCfgAt_ValidFile(t *testing.T) {
+ cfg, err :=
InitializeControllersCfgAt("./testdata/controllers-cfg-test.yaml")
+ assert.NoError(t, err)
+ assert.NotNil(t, cfg)
+
+ assert.Equal(t, int32(555), cfg.HealthFailureThresholdDevMode)
+ assert.Equal(t, "2Gi", cfg.DefaultPvcKanikoSize)
+ assert.Equal(t, "local/jobs-service:1.0.0",
cfg.JobsServicePostgreSQLImageTag)
+ assert.Equal(t, "local/data-index:1.0.0",
cfg.DataIndexPostgreSQLImageTag)
+ assert.Equal(t, "local/sonataflow-builder:1.0.0",
cfg.SonataFlowBaseBuilderImageTag)
+ assert.Equal(t, "local/sonataflow-devmode:1.0.0",
cfg.SonataFlowDevModeImageTag)
+}
+
+func TestInitializeControllersCfgAt_FileNotFound(t *testing.T) {
+ cfg, err := InitializeControllersCfgAt("./whatever.yaml")
+ assert.Error(t, err)
+ assert.NotNil(t, cfg) //get the default
+ assert.True(t, os.IsNotExist(err))
+ // defaults
+ assert.Equal(t, defaultControllersCfg, cfg)
+}
+
+func TestInitializeControllersCfgAt_NotValidYaml(t *testing.T) {
+ cfg, err :=
InitializeControllersCfgAt("./testdata/controllers-cfg-invalid.yaml")
+ assert.NoError(t, err)
+ assert.NotNil(t, cfg)
+ // defaults
+ assert.Equal(t, defaultControllersCfg, cfg)
+}
diff --git a/controllers/cfg/testdata/controllers-cfg-invalid.yaml
b/controllers/cfg/testdata/controllers-cfg-invalid.yaml
new file mode 100644
index 00000000..3d10351d
--- /dev/null
+++ b/controllers/cfg/testdata/controllers-cfg-invalid.yaml
@@ -0,0 +1,15 @@
+# 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.
+
+anyThingNotValid: "true"
diff --git a/controllers/cfg/testdata/controllers-cfg-test.yaml
b/controllers/cfg/testdata/controllers-cfg-test.yaml
new file mode 100644
index 00000000..66ec30d8
--- /dev/null
+++ b/controllers/cfg/testdata/controllers-cfg-test.yaml
@@ -0,0 +1,23 @@
+# 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.
+
+# The default size of Kaniko PVC when using the internal operator builder
manager
+defaultPvcKanikoSize: 2Gi
+healthFailureThresholdDevMode: 555
+kanikoDefaultWarmerImageTag: gcr.io/kaniko-project/warmer:v1.0.0
+kanikoExecutorImageTag: gcr.io/kaniko-project/executor:v1.0.0
+jobsServicePostgreSQLImageTag: "local/jobs-service:1.0.0"
+dataIndexPostgreSQLImageTag: "local/data-index:1.0.0"
+sonataFlowBaseBuilderImageTag: "local/sonataflow-builder:1.0.0"
+sonataFlowDevModeImageTag: "local/sonataflow-devmode:1.0.0"
diff --git a/controllers/platform/initialize.go
b/controllers/platform/initialize.go
index 492cd079..d1bfb07b 100644
--- a/controllers/platform/initialize.go
+++ b/controllers/platform/initialize.go
@@ -22,6 +22,7 @@ package platform
import (
"context"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"k8s.io/klog/v2"
corev1 "k8s.io/api/core/v1"
@@ -40,7 +41,6 @@ import (
)
const (
- defaultKanikoPVCSize = "1Gi"
defaultKanikoCachePVCName = "kogito-kaniko-cache-pv"
)
@@ -112,7 +112,7 @@ func (action *initializeAction) Handle(ctx context.Context,
platform *operatorap
// TODO: move this to Kaniko packages based on the platform context
func createPersistentVolumeClaim(ctx context.Context, client client.Client,
platform *operatorapi.SonataFlowPlatform) error {
- volumeSize, err := resource.ParseQuantity(defaultKanikoPVCSize)
+ volumeSize, err :=
resource.ParseQuantity(cfg.GetCfg().DefaultPvcKanikoSize)
if err != nil {
return err
}
diff --git a/controllers/platform/kaniko_cache.go
b/controllers/platform/kaniko_cache.go
index 251e5a8f..df3b8067 100644
--- a/controllers/platform/kaniko_cache.go
+++ b/controllers/platform/kaniko_cache.go
@@ -21,25 +21,24 @@ package platform
import (
"context"
- "fmt"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/client"
-
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/defaults"
-
v08
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/client"
)
// kanikoCacheDir is the cache directory for Kaniko builds (mounted into the
Kaniko pod).
-const kanikoCacheDir = "/kaniko/cache"
-const kanikoPVCName = "KanikoPersistentVolumeClaim"
-const kanikoWarmerImage = "KanikoWarmerImage"
-const kanikoBuildCacheEnabled = "KanikoBuildCacheEnabled"
-const kanikoDefaultWarmerImageName = "gcr.io/kaniko-project/warmer"
+const (
+ kanikoCacheDir = "/kaniko/cache"
+ kanikoPVCName = "KanikoPersistentVolumeClaim"
+ kanikoWarmerImage = "KanikoWarmerImage"
+ kanikoBuildCacheEnabled = "KanikoBuildCacheEnabled"
+)
func IsKanikoCacheEnabled(platform *v08.SonataFlowPlatform) bool {
return
platform.Spec.Build.Config.IsStrategyOptionEnabled(kanikoBuildCacheEnabled)
@@ -62,7 +61,7 @@ func createKanikoCacheWarmerPod(ctx context.Context, client
client.Client, platf
if image, found :=
platform.Spec.Build.Config.BuildStrategyOptions[kanikoWarmerImage]; found {
warmerImage = image
} else {
- warmerImage = fmt.Sprintf("%s:v%s",
kanikoDefaultWarmerImageName, defaults.KanikoVersion)
+ warmerImage = cfg.GetCfg().KanikoDefaultWarmerImageTag
}
pod := corev1.Pod{
diff --git a/controllers/platform/platform.go b/controllers/platform/platform.go
index 0a648058..69b636dc 100644
--- a/controllers/platform/platform.go
+++ b/controllers/platform/platform.go
@@ -45,7 +45,6 @@ const (
OperatorWatchNamespaceEnvVariable = "WATCH_NAMESPACE"
operatorNamespaceEnvVariable = "NAMESPACE"
- operatorPodNameEnvVariable = "POD_NAME"
)
// Copied from
https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry
diff --git a/controllers/platform/platformutils.go
b/controllers/platform/platformutils.go
index ae14c40e..f88863bf 100644
--- a/controllers/platform/platformutils.go
+++ b/controllers/platform/platformutils.go
@@ -36,7 +36,6 @@ import (
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/workflowdef"
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/client"
-
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/defaults"
"github.com/apache/incubator-kie-kogito-serverless-operator/log"
operatorapi
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
@@ -133,10 +132,6 @@ func setPlatformDefaults(p
*operatorapi.SonataFlowPlatform, verbose bool) error
func setStatusAdditionalInfo(platform *operatorapi.SonataFlowPlatform) {
platform.Status.Info = make(map[string]string)
- klog.V(log.D).InfoS("SonataFlow Platform setting build publish
strategy", "namespace", platform.Namespace)
- if platform.Spec.Build.Config.BuildStrategy ==
operatorapi.OperatorBuildStrategy {
- platform.Status.Info["kanikoVersion"] = defaults.KanikoVersion
- }
klog.V(log.D).InfoS("SonataFlow setting status info", "namespace",
platform.Namespace)
platform.Status.Info["goVersion"] = runtime.Version()
platform.Status.Info["goOS"] = runtime.GOOS
@@ -163,9 +158,9 @@ func GetRegistryAddress(ctx context.Context, c
client.Client) (*string, error) {
return nil, nil
}
-// GetCustomizedDockerfile gets the Dockerfile as defined in the default
platform ConfigMap, apply any custom requirements and return.
-func GetCustomizedDockerfile(dockerfile string, platform
operatorapi.SonataFlowPlatform) string {
- if platform.Spec.Build.Config.BaseImage != "" {
+// GetCustomizedBuilderDockerfile gets the Dockerfile as defined in the
default platform ConfigMap, apply any custom requirements and return.
+func GetCustomizedBuilderDockerfile(dockerfile string, platform
operatorapi.SonataFlowPlatform) string {
+ if len(platform.Spec.Build.Config.BaseImage) > 0 {
res :=
builderDockerfileFromRE.FindAllStringSubmatch(dockerfile, 1)
dockerfile = strings.Replace(dockerfile,
strings.Trim(res[0][1], " "), platform.Spec.Build.Config.BaseImage, 1)
}
diff --git a/controllers/platform/platformutils_test.go
b/controllers/platform/platformutils_test.go
index 0707250d..f1119036 100644
--- a/controllers/platform/platformutils_test.go
+++ b/controllers/platform/platformutils_test.go
@@ -37,14 +37,14 @@ func TestSonataFlowBuildController(t *testing.T) {
}
dockerfile := string(dockerfileBytes)
// 1 - Let's verify that the default image is used (for this unit test
is quay.io/kiegroup/kogito-swf-builder-nightly:latest)
- resDefault := GetCustomizedDockerfile(dockerfile, *platform)
+ resDefault := GetCustomizedBuilderDockerfile(dockerfile, *platform)
foundDefault, err := regexp.MatchString("FROM
quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder", resDefault)
assert.NoError(t, err)
assert.True(t, foundDefault)
// 2 - Let's try to override using the productized image
platform.Spec.Build.Config.BaseImage =
"registry.access.redhat.com/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8"
- resProductized := GetCustomizedDockerfile(dockerfile, *platform)
+ resProductized := GetCustomizedBuilderDockerfile(dockerfile, *platform)
foundProductized, err := regexp.MatchString("FROM
registry.access.redhat.com/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8
AS builder", resProductized)
assert.NoError(t, err)
assert.True(t, foundProductized)
diff --git a/controllers/platform/services/services.go
b/controllers/platform/services/services.go
index 55e7e72a..8bd6d19e 100644
--- a/controllers/platform/services/services.go
+++ b/controllers/platform/services/services.go
@@ -22,6 +22,7 @@ package services
import (
"fmt"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
@@ -45,7 +46,7 @@ type PlatformServiceHandler interface {
GetContainerName() string
// GetServiceImageName returns the image name of the service's
container. It takes in the service and persistence types and returns a string
// that contains the FQDN of the image, including the tag.
- GetServiceImageName(persistenceName string) string
+ GetServiceImageName(persistenceName constants.PersistenceType) string
// GetServiceName returns the name of the kubernetes service prefixed
with the platform name
GetServiceName() string
// GetServiceCmName returns the name of the configmap associated to the
service
@@ -101,7 +102,13 @@ func (d DataIndexHandler) GetContainerName() string {
return constants.DataIndexServiceName
}
-func (d DataIndexHandler) GetServiceImageName(persistenceName string) string {
+func (d DataIndexHandler) GetServiceImageName(persistenceType
constants.PersistenceType) string {
+ if persistenceType == constants.PersistenceTypePostgreSQL &&
len(cfg.GetCfg().DataIndexPostgreSQLImageTag) > 0 {
+ return cfg.GetCfg().DataIndexPostgreSQLImageTag
+ }
+ if persistenceType == constants.PersistenceTypeEphemeral &&
len(cfg.GetCfg().DataIndexEphemeralImageTag) > 0 {
+ return cfg.GetCfg().DataIndexEphemeralImageTag
+ }
var tag = version.GetMajorMinor()
var suffix = ""
if version.IsSnapshot() {
@@ -110,7 +117,7 @@ func (d DataIndexHandler)
GetServiceImageName(persistenceName string) string {
suffix = constants.ImageNameNightlySuffix
}
// returns
"quay.io/kiegroup/kogito-data-index-<persistence_layer>:<tag>"
- return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix,
constants.DataIndexName, persistenceName+suffix, tag)
+ return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix,
constants.DataIndexName, persistenceType.String()+suffix, tag)
}
func (d DataIndexHandler) GetServiceName() string {
@@ -266,7 +273,13 @@ func (j JobServiceHandler) GetContainerName() string {
return constants.JobServiceName
}
-func (j JobServiceHandler) GetServiceImageName(persistenceName string) string {
+func (j JobServiceHandler) GetServiceImageName(persistenceType
constants.PersistenceType) string {
+ if persistenceType == constants.PersistenceTypePostgreSQL &&
len(cfg.GetCfg().JobsServicePostgreSQLImageTag) > 0 {
+ return cfg.GetCfg().JobsServicePostgreSQLImageTag
+ }
+ if persistenceType == constants.PersistenceTypeEphemeral &&
len(cfg.GetCfg().JobsServiceEphemeralImageTag) > 0 {
+ return cfg.GetCfg().JobsServiceEphemeralImageTag
+ }
var tag = version.GetMajorMinor()
var suffix = ""
if version.IsSnapshot() {
@@ -275,7 +288,7 @@ func (j JobServiceHandler)
GetServiceImageName(persistenceName string) string {
suffix = constants.ImageNameNightlySuffix
}
// returns
"quay.io/kiegroup/kogito-jobs-service-<persistece_layer>:<tag>"
- return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix,
constants.JobServiceName, persistenceName+suffix, tag)
+ return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix,
constants.JobServiceName, persistenceType.String()+suffix, tag)
}
func (j JobServiceHandler) GetServiceName() string {
diff --git a/controllers/profiles/common/constants/platform_services.go
b/controllers/profiles/common/constants/platform_services.go
index c0bc5086..30b25fb2 100644
--- a/controllers/profiles/common/constants/platform_services.go
+++ b/controllers/profiles/common/constants/platform_services.go
@@ -23,8 +23,6 @@ const (
QuarkusHTTP = "quarkus-http"
ConfigMapWorkflowPropsVolumeName = "workflow-properties"
- PersistenceTypePostgreSQL = "postgresql"
- PersistenceTypeEphemeral = "ephemeral"
JobServiceRequestEventsURL =
"mp.messaging.outgoing.kogito-job-service-job-request-events.url"
JobServiceRequestEventsConnector =
"mp.messaging.outgoing.kogito-job-service-job-request-events.connector"
@@ -34,7 +32,6 @@ const (
JobServiceDataSourceReactiveURL = "quarkus.datasource.reactive.url"
JobServiceJobEventsPath = "/v2/jobs/events"
- KogitoProcessEventsProtocol = "http"
KogitoProcessInstancesEventsURL =
"mp.messaging.outgoing.kogito-processinstances-events.url"
KogitoProcessInstancesEventsEnabled =
"kogito.events.processinstances.enabled"
KogitoProcessInstancesEventsPath = "/processes"
@@ -70,3 +67,14 @@ const (
DefaultDatabaseName string = "sonataflow"
DefaultPostgreSQLPort int = 5432
)
+
+type PersistenceType string
+
+const (
+ PersistenceTypePostgreSQL PersistenceType = "postgresql"
+ PersistenceTypeEphemeral PersistenceType = "ephemeral"
+)
+
+func (p PersistenceType) String() string {
+ return string(p)
+}
diff --git a/controllers/profiles/common/persistence/postgresql.go
b/controllers/profiles/common/persistence/postgresql.go
index 6da517bf..4bb5f38d 100644
--- a/controllers/profiles/common/persistence/postgresql.go
+++ b/controllers/profiles/common/persistence/postgresql.go
@@ -92,7 +92,7 @@ func ConfigurePostgreSQLEnv(postgresql
*operatorapi.PersistencePostgreSQL, datab
},
{
Name: "QUARKUS_DATASOURCE_DB_KIND",
- Value: constants.PersistenceTypePostgreSQL,
+ Value: constants.PersistenceTypePostgreSQL.String(),
},
{
Name: "QUARKUS_DATASOURCE_JDBC_URL",
diff --git a/controllers/profiles/dev/object_creators_dev.go
b/controllers/profiles/dev/object_creators_dev.go
index 0d947c0f..45f6926c 100644
--- a/controllers/profiles/dev/object_creators_dev.go
+++ b/controllers/profiles/dev/object_creators_dev.go
@@ -22,6 +22,7 @@ package dev
import (
"path"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/profiles"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
@@ -35,11 +36,6 @@ import (
"github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj"
)
-const (
- // healthFailureThresholdDevMode exclusive threshold for devmode given
that it might take longer than the immutable image to start/live/respond.
- healthFailureThresholdDevMode = 50
-)
-
// serviceCreator is an objectCreator for a basic Service for a workflow using
dev profile
// aiming a vanilla Kubernetes Deployment.
// It maps the default HTTP port (80) to the target Java application webserver
on port 8080.
@@ -55,21 +51,21 @@ func serviceCreator(workflow *operatorapi.SonataFlow)
(client.Object, error) {
}
func deploymentCreator(workflow *operatorapi.SonataFlow, plf
*operatorapi.SonataFlowPlatform) (client.Object, error) {
-
obj, err := common.DeploymentCreator(workflow, plf)
if err != nil {
return nil, err
}
deployment := obj.(*appsv1.Deployment)
_, idx := kubeutil.GetContainerByName(operatorapi.DefaultContainerName,
&deployment.Spec.Template.Spec)
+ healthThreshold := cfg.GetCfg().HealthFailureThresholdDevMode
if workflow.Spec.PodTemplate.Container.StartupProbe == nil {
-
deployment.Spec.Template.Spec.Containers[idx].StartupProbe.FailureThreshold =
healthFailureThresholdDevMode
+
deployment.Spec.Template.Spec.Containers[idx].StartupProbe.FailureThreshold =
healthThreshold
}
if workflow.Spec.PodTemplate.Container.LivenessProbe == nil {
-
deployment.Spec.Template.Spec.Containers[idx].LivenessProbe.FailureThreshold =
healthFailureThresholdDevMode
+
deployment.Spec.Template.Spec.Containers[idx].LivenessProbe.FailureThreshold =
healthThreshold
}
if workflow.Spec.PodTemplate.Container.ReadinessProbe == nil {
-
deployment.Spec.Template.Spec.Containers[idx].ReadinessProbe.FailureThreshold =
healthFailureThresholdDevMode
+
deployment.Spec.Template.Spec.Containers[idx].ReadinessProbe.FailureThreshold =
healthThreshold
}
return deployment, nil
}
diff --git a/controllers/profiles/dev/profile_dev_test.go
b/controllers/profiles/dev/profile_dev_test.go
index 1c3478ea..c5671faf 100644
--- a/controllers/profiles/dev/profile_dev_test.go
+++ b/controllers/profiles/dev/profile_dev_test.go
@@ -24,6 +24,7 @@ import (
"sort"
"testing"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"k8s.io/client-go/rest"
corev1 "k8s.io/api/core/v1"
@@ -67,7 +68,7 @@ func Test_OverrideStartupProbe(t *testing.T) {
// get the deployment, change the probe and reconcile it again
newThreshold := int32(5) //yes we have to force the type for the
assertion below
deployment := test.MustGetDeployment(t, client, workflow)
- assert.Equal(t, int32(healthFailureThresholdDevMode),
deployment.Spec.Template.Spec.Containers[0].StartupProbe.FailureThreshold)
+ assert.Equal(t, cfg.GetCfg().HealthFailureThresholdDevMode,
deployment.Spec.Template.Spec.Containers[0].StartupProbe.FailureThreshold)
deployment.Spec.Template.Spec.Containers[0].StartupProbe.FailureThreshold =
newThreshold
assert.NoError(t, client.Update(context.TODO(), deployment))
// reconcile and fetch from the cluster
diff --git a/controllers/sonataflowplatform_controller_test.go
b/controllers/sonataflowplatform_controller_test.go
index abfffb20..022c7606 100644
--- a/controllers/sonataflowplatform_controller_test.go
+++ b/controllers/sonataflowplatform_controller_test.go
@@ -40,7 +40,7 @@ import (
var (
envDBKind = corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_DB_KIND",
- Value: constants.PersistenceTypePostgreSQL,
+ Value: constants.PersistenceTypePostgreSQL.String(),
}
envDataIndex = corev1.EnvVar{
@@ -130,7 +130,7 @@ func TestSonataFlowPlatformController(t *testing.T) {
env := corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_DB_KIND",
- Value: constants.PersistenceTypePostgreSQL,
+ Value: constants.PersistenceTypePostgreSQL.String(),
}
assert.Len(t, dep.Spec.Template.Spec.Containers, 1)
assert.Equal(t,
di.GetServiceImageName(constants.PersistenceTypeEphemeral),
dep.Spec.Template.Spec.Containers[0].Image)
@@ -216,7 +216,7 @@ func TestSonataFlowPlatformController(t *testing.T) {
env := corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_DB_KIND",
- Value: constants.PersistenceTypePostgreSQL,
+ Value: constants.PersistenceTypePostgreSQL.String(),
}
assert.Len(t, dep.Spec.Template.Spec.Containers, 1)
assert.Equal(t,
di.GetServiceImageName(constants.PersistenceTypeEphemeral),
dep.Spec.Template.Spec.Containers[0].Image)
@@ -294,7 +294,7 @@ func TestSonataFlowPlatformController(t *testing.T) {
}
dbSourceKind := corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_DB_KIND",
- Value: constants.PersistenceTypePostgreSQL,
+ Value: constants.PersistenceTypePostgreSQL.String(),
}
dbSourceDIURL := corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_JDBC_URL",
@@ -398,7 +398,7 @@ func TestSonataFlowPlatformController(t *testing.T) {
}
dbSourceKind := corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_DB_KIND",
- Value: constants.PersistenceTypePostgreSQL,
+ Value: constants.PersistenceTypePostgreSQL.String(),
}
dbDIUsername := corev1.EnvVar{
Name: "QUARKUS_DATASOURCE_USERNAME",
diff --git a/controllers/workflowdef/image.go b/controllers/workflowdef/image.go
index 760a233e..220aa209 100644
--- a/controllers/workflowdef/image.go
+++ b/controllers/workflowdef/image.go
@@ -21,6 +21,7 @@ package workflowdef
import (
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
"github.com/apache/incubator-kie-kogito-serverless-operator/version"
)
@@ -29,7 +30,6 @@ const (
nightlySuffix = "nightly"
defaultWorkflowDevModeImage = "quay.io/kiegroup/kogito-swf-devmode"
defaultWorkflowBuilderImage = "quay.io/kiegroup/kogito-swf-builder"
- defaultOperatorImage =
"quay.io/kiegroup/kogito-serverless-operator"
)
// GetWorkflowAppImageNameTag returns the image name with tag to use for the
image to be produced for a given workflow.
@@ -49,17 +49,19 @@ func GetWorkflowAppImageNameTag(w *v1alpha08.SonataFlow)
string {
}
func GetDefaultWorkflowDevModeImageTag() string {
+ if len(cfg.GetCfg().SonataFlowDevModeImageTag) > 0 {
+ return cfg.GetCfg().SonataFlowDevModeImageTag
+ }
return GetDefaultImageTag(defaultWorkflowDevModeImage)
}
func GetDefaultWorkflowBuilderImageTag() string {
+ if len(cfg.GetCfg().SonataFlowBaseBuilderImageTag) > 0 {
+ return cfg.GetCfg().SonataFlowBaseBuilderImageTag
+ }
return GetDefaultImageTag(defaultWorkflowBuilderImage)
}
-func GetDefaultOperatorImageTag() string {
- return GetDefaultImageTag(defaultOperatorImage)
-}
-
func GetDefaultImageTag(imgTag string) string {
if version.IsSnapshot() {
imgTag += "-" + nightlySuffix
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index ba1e3638..2112d86e 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -168,13 +168,12 @@ See the section on [README](../README.md#getting-started)
A configmap called `sonataflow-operator-builder-config` will be created under
the `sonataflow-operator-system` namespace
when the Operator will be installed, and it contains:
-- DEFAULT_BUILDER_RESOURCE = Dockerfile
- DEFAULT_WORKFLOW_EXTENSION = .sw.json
- Dockerfile = `<dockerfile content>`
## Customize Builder Image
-At the startup a
[Dockerfile](../config/manager/sonataflow_builder_dockerfile.yaml) is placed in
a configmap. This
+At the startup a
[Dockerfile](../config/manager/SonataFlow-Builder.containerfile) is placed in a
configmap. This
Dockerfile uses a base image
called
[kogito-swf-builder](https://github.com/kiegroup/kogito-images/tree/master/modules/kogito-swf-builder)
with:
diff --git a/go.mod b/go.mod
index 4f650cf7..cecb57f4 100644
--- a/go.mod
+++ b/go.mod
@@ -74,7 +74,6 @@ require (
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
- github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
diff --git a/go.sum b/go.sum
index 86d6dfce..f6b34f62 100644
--- a/go.sum
+++ b/go.sum
@@ -371,8 +371,6 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod
h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX
github.com/hashicorp/go-syslog v1.0.0/go.mod
h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod
h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1/go.mod
h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
-github.com/hashicorp/go-version v1.6.0
h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
-github.com/hashicorp/go-version v1.6.0/go.mod
h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod
h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod
h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod
h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
diff --git a/hack/local/run-e2e.sh b/hack/local/run-e2e.sh
index a048fad7..af20051c 100755
--- a/hack/local/run-e2e.sh
+++ b/hack/local/run-e2e.sh
@@ -23,6 +23,7 @@ echo "Using minikube profile ${MINIKUBE_PROFILE}"
export OPERATOR_IMAGE_NAME=localhost/kogito-serverless-operator:0.0.1
# clean up previous runs
+kubectl get namespaces -o name | awk -F/ '/^namespace\/test/ {print $2}' |
xargs kubectl delete namespace
make undeploy ignore-not-found=true
make deploy IMG="${OPERATOR_IMAGE_NAME}"
@@ -31,4 +32,6 @@ if ! make docker-build IMG="${OPERATOR_IMAGE_NAME}"; then
echo "Failure: Failed to build image, exiting " >&2
exit 1
fi
+
+make deploy IMG="${OPERATOR_IMAGE_NAME}"
make test-e2e
diff --git a/main.go b/main.go
index 240a1d2f..2e39652c 100644
--- a/main.go
+++ b/main.go
@@ -23,6 +23,7 @@ import (
"flag"
"os"
+
"github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg"
eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1"
@@ -91,6 +92,12 @@ func main() {
utils.SetIsOpenShift(mgr.GetConfig())
+ // Fail fast, we can change this behavior in the future to read from
defaults instead.
+ if _, err = cfg.InitializeControllersCfg(); err != nil {
+ klog.V(log.E).ErrorS(err, "unable to read controllers
configuration file")
+ os.Exit(1)
+ }
+
if err = (&controllers.SonataFlowReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
diff --git a/operator.yaml b/operator.yaml
index 939c060a..ef09c6cb 100644
--- a/operator.yaml
+++ b/operator.yaml
@@ -26857,7 +26857,6 @@ subjects:
---
apiVersion: v1
data:
- DEFAULT_BUILDER_RESOURCE_NAME: Dockerfile
DEFAULT_WORKFLOW_EXTENSION: .sw.json
Dockerfile: "FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS
builder\n\n#
variables that can be overridden by the builder\n# To add a Quarkus
extension
@@ -26881,21 +26880,38 @@ metadata:
---
apiVersion: v1
data:
- controller_manager_config.yaml: |
- apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
- kind: ControllerManagerConfig
- health:
- healthProbeBindAddress: :8081
- metrics:
- bindAddress: 127.0.0.1:8080
- webhook:
- port: 9443
- leaderElection:
- leaderElect: true
- resourceName: 1be5e57d.kiegroup.org
+ controllers_cfg.yaml: |
+ # The default size of Kaniko PVC when using the internal operator builder
manager
+ defaultPvcKanikoSize: 1Gi
+ # How much time (in seconds) to wait for a devmode workflow to start.
+ # This information is used for the controller manager to create new
devmode containers and setup the healthcheck probes.
+ healthFailureThresholdDevMode: 50
+ # Default image used internally by the Operator Managed Kaniko builder to
create the warmup pods
+ kanikoDefaultWarmerImageTag: gcr.io/kaniko-project/warmer:v1.9.0
+ # Default image used internally by the Operator Managed Kaniko builder to
create the executor pods
+ kanikoExecutorImageTag: gcr.io/kaniko-project/executor:v1.9.0
+ # The Jobs Service image to use, if empty the operator will use the
default Apache Community one based on the current operator's version
+ jobsServicePostgreSQLImageTag: ""
+ jobsServiceEphemeralImageTag: ""
+ # 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: ""
+ dataIndexEphemeralTag: ""
+ # 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
+ # 2. This configuration
+ # 3. The FROM in the Dockerfile in the operator's namespace
"sonataflow-operator-builder-config" configMap.
+ # If 1 or 2, the FROM tag will be replaced by the tag se there.
+ # If empty the operator will use the default Apache Community one based on
the current operator's version.
+ sonataFlowBaseBuilderImageTag: ""
+ # The image to use to deploy SonataFlow workflow images in devmode profile.
+ # If empty the operator will use the default Apache Community one based on
the current operator's version.
+ sonataFlowDevModeImageTag: ""
+ # The default name of the builder configMap in the operator's namespace
+ builderConfigMapName: "sonataflow-operator-builder-config"
kind: ConfigMap
metadata:
- name: sonataflow-operator-manager-config
+ name: sonataflow-operator-controllers-config
namespace: sonataflow-operator-system
---
apiVersion: v1
@@ -26934,31 +26950,6 @@ spec:
control-plane: sonataflow-operator
spec:
containers:
- - args:
- - --secure-listen-address=0.0.0.0:8443
- - --upstream=http://127.0.0.1:8080/
- - --logtostderr=true
- - --v=0
- image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
- name: kube-rbac-proxy
- ports:
- - containerPort: 8443
- name: https
- protocol: TCP
- resources:
- limits:
- cpu: 500m
- memory: 128Mi
- requests:
- cpu: 5m
- memory: 64Mi
- securityContext:
- allowPrivilegeEscalation: false
- capabilities:
- drop:
- - ALL
- seccompProfile:
- type: RuntimeDefault
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
@@ -26997,7 +26988,40 @@ spec:
capabilities:
drop:
- ALL
+ volumeMounts:
+ - mountPath: /config/controllers_cfg.yaml
+ name: controllers-config
+ subPath: controllers_cfg.yaml
+ - args:
+ - --secure-listen-address=0.0.0.0:8443
+ - --upstream=http://127.0.0.1:8080/
+ - --logtostderr=true
+ - --v=0
+ image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
+ name: kube-rbac-proxy
+ ports:
+ - containerPort: 8443
+ name: https
+ protocol: TCP
+ resources:
+ limits:
+ cpu: 500m
+ memory: 128Mi
+ requests:
+ cpu: 5m
+ memory: 64Mi
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop:
+ - ALL
+ seccompProfile:
+ type: RuntimeDefault
securityContext:
runAsNonRoot: true
serviceAccountName: sonataflow-operator-controller-manager
terminationGracePeriodSeconds: 10
+ volumes:
+ - configMap:
+ name: sonataflow-operator-controllers-config
+ name: controllers-config
diff --git a/testbdd/installers/sonataflow_installer.go
b/testbdd/installers/sonataflow_installer.go
index f9520f64..1b528bcb 100644
--- a/testbdd/installers/sonataflow_installer.go
+++ b/testbdd/installers/sonataflow_installer.go
@@ -33,6 +33,8 @@ import (
srvframework
"github.com/apache/incubator-kie-kogito-serverless-operator/testbdd/framework"
)
+const defaultOperatorImage = "quay.io/kiegroup/kogito-serverless-operator"
+
var (
// sonataFlowYamlClusterInstaller installs SonataFlow operator cluster
wide using YAMLs
sonataFlowYamlClusterInstaller =
installers.YamlClusterWideServiceInstaller{
@@ -101,7 +103,7 @@ func installSonataFlowUsingYaml() error {
return err
}
- regexp, err := regexp.Compile(workflowdef.GetDefaultOperatorImageTag())
+ regexp, err := regexp.Compile(getDefaultOperatorImageTag())
if err != nil {
return err
}
@@ -191,3 +193,7 @@ func cleanupSonataFlowCrsInNamespace(namespace string) bool
{
}
return true
}
+
+func getDefaultOperatorImageTag() string {
+ return workflowdef.GetDefaultImageTag(defaultOperatorImage)
+}
diff --git a/utils/common.go b/utils/common.go
index c105f2a8..e24e8691 100644
--- a/utils/common.go
+++ b/utils/common.go
@@ -28,8 +28,6 @@ import (
)
const (
- // DebugV is the default verbosity for the debugger logger
- DebugV = 2
HttpScheme = "http"
)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]