Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyrax chart should evaluate extraEnvVars #835

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bin/worker
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions hyrax/templates/_tmplvalues.tpl
Original file line number Diff line number Diff line change
@@ -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" -}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"common" should be renamed "hyrax" to be inline with this feedback

{{- $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 -}}
8 changes: 6 additions & 2 deletions hyrax/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 9 additions & 3 deletions hyrax/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions hyrax/templates/import-deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 12 additions & 5 deletions ops/demo-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" $) }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these lines need | nindent 4?

{{- 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:
Expand Down
18 changes: 11 additions & 7 deletions ops/prod-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading