Skip to content

Commit 5b6c954

Browse files
authored
Merge pull request #969 from scientist-softserv/i852-new-worker-to-run-resource-intensive-jobs
i852 New worker to run resource intensive jobs
2 parents 3dffacf + d9f5488 commit 5b6c954

11 files changed

+584
-65
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
AUXILIARY_WORKER_THREAD_COUNT=1
12
CAPYBARA_SERVER=web
23
CHROME_HOSTNAME=seleniarm-hub
34
DB_ADAPTER=postgresql

app/jobs/create_large_derivatives_job.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# CreateLargeDerivativesJob is intended to be used for resource-intensive derivative
44
# generation (e.g. video processing). It is functionally similar to CreateDerivativesJob,
5-
# except that it queues jobs in the :resource_intensive queue.
5+
# except that it queues jobs in the :auxiliary queue.
66
#
7-
# The worker responsible for processing jobs in the :resource_intensive queue should be
7+
# The worker responsible for processing jobs in the :auxiliary queue should be
88
# configured to have more resources dedicated to it, especially CPU. Otherwise, the
99
# `ffmpeg` commands that this job class eventually triggers could be throttled.
1010
#
1111
# @see CreateDerivativesJobDecorator
1212
# @see Hydra::Derivatives::Processors::Ffmpeg
1313
# @see https://github.com/scientist-softserv/palni-palci/issues/852
1414
class CreateLargeDerivativesJob < CreateDerivativesJob
15-
queue_as :resource_intensive
15+
queue_as :auxiliary
1616
end

bin/helm_deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WORKER_IMAGE="${WORKER_IMAGE:-ghcr.io/samvera/hyku/worker}"
2323
DEPLOY_TAG="${DEPLOY_TAG:-latest}"
2424
WORKER_TAG="${WORKER_TAG:-$DEPLOY_TAG}"
2525

26-
helm pull oci://ghcr.io/samvera/charts/hyrax --version 2.0.0 --untar --untardir charts
26+
helm pull oci://ghcr.io/samvera/charts/hyrax --version 3.5.1 --untar --untardir charts
2727

2828
helm repo update
2929

bin/worker

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ else
99
puts 'DATABASE_URL not set, no pool change needed'
1010
end
1111

12-
exec "echo $DATABASE_URL && bundle exec sidekiq"
12+
if ENV['SIDEKIQ_CONFIG']
13+
exec "echo $DATABASE_URL && bundle exec sidekiq -C #{ENV['SIDEKIQ_CONFIG']}"
14+
else
15+
exec "echo $DATABASE_URL && bundle exec sidekiq"
16+
end

config/sidekiq.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
- default
44
- import
55
- export
6-
- resource_intensive

config/sidekiq_auxiliary.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
:concurrency: <%= ENV['AUXILIARY_WORKER_THREAD_COUNT'] %>
3+
:queues:
4+
- auxiliary
5+
- default
6+
- import
7+
- export

docker-compose.yml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,35 @@ x-app: &app
2020
networks:
2121
internal:
2222

23+
x-app-worker: &app-worker
24+
<<: *app
25+
build:
26+
context: .
27+
target: hyku-worker
28+
args:
29+
- EXTRA_APK_PACKAGES=less vim bash openjdk11-jre ffmpeg rsync exiftool
30+
- HYKU_BULKRAX_ENABLED=true
31+
cache_from:
32+
- ghcr.io/scientist-softserv/palni-palci:${TAG:-latest}
33+
- ghcr.io/scientist-softserv/palni-palci/worker:${TAG:-latest}
34+
image: ghcr.io/scientist-softserv/palni-palci/worker:${TAG:-latest}
35+
command: sh -l -c 'bundle && bundle exec sidekiq'
36+
depends_on:
37+
check_volumes:
38+
condition: service_completed_successfully
39+
initialize_app:
40+
condition: service_completed_successfully
41+
db:
42+
condition: service_started
43+
solr:
44+
condition: service_started
45+
fcrepo:
46+
condition: service_started
47+
redis:
48+
condition: service_started
49+
zoo:
50+
condition: service_started
51+
2352
volumes:
2453
assets:
2554
cache:
@@ -145,6 +174,8 @@ services:
145174
condition: service_started
146175
worker:
147176
condition: service_started
177+
worker_auxiliary:
178+
condition: service_started
148179
initialize_app:
149180
condition: service_completed_successfully
150181
# ports:
@@ -153,33 +184,11 @@ services:
153184
- 3000
154185

155186
worker:
156-
<<: *app
157-
build:
158-
context: .
159-
target: hyku-worker
160-
args:
161-
- EXTRA_APK_PACKAGES=less vim bash openjdk11-jre ffmpeg rsync exiftool
162-
- HYKU_BULKRAX_ENABLED=true
163-
cache_from:
164-
- ghcr.io/scientist-softserv/palni-palci:${TAG:-latest}
165-
- ghcr.io/scientist-softserv/palni-palci/worker:${TAG:-latest}
166-
image: ghcr.io/scientist-softserv/palni-palci/worker:${TAG:-latest}
167-
command: sh -l -c 'bundle && bundle exec sidekiq'
168-
depends_on:
169-
check_volumes:
170-
condition: service_completed_successfully
171-
initialize_app:
172-
condition: service_completed_successfully
173-
db:
174-
condition: service_started
175-
solr:
176-
condition: service_started
177-
fcrepo:
178-
condition: service_started
179-
redis:
180-
condition: service_started
181-
zoo:
182-
condition: service_started
187+
<<: *app-worker
188+
189+
worker_auxiliary:
190+
<<: *app-worker
191+
command: sh -l -c 'bundle && bundle exec sidekiq -C config/sidekiq_auxiliary.yml'
183192

184193
# Do not recurse through all of tmp. derivitives will make booting
185194
# very slow and eventually just time out as data grows

ops/demo-deploy.tmpl.yaml

Lines changed: 177 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ ingress:
4747
- host: commons-archive.org
4848
paths:
4949
- path: /
50+
pathType: ImplementationSpecific
5051
- host: "*.commons-archive.org"
5152
paths:
5253
- path: /
53-
annotations: {
54-
kubernetes.io/ingress.class: "nginx",
55-
nginx.ingress.kubernetes.io/proxy-body-size: "0",
56-
cert-manager.io/cluster-issuer: letsencrypt-production-dns
57-
}
54+
pathType: ImplementationSpecific
55+
annotations:
56+
kubernetes.io/ingress.class: "nginx"
57+
nginx.ingress.kubernetes.io/proxy-body-size: "0"
58+
cert-manager.io/cluster-issuer: "letsencrypt-production-dns"
5859
tls:
5960
- hosts:
6061
- commons-archive.org
@@ -191,6 +192,167 @@ worker:
191192
runAsGroup: 101
192193
fsGroup: 101
193194
fsGroupChangePolicy: "OnRootMismatch"
195+
196+
# When adding/removing key-value pairs to this block, ensure the
197+
# corresponding changes are made in the `extraDeploy` block below.
198+
workerAuxiliary:
199+
replicaCount: 1
200+
resources:
201+
limits:
202+
memory: "12Gi"
203+
cpu: "4"
204+
requests:
205+
memory: "4Gi"
206+
cpu: "2"
207+
extraEnvVars:
208+
- name: AUXILIARY_WORKER_THREAD_COUNT
209+
value: "1"
210+
- name: SIDEKIQ_CONFIG
211+
value: "config/sidekiq_auxiliary.yml"
212+
213+
extraDeploy:
214+
- |-
215+
apiVersion: apps/v1
216+
kind: Deployment
217+
metadata:
218+
name: {{ include "hyrax.fullname" . }}-auxiliary-worker
219+
labels:
220+
{{- include "hyrax.labels" . | nindent 4 }}
221+
spec:
222+
replicas: {{ .Values.workerAuxiliary.replicaCount }}
223+
selector:
224+
matchLabels:
225+
{{- include "hyrax.workerSelectorLabels" . | nindent 6 }}
226+
template:
227+
metadata:
228+
{{- with .Values.podAnnotations }}
229+
annotations:
230+
{{- toYaml . | nindent 8 }}
231+
{{- end }}
232+
labels:
233+
{{- include "hyrax.workerSelectorLabels" . | nindent 8 }}
234+
spec:
235+
initContainers:
236+
- name: db-wait
237+
image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag | default .Chart.AppVersion }}"
238+
imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
239+
envFrom:
240+
- configMapRef:
241+
name: {{ include "hyrax.fullname" . }}-env
242+
- secretRef:
243+
name: {{ template "hyrax.fullname" . }}
244+
env:
245+
{{- toYaml .Values.workerAuxiliary.extraEnvVars | nindent 12 }}
246+
{{- toYaml .Values.worker.extraEnvVars | nindent 12 }}
247+
command:
248+
- sh
249+
- -c
250+
- "db-wait.sh {{ include "hyrax.redis.host" . }}:6379"
251+
{{- if .Values.worker.extraInitContainers }}
252+
{{- toYaml .Values.worker.extraInitContainers | nindent 8 }}
253+
{{- end }}
254+
{{- with .Values.imagePullSecrets }}
255+
imagePullSecrets:
256+
{{- toYaml . | nindent 8 }}
257+
{{- end }}
258+
serviceAccountName: {{ include "hyrax.serviceAccountName" . }}
259+
securityContext:
260+
{{- toYaml .Values.worker.podSecurityContext | nindent 8 }}
261+
containers:
262+
- name: {{ .Chart.Name }}-worker
263+
securityContext:
264+
{{- toYaml .Values.worker.securityContext | nindent 12 }}
265+
image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag | default .Chart.AppVersion }}"
266+
imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
267+
envFrom:
268+
- configMapRef:
269+
name: {{ include "hyrax.fullname" . }}-env
270+
- secretRef:
271+
name: {{ template "hyrax.fullname" . }}
272+
{{- if .Values.solrExistingSecret }}
273+
- secretRef:
274+
name: {{ .Values.solrExistingSecret }}
275+
{{- end }}
276+
{{- with .Values.worker.extraEnvFrom }}
277+
{{- toYaml . | nindent 12 }}
278+
{{- end }}
279+
env:
280+
{{- toYaml .Values.workerAuxiliary.extraEnvVars | nindent 12 }}
281+
{{- toYaml .Values.worker.extraEnvVars | nindent 12 }}
282+
{{- if .Values.worker.readinessProbe.enabled }}
283+
readinessProbe:
284+
exec:
285+
command:
286+
{{- toYaml .Values.worker.readinessProbe.command | nindent 16 }}
287+
failureThreshold: {{ .Values.worker.readinessProbe.failureThreshold }}
288+
initialDelaySeconds: {{ .Values.worker.readinessProbe.initialDelaySeconds }}
289+
periodSeconds: {{ .Values.worker.readinessProbe.periodSeconds }}
290+
successThreshold: {{ .Values.worker.readinessProbe.successThreshold }}
291+
timeoutSeconds: {{ .Values.worker.readinessProbe.timeoutSeconds }}
292+
{{- end }}
293+
volumeMounts:
294+
- name: derivatives
295+
mountPath: /app/samvera/derivatives
296+
- name: uploads
297+
subPath: file_cache
298+
mountPath: /app/samvera/file_cache
299+
- name: uploads
300+
subPath: uploads
301+
mountPath: /app/samvera/uploads
302+
{{- if .Values.applicationExistingClaim }}
303+
- name: application
304+
mountPath: /app/samvera/hyrax-webapp
305+
{{- end }}
306+
{{- with .Values.worker.extraVolumeMounts }}
307+
{{- toYaml . | nindent 12 }}
308+
{{- end }}
309+
resources:
310+
{{- toYaml .Values.workerAuxiliary.resources | nindent 12 }}
311+
{{- with .Values.extraContainerConfiguration }}
312+
{{- toYaml . | nindent 10 }}
313+
{{- end }}
314+
volumes:
315+
- name: "derivatives"
316+
{{- if and .Values.derivativesVolume.enabled .Values.derivativesVolume.existingClaim }}
317+
persistentVolumeClaim:
318+
claimName: {{ .Values.derivativesVolume.existingClaim }}
319+
{{- else if .Values.derivativesVolume.enabled }}
320+
persistentVolumeClaim:
321+
claimName: {{ template "hyrax.fullname" . }}-derivatives
322+
{{ else }}
323+
emptyDir: {}
324+
{{ end }}
325+
- name: "uploads"
326+
{{- if and .Values.uploadsVolume.enabled .Values.uploadsVolume.existingClaim }}
327+
persistentVolumeClaim:
328+
claimName: {{ .Values.uploadsVolume.existingClaim }}
329+
{{- else if .Values.uploadsVolume.enabled }}
330+
persistentVolumeClaim:
331+
claimName: {{ template "hyrax.fullname" . }}-uploads
332+
{{ else }}
333+
emptyDir: {}
334+
{{ end }}
335+
{{- if .Values.applicationExistingClaim }}
336+
- name: "application"
337+
persistentVolumeClaim:
338+
claimName: {{ .Values.applicationExistingClaim }}
339+
{{- end }}
340+
{{- with .Values.worker.extraVolumes }}
341+
{{- toYaml . | nindent 8 }}
342+
{{- end }}
343+
{{- with .Values.worker.nodeSelector }}
344+
nodeSelector:
345+
{{- toYaml . | nindent 8 }}
346+
{{- end }}
347+
{{- with .Values.worker.affinity }}
348+
affinity:
349+
{{- toYaml . | nindent 8 }}
350+
{{- end }}
351+
{{- with .Values.worker.tolerations }}
352+
tolerations:
353+
{{- toYaml . | nindent 8 }}
354+
{{- end }}
355+
194356
podSecurityContext:
195357
runAsUser: 1001
196358
runAsGroup: 101
@@ -208,11 +370,16 @@ fcrepo:
208370
postgresql:
209371
enabled: false
210372
redis:
211-
cluster:
212-
enabled: false
213-
password: $REDIS_PASSWORD
373+
enabled: true
374+
architecture: standalone
375+
auth:
376+
password: $REDIS_PASSWORD
214377
solr:
215378
enabled: false
379+
fits:
380+
enabled: true
381+
servicePort: 8080
382+
subPath: /fits
216383

217384
externalPostgresql:
218385
host: postgres-cluster-alpha-ha.postgres.svc.cluster.local
@@ -226,7 +393,7 @@ externalSolrCollection: demo-palni-palci
226393
externalSolrPassword: $SOLR_ADMIN_PASSWORD
227394

228395
global:
229-
hyraxName: palni-palci-demo-pals
396+
hyraxHostName: palni-palci-demo-pals
230397

231398
nginx:
232399
enabled: true
@@ -238,7 +405,7 @@ nginx:
238405
tag: 1.21.5-debian-10-r4
239406
serverBlock: |-
240407
upstream rails_app {
241-
server {{ .Values.global.hyraxName }};
408+
server {{ .Values.global.hyraxHostName }};
242409
}
243410
244411
map ${DOLLAR}status ${DOLLAR}loggable {

0 commit comments

Comments
 (0)