dimas-b commented on code in PR #4755:
URL: https://github.com/apache/polaris/pull/4755#discussion_r3417902034


##########
helm/polaris/values.yaml:
##########
@@ -1167,3 +1167,104 @@ tasks:
   # -- The maximum number of tasks that can be queued up for execution. If 
unspecified or zero, defaults to Integer.MAX_VALUE.
   # @section -- Tasks
   maxQueuedTasks: 0  # 1000
+
+# @schema type: object
+# -- Configuration for maintenance tasks using as Kubernetes CronJob
+# @section -- Maintenance
+maintenance:
+  # @schema additionalProperties: {type: string}
+  # -- Annotations to add to every maintenance Cronjob object.
+  # @section -- Maintenance
+  annotations: {}
+
+  # @schema item: object
+  # -- Extra environment variables to add to every maintenance Cronjob object.
+  # @section -- Maintenance
+  extraEnv: []
+  #  - name: AWS_STORAGE_BUCKET
+  #    value: s3://xxxxx/
+  #  - name: AWS_ACCESS_KEY_ID
+  #    valueFrom:
+  #      secretKeyRef:
+  #        name: aws-secret
+  #        key: access_key_id
+  #  - name: AWS_SECRET_ACCESS_KEY
+  #    valueFrom:
+  #      secretKeyRef:
+  #        name: aws-secret
+  #        key: secret_access_key
+
+  # @schema item: object
+  # -- Bulk import environment variables from Secrets or ConfigMaps to every 
maintenance Cronjob object.
+  # @section -- Maintenance
+  envFrom: []
+  #  - secretRef:
+  #      name: polaris-env-secret
+  #  - configMapRef:
+  #      name: polaris-env-configmap
+
+  # @schema item: object
+  # -- Extra volumes to add to every maintenance Cronjob object.
+  # @section -- Maintenance
+  extraVolumes: []
+    # - name: extra-volume
+    #   emptyDir: {}
+
+  # @schema item: object
+  # -- Extra volume mounts to add to every maintenance Cronjob object.
+  # @section -- Maintenance
+  extraVolumeMounts: []
+    # - name: extra-volume
+    #   mountPath: /usr/share/extra-volume
+
+  # -- The container image used by every maintenance Cronjob object.
+  # @section -- Maintenance
+  image:
+    # -- The image repository to pull from for the Polaris admin tool.
+    # @section -- Maintenance
+    repository: apache/polaris-admin-tool
+    # @schema enum: [Always, IfNotPresent, Never]
+    # -- The image pull policy.
+    # @section -- Maintenance
+    pullPolicy: IfNotPresent
+    # -- The image tag.
+    # @section -- Maintenance
+    tag: "latest"  # This tag will be replaced with the chart version at 
release time.
+
+  # @schema additionalProperties: {type: object, required: [schedule]}
+  # -- Define maintenance CronJobs. The key is the name of the job.
+  # @section -- Maintenance
+  jobs:
+    nosql-maintenance:
+      # -- Enable this maintenance job.
+      # @section -- Maintenance
+      enabled: false
+      # -- The schedule in Cron format.
+      # @section -- Maintenance
+      schedule: "0 2 * * *"
+      # -- The arguments to pass tothe admin tool.

Review Comment:
   nit: `to the` (space)



##########
helm/polaris/templates/cronjob-maintenance.yaml:
##########
@@ -0,0 +1,153 @@
+{{/*
+  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.
+*/}}
+
+{{- range $jobName, $jobSpec := .Values.maintenance.jobs }}
+{{- if $jobSpec.enabled }}
+{{- $cronName := printf "%s-maint-%s" (include "polaris.fullname" $) $jobName 
}}
+{{- if gt (len $cronName) 52 }}
+  {{- fail (printf "Maintenance CronJob name %q is %d chars; must be <= 52 
(K8s appends a timestamp+random suffix to generated Pod names, which are capped 
at 63). Shorten release name, nameOverride/fullnameOverride, or the job key 
%q." $cronName (len $cronName) $jobName) }}
+{{- end }}
+---
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+  name: {{ $cronName }}
+  namespace: {{ $.Release.Namespace }}
+  labels:
+    {{- include "polaris.labels" $ | nindent 4 }}
+  {{- with $.Values.maintenance.annotations }}
+  annotations:
+    {{- tpl (toYaml .) $ | nindent 4 }}
+  {{- end }}
+spec:
+  schedule: {{ $jobSpec.schedule | quote }}
+  concurrencyPolicy: {{ default "Forbid" $jobSpec.concurrencyPolicy }}
+  {{- if hasKey $jobSpec "successfulJobsHistoryLimit" }}
+  successfulJobsHistoryLimit: {{ $jobSpec.successfulJobsHistoryLimit }}
+  {{- end }}
+  {{- if hasKey $jobSpec "failedJobsHistoryLimit" }}
+  failedJobsHistoryLimit: {{ $jobSpec.failedJobsHistoryLimit }}
+  {{- end }}
+  jobTemplate:
+    spec:
+      {{- if hasKey $jobSpec "backoffLimit" }}
+      backoffLimit: {{ $jobSpec.backoffLimit }}
+      {{- end }}
+      {{- with $jobSpec.activeDeadlineSeconds }}
+      activeDeadlineSeconds: {{ . }}
+      {{- end }}
+      template:
+        metadata:
+          labels:
+            helm.sh/chart: {{ include "polaris.chart" $ }}
+            app.kubernetes.io/name: {{ include "polaris.name" $ }}-maintenance
+            app.kubernetes.io/instance: {{ $.Release.Name }}
+            app.kubernetes.io/component: maintenance
+            app.kubernetes.io/managed-by: {{ $.Release.Service }}
+            {{- if $.Chart.AppVersion }}
+            app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
+            {{- end }}
+          {{- with $jobSpec.podAnnotations }}
+          annotations:
+            {{- tpl (toYaml .) $ | nindent 12 }}
+          {{- end }}
+        spec:
+          {{- if $.Values.imagePullSecrets }}
+          imagePullSecrets:
+          {{- range $.Values.imagePullSecrets }}
+            - name: {{ . | quote }}
+          {{- end }}
+          {{- end }}
+          restartPolicy: {{ default "Never" $jobSpec.restartPolicy }}
+          {{- with $.Values.priorityClassName }}
+          priorityClassName: {{ tpl . $ | quote }}
+          {{- end }}
+          serviceAccountName: {{ include "polaris.serviceAccountName" $ }}
+          automountServiceAccountToken: false
+          {{- if $.Values.podSecurityContext }}
+          securityContext:
+            {{- tpl (toYaml $.Values.podSecurityContext) $ | nindent 12 }}
+          {{- end }}
+          containers:
+            - name: polaris-admin-tool
+              {{- if $.Values.containerSecurityContext }}
+              securityContext:
+                {{- tpl (toYaml $.Values.containerSecurityContext) $ | nindent 
16 }}
+              {{- end }}
+              image: "{{ tpl $.Values.maintenance.image.repository $ }}:{{ tpl 
$.Values.maintenance.image.tag $ | default $.Chart.Version }}"
+              imagePullPolicy: {{ tpl $.Values.maintenance.image.pullPolicy $ 
}}
+              {{- if $jobSpec.args }}
+              args:
+                {{- range $jobSpec.args }}
+                - {{ . | quote }}
+                {{- end }}
+              {{- end }}
+              {{- with $jobSpec.resources }}
+              resources:
+                {{- tpl (toYaml .) $ | nindent 16 }}
+              {{- end }}
+              env:
+                - name: quarkus.config.locations
+                  value: "file:{{ trimSuffix "/" $.Values.image.configDir 
}}/application.properties"
+                {{- $persistenceEnv := include "polaris.persistenceEnv" $ -}}
+                {{- if and (eq $.Values.persistence.type "nosql") (eq 
$.Values.persistence.nosql.backend "MongoDb") }}
+                - name: quarkus.mongodb.active
+                  value: "true"

Review Comment:
   side note: can we do it in java code? 🤔 



-- 
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]

Reply via email to