diff --git a/bin/worker b/bin/worker index b0935964..840e9128 100755 --- a/bin/worker +++ b/bin/worker @@ -10,10 +10,6 @@ if ENV['AAPB_HOST'] %x{mkdir ~/.ssh && ssh-keyscan $AAPB_HOST >> ~/.ssh/known_hosts} end -if ENV['IMPORT_WORKER_SIDEKIQ_CONCURRENCY'] - ENV['SIDEKIQ_CONCURRENCY'] = ENV.fetch('IMPORT_WORKER_SIDEKIQ_CONCURRENCY', '10') -end - queues = if !ARGV.empty? ' -q ' + ARGV.join(' -q ') else diff --git a/hyrax/templates/_tmplvalues.tpl b/hyrax/templates/_tmplvalues.tpl new file mode 100644 index 00000000..a8ed7637 --- /dev/null +++ b/hyrax/templates/_tmplvalues.tpl @@ -0,0 +1,38 @@ +{{/* +Copyright VMware, Inc. +SPDX-License-Identifier: APACHE-2.0 +*/}} + +{{/* vim: set filetype=mustache: */}} +{{/* +Renders a value that contains template perhaps with scope if the scope is present. +Usage: +{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }} +{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }} +*/}} +{{- define "common.tplvalues.render" -}} +{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }} +{{- if contains "{{" (toJson .value) }} + {{- if .scope }} + {{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }} + {{- else }} + {{- tpl $value .context }} + {{- end }} +{{- else }} + {{- $value }} +{{- end }} +{{- end -}} + +{{/* +Merge a list of values that contains template after rendering them. +Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge +Usage: +{{ include "common.tplvalues.merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }} +*/}} +{{- define "common.tplvalues.merge" -}} +{{- $dst := dict -}} +{{- range .values -}} +{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}} +{{- end -}} +{{ $dst | toYaml }} +{{- end -}} diff --git a/hyrax/templates/deployment-worker.yaml b/hyrax/templates/deployment-worker.yaml index 8590ea37..ce05afe2 100644 --- a/hyrax/templates/deployment-worker.yaml +++ b/hyrax/templates/deployment-worker.yaml @@ -33,7 +33,9 @@ spec: name: app-secrets {{- end }} env: - {{- toYaml .Values.worker.extraEnvVars | nindent 12 }} + {{- if .Values.worker.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVars "context" $) | nindent 12 }} + {{- end }} command: - sh - -c @@ -71,7 +73,9 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} env: - {{- toYaml .Values.worker.extraEnvVars | nindent 12 }} + {{- if .Values.worker.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVars "context" $) | nindent 12 }} + {{- end }} {{- if .Values.worker.readinessProbe.enabled }} readinessProbe: exec: diff --git a/hyrax/templates/deployment.yaml b/hyrax/templates/deployment.yaml index 5181019c..2a034e27 100644 --- a/hyrax/templates/deployment.yaml +++ b/hyrax/templates/deployment.yaml @@ -42,7 +42,9 @@ spec: name: {{ .Values.solrExistingSecret }} {{- end }} env: - {{- toYaml .Values.extraEnvVars | nindent 12 }} + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} + {{- end }} command: - sh - -c @@ -74,7 +76,9 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} env: - {{- toYaml .Values.extraEnvVars | nindent 12 }} + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} + {{- end }} command: - sh - -c @@ -113,7 +117,9 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} env: - {{- toYaml .Values.extraEnvVars | nindent 12 }} + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} + {{- end }} ports: - name: http containerPort: 3000 diff --git a/hyrax/templates/import-deployment-worker.yaml b/hyrax/templates/import-deployment-worker.yaml index 839762fe..1a8355db 100644 --- a/hyrax/templates/import-deployment-worker.yaml +++ b/hyrax/templates/import-deployment-worker.yaml @@ -33,8 +33,9 @@ spec: name: app-secrets {{- end }} env: - {{- toYaml .Values.worker.extraEnvVars | nindent 12 }} - {{- toYaml .Values.importWorker.extraEnvVars | nindent 12 }} + {{- if .Values.importWorker.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.importWorker.extraEnvVars "context" $) | nindent 12 }} + {{- end }} command: - sh - -c @@ -77,8 +78,9 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} env: - {{- toYaml .Values.worker.extraEnvVars | nindent 12 }} - {{- toYaml .Values.importWorker.extraEnvVars | nindent 12 }} + {{- if .Values.importWorker.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.importWorker.extraEnvVars "context" $) | nindent 12 }} + {{- end }} {{- if .Values.worker.readinessProbe.enabled }} readinessProbe: exec: diff --git a/ops/demo-deploy.tmpl.yaml b/ops/demo-deploy.tmpl.yaml index d9770c1f..1381a5db 100644 --- a/ops/demo-deploy.tmpl.yaml +++ b/ops/demo-deploy.tmpl.yaml @@ -116,8 +116,6 @@ extraEnvVars: &envVars value: "8983" - name: SOLR_URL value: http://10.0.4.190:8983/solr/ams - - name: SIDEKIQ_CONCURRENCY - value: "1" - name: AWS_ACCESS_KEY value: "AKIAIWFN3WW3WBIMKNCQ" - name: MAIL_DELIVERY_METHOD @@ -147,15 +145,24 @@ worker: fsGroup: 101 fsGroupChangePolicy: "OnRootMismatch" extraVolumeMounts: *volMounts - extraEnvVars: *envVars + extraEnvVars: | + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) }} + {{- end }} + - name: SIDEKIQ_CONCURRENCY + value: "1" + importWorker: enabled: false replicaCount: 1 # extraEnvVars will not handle overriden values # only additional to the original workerEnvVars list - extraEnvVars: - - name: IMPORT_WORKER_SIDEKIQ_CONCURRENCY + extraEnvVars: | + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) }} + {{- end }} + - name: SIDEKIQ_CONCURRENCY value: "20" podSecurityContext: diff --git a/ops/prod-deploy.tmpl.yaml b/ops/prod-deploy.tmpl.yaml index 4b3c1fdf..cf6b9b80 100644 --- a/ops/prod-deploy.tmpl.yaml +++ b/ops/prod-deploy.tmpl.yaml @@ -121,8 +121,6 @@ extraEnvVars: &envVars value: "0.1" - name: SETTINGS__BULKRAX__ENABLED value: "false" - - name: SIDEKIQ_CONCURRENCY - value: "1" - name: SIDEKIQ_REDIS_URL value: "redis://:prod@ams-prod-redis-master:6379/0" - name: SMTP_ADDRESS @@ -152,15 +150,21 @@ worker: fsGroup: 101 fsGroupChangePolicy: "OnRootMismatch" extraVolumeMounts: *volMounts - extraEnvVars: *envVars + extraEnvVars: | + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) }} + {{- end }} + - name: SIDEKIQ_CONCURRENCY + value: "1" importWorker: enabled: true replicaCount: 3 - # extraEnvVars will not handle overriden values - # only additional to the original workerEnvVars list - extraEnvVars: - - name: IMPORT_WORKER_SIDEKIQ_CONCURRENCY + extraEnvVars: | + {{- if .Values.extraEnvVars }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) }} + {{- end }} + - name: SIDEKIQ_CONCURRENCY value: "20" podSecurityContext: