MonkeyCanCode commented on code in PR #4755:
URL: https://github.com/apache/polaris/pull/4755#discussion_r3418136666


##########
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:
   I would think so. Once that is completed, we will then be able to remove 
this section. Currently if anyone tried to use the cli for no-sql maintenance, 
they would get the following:
   ```
   ➜ docker run -it apache/polaris-admin-tool:latest nosql
   INFO exec -a "java" java -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC 
-XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 
-XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp "." -jar 
/deployments/polaris-admin-tool.jar nosql
   INFO running in /deployments
   Polaris NoSql persistence has multiple subcommands,
   use the 'help nosql' command.
   
   java.lang.IllegalStateException: Mandatory configuration option 
polaris.persistence.nosql.backend is missing!
   ...
   ```



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