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

use templates and config maps to get the settings for sidekiq the way we want #976

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 2 additions & 6 deletions bin/worker
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ if ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] && !ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE
end

if ENV['DATABASE_URL'] && !ENV['DATABASE_URL'].empty?
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].gsub('pool=5', 'pool=30')
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].gsub('pool=5', "pools=#{ENV.fetch('WORKER_CONCURENCY'), 30}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

Suggested change
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].gsub('pool=5', "pools=#{ENV.fetch('WORKER_CONCURENCY'), 30}")
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].gsub('pool=5', "pools=#{ENV.fetch('WORKER_CONCURRENCY'), 30}")

else
puts 'DATABASE_URL not set, no pool change needed'
end

if ENV['SIDEKIQ_CONFIG']
exec "echo $DATABASE_URL && bundle exec sidekiq -C #{ENV['SIDEKIQ_CONFIG']}"
else
exec "echo $DATABASE_URL && bundle exec sidekiq"
end
exec "echo $DATABASE_URL && RAILS_MAX_THREADS=$WORKER_CONCURENCY bundle exec sidekiq $WORKER_ARGS"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
exec "echo $DATABASE_URL && RAILS_MAX_THREADS=$WORKER_CONCURENCY bundle exec sidekiq $WORKER_ARGS"
exec "echo $DATABASE_URL && RAILS_MAX_THREADS=$WORKER_CONCURRENCY bundle exec sidekiq $WORKER_ARGS"

5 changes: 0 additions & 5 deletions config/sidekiq.yml

This file was deleted.

7 changes: 0 additions & 7 deletions config/sidekiq_auxiliary.yml

This file was deleted.

41 changes: 33 additions & 8 deletions ops/demo-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ worker:
cpu: "150m"
extraVolumeMounts: *volMounts
extraEnvVars: *envVars
extraEnvFrom:
- configMapRef:
name: worker-env
podSecurityContext:
runAsUser: 1001
runAsGroup: 101
Expand All @@ -204,14 +207,35 @@ workerAuxiliary:
requests:
memory: "4Gi"
cpu: "2"
extraEnvVars:
- name: AUXILIARY_WORKER_THREAD_COUNT
value: "1"
- name: SIDEKIQ_CONFIG
value: "config/sidekiq_auxiliary.yml"
extraEnvVars: *envVars
extraEnvFrom:
- configMapRef:
name: auxilary-worker-env
Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn't put this back into pals yet, but in adventist we established this pattern:

  1. Use "aux" instead of "auxiliary"
  2. Put "worker" before "aux"
Suggested change
name: auxilary-worker-env
name: worker-aux-env



extraDeploy:
- |-
---
apiVersion: v1
kind: ConfigMap
metadata:
name: worker-env
labels:
{{- include "hyrax.labels" . | nindent 4 }}
data:
WORKER_CONCURENCY: "5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
WORKER_CONCURENCY: "5"
WORKER_CONCURRENCY: "5"

WORKER_ARGS: -q default -q import -q export
---
apiVersion: v1
kind: ConfigMap
metadata:
name: auxiliary-worker-env
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: auxiliary-worker-env
name: worker-aux-env

labels:
{{- include "hyrax.labels" . | nindent 4 }}
data:
WORKER_CONCURENCY: "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
WORKER_CONCURENCY: "1"
WORKER_CONCURRENCY: "1"

WORKER_ARGS: -q auxiliary -q default -q import -q export
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -241,9 +265,11 @@ extraDeploy:
name: {{ include "hyrax.fullname" . }}-env
- secretRef:
name: {{ template "hyrax.fullname" . }}
{{- with .Values.workerAuxiliary.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- toYaml .Values.workerAuxiliary.extraEnvVars | nindent 12 }}
{{- toYaml .Values.worker.extraEnvVars | nindent 12 }}
command:
- sh
- -c
Expand Down Expand Up @@ -273,12 +299,11 @@ extraDeploy:
- secretRef:
name: {{ .Values.solrExistingSecret }}
{{- end }}
{{- with .Values.worker.extraEnvFrom }}
{{- with .Values.workerAuxiliary.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
env:
{{- toYaml .Values.workerAuxiliary.extraEnvVars | nindent 12 }}
{{- toYaml .Values.worker.extraEnvVars | nindent 12 }}
{{- if .Values.worker.readinessProbe.enabled }}
readinessProbe:
exec:
Expand Down
33 changes: 28 additions & 5 deletions ops/production-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ worker:
cpu: "150m"
extraVolumeMounts: *volMounts
extraEnvVars: *envVars
extraEnvFrom:
- configMapRef:
name: worker-env
podSecurityContext:
runAsUser: 1001
runAsGroup: 101
Expand All @@ -220,14 +223,34 @@ workerAuxiliary:
requests:
memory: "4Gi"
cpu: "2"
extraEnvVars:
- name: AUXILIARY_WORKER_THREAD_COUNT
value: "1"
- name: SIDEKIQ_CONFIG
value: "config/sidekiq_auxiliary.yml"
extraEnvVars: *envVars
extraEnvFrom:
- configMapRef:
name: auxilary-worker-env
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: auxilary-worker-env
name: worker-aux-env


extraDeploy:
- |-
---
apiVersion: v1
kind: ConfigMap
metadata:
name: worker-env
labels:
{{- include "hyrax.labels" . | nindent 4 }}
data:
WORKER_CONCURENCY: "5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
WORKER_CONCURENCY: "5"
WORKER_CONCURRENCY: "5"

WORKER_ARGS: -q default -q import -q export
---
apiVersion: v1
kind: ConfigMap
metadata:
name: auxiliary-worker-env
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: auxiliary-worker-env
name: worker-aux-env

labels:
{{- include "hyrax.labels" . | nindent 4 }}
data:
WORKER_CONCURENCY: "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
WORKER_CONCURENCY: "1"
WORKER_CONCURRENCY: "1"

WORKER_ARGS: -q auxiliary -q default -q import -q export
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
Loading