diff --git a/charts/backstage/Chart.yaml b/charts/backstage/Chart.yaml index 6bc9b519..9ebd837a 100644 --- a/charts/backstage/Chart.yaml +++ b/charts/backstage/Chart.yaml @@ -47,4 +47,4 @@ sources: [] # Versions are expected to follow Semantic Versioning (https://semver.org/) # Note that when this chart is published to https://github.com/openshift-helm-charts/charts # it will follow the RHDH versioning 1.y.z -version: 5.14.0 +version: 6.0.0 diff --git a/charts/backstage/README.md b/charts/backstage/README.md index fb961400..49e20ef2 100644 --- a/charts/backstage/README.md +++ b/charts/backstage/README.md @@ -1,7 +1,7 @@ # RHDH Backstage Helm Chart for OpenShift -![Version: 5.14.0](https://img.shields.io/badge/Version-5.14.0-informational?style=flat-square) +![Version: 6.0.0](https://img.shields.io/badge/Version-6.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) A Helm chart for deploying Red Hat Developer Hub, which is a Red Hat supported version of Backstage. @@ -29,7 +29,7 @@ For the **Generally Available** version of this chart, see: helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add redhat-developer https://redhat-developer.github.io/rhdh-chart -helm install my-backstage redhat-developer/backstage --version 5.14.0 +helm install my-backstage redhat-developer/backstage --version 6.0.0 ``` ## Introduction @@ -211,6 +211,9 @@ Kubernetes: `>= 1.27.0-0` | orchestrator.serverlessOperator.enabled | | bool | `true` | | orchestrator.sonataflowPlatform.createDBJobImage | Image for the container used by the create-db job | string | `"{{ .Values.upstream.postgresql.image.registry }}/{{ .Values.upstream.postgresql.image.repository }}:{{ .Values.upstream.postgresql.image.tag }}"` | | orchestrator.sonataflowPlatform.dataIndexImage | Image for the container used by the sonataflow data index, optional and used for disconnected environments | string | `""` | +| orchestrator.sonataflowPlatform.dbCreationJobActiveDeadlineSeconds | Maximum time in seconds for the create-db Job to complete before being terminated | int | `120` | +| orchestrator.sonataflowPlatform.dbCreationJobBackoffLimit | Number of retries for the create-db job if it fails | int | `2` | +| orchestrator.sonataflowPlatform.dbCreationJobTTLSecondsAfterFinished | Time in seconds after which a finished create-db Job is automatically deleted | int | `300` | | orchestrator.sonataflowPlatform.eventing.broker.name | | string | `""` | | orchestrator.sonataflowPlatform.eventing.broker.namespace | | string | `""` | | orchestrator.sonataflowPlatform.externalDBHost | Host for the user-configured external Database | string | `""` | diff --git a/charts/backstage/templates/sonataflows.yaml b/charts/backstage/templates/sonataflows.yaml index d957f89d..d76b7c8a 100644 --- a/charts/backstage/templates/sonataflows.yaml +++ b/charts/backstage/templates/sonataflows.yaml @@ -85,10 +85,11 @@ spec: apiVersion: batch/v1 kind: Job metadata: - name: {{ .Release.Name }}-create-sonataflow-database + name: {{ .Release.Name }}-create-sf-db-{{ .Chart.Version | replace "." "-" }} namespace: {{ .Release.Namespace }} spec: - activeDeadlineSeconds: 120 + ttlSecondsAfterFinished: {{ .Values.orchestrator.sonataflowPlatform.dbCreationJobTTLSecondsAfterFinished }} + activeDeadlineSeconds: {{ .Values.orchestrator.sonataflowPlatform.dbCreationJobActiveDeadlineSeconds }} template: spec: initContainers: @@ -186,11 +187,27 @@ spec: command: [ "sh", "-c" ] {{- if .Values.upstream.postgresql.enabled }} args: - - "psql -h {{ .Release.Name }}-postgresql{{- if eq .Values.upstream.postgresql.architecture "replication" }}-primary{{- end }} -p 5432 -U postgres -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" + - | + psql -h {{ .Release.Name }}-postgresql{{- if eq .Values.upstream.postgresql.architecture "replication" }}-primary{{- end }} -p 5432 -U postgres -c 'CREATE DATABASE sonataflow;' 2>&1 || { + if psql -h {{ .Release.Name }}-postgresql{{- if eq .Values.upstream.postgresql.architecture "replication" }}-primary{{- end }} -p 5432 -U postgres -tc "SELECT 1 FROM pg_database WHERE datname='sonataflow'" | grep -q 1; then + echo "Database 'sonataflow' already exists, skipping creation." + else + echo "ERROR: Failed to create database 'sonataflow'." + exit 1 + fi + } {{- else }} args: - - "psql -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" + - | + psql -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -c 'CREATE DATABASE sonataflow;' 2>&1 || { + if psql -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -tc "SELECT 1 FROM pg_database WHERE datname='sonataflow'" | grep -q 1; then + echo "Database 'sonataflow' already exists, skipping creation." + else + echo "ERROR: Failed to create database 'sonataflow'." + exit 1 + fi + } {{- end }} restartPolicy: Never - backoffLimit: 2 + backoffLimit: {{ .Values.orchestrator.sonataflowPlatform.dbCreationJobBackoffLimit }} {{- end }} diff --git a/charts/backstage/values.schema.json b/charts/backstage/values.schema.json index d6cf6738..94a2d6ad 100644 --- a/charts/backstage/values.schema.json +++ b/charts/backstage/values.schema.json @@ -475,6 +475,25 @@ "title": "Image for the container used by the sonataflow data index", "type": "string" }, + "dbCreationJobActiveDeadlineSeconds": { + "default": 120, + "minimum": 1, + "title": "Maximum time in seconds for the create-db Job to complete before being terminated", + "type": "integer" + }, + "dbCreationJobBackoffLimit": { + "default": 2, + "maximum": 10, + "minimum": 0, + "title": "Number of retries for the create-db job if it fails", + "type": "integer" + }, + "dbCreationJobTTLSecondsAfterFinished": { + "default": 300, + "minimum": 0, + "title": "Time in seconds after which a finished create-db Job is automatically deleted", + "type": "integer" + }, "eventing": { "additionalProperties": false, "properties": { diff --git a/charts/backstage/values.schema.tmpl.json b/charts/backstage/values.schema.tmpl.json index 00bd3dd9..d47fdf80 100644 --- a/charts/backstage/values.schema.tmpl.json +++ b/charts/backstage/values.schema.tmpl.json @@ -568,6 +568,25 @@ "type": "string", "additionalProperties": false }, + "dbCreationJobBackoffLimit": { + "default": 2, + "maximum": 10, + "minimum": 0, + "title": "Number of retries for the create-db job if it fails", + "type": "integer" + }, + "dbCreationJobTTLSecondsAfterFinished": { + "default": 300, + "minimum": 0, + "title": "Time in seconds after which a finished create-db Job is automatically deleted", + "type": "integer" + }, + "dbCreationJobActiveDeadlineSeconds": { + "default": 120, + "minimum": 1, + "title": "Maximum time in seconds for the create-db Job to complete before being terminated", + "type": "integer" + }, "jobServiceImage": { "title": "Image for the container used by the sonataflow jobs service", "type": "string", diff --git a/charts/backstage/values.yaml b/charts/backstage/values.yaml index eed09725..0be42f06 100644 --- a/charts/backstage/values.yaml +++ b/charts/backstage/values.yaml @@ -533,6 +533,12 @@ orchestrator: initContainerImage: "{{ .Values.upstream.postgresql.image.registry }}/{{ .Values.upstream.postgresql.image.repository }}:{{ .Values.upstream.postgresql.image.tag }}" # -- Image for the container used by the create-db job createDBJobImage: "{{ .Values.upstream.postgresql.image.registry }}/{{ .Values.upstream.postgresql.image.repository }}:{{ .Values.upstream.postgresql.image.tag }}" + # -- Number of retries for the create-db job if it fails + dbCreationJobBackoffLimit: 2 + # -- Time in seconds after which a finished create-db Job is automatically deleted + dbCreationJobTTLSecondsAfterFinished: 300 + # -- Maximum time in seconds for the create-db Job to complete before being terminated + dbCreationJobActiveDeadlineSeconds: 120 # -- Image for the container used by the sonataflow jobs service, optional and used for disconnected environments jobServiceImage: "" # -- Image for the container used by the sonataflow data index, optional and used for disconnected environments