Skip to content

Commit b0a5ace

Browse files
Add good_job worker probes
1 parent 19a6353 commit b0a5ace

File tree

3 files changed

+87
-37
lines changed

3 files changed

+87
-37
lines changed

charts/openproject/templates/worker-deployment.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ spec:
8181
{{- include "openproject.env" . | nindent 12 }}
8282
- name: "QUEUE"
8383
value: "{{ $workerValues.queues }}"
84+
{{- if $workerValues.probes.enabled }}
85+
- name: "GOOD_JOB_PROBE_PORT"
86+
value: "{{ $workerValues.probes.port }}"
87+
{{- end }}
8488
volumeMounts:
8589
{{- include "openproject.tmpVolumeMounts" . | indent 12 }}
8690
{{- if .Values.persistence.enabled }}
@@ -94,6 +98,28 @@ spec:
9498
readOnly: false
9599
{{- end }}
96100
{{- include "openproject.extraVolumeMounts" . | indent 12 }}
101+
{{- if and .Values.probes.liveness.enabled $workerValues.probes.enabled }}
102+
livenessProbe:
103+
httpGet:
104+
path: "/status/connected"
105+
port: {{ $workerValues.probes.port }}
106+
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
107+
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
108+
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
109+
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
110+
successThreshold: {{ .Values.probes.liveness.successThreshold }}
111+
{{- end }}
112+
{{- if and .Values.probes.readiness.enabled $workerValues.probes.enabled }}
113+
readinessProbe:
114+
httpGet:
115+
path: "/status"
116+
port: {{ $workerValues.probes.port }}
117+
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
118+
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
119+
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
120+
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
121+
successThreshold: {{ .Values.probes.readiness.successThreshold }}
122+
{{- end }}
97123
resources:
98124
{{- coalesce $workerValues.resources .Values.resources | toYaml | nindent 12 }}
99125
{{- end }}

charts/openproject/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ workers:
257257
default:
258258
queues: ""
259259
replicas: 1
260+
# Enable monitoring probe for background workers
261+
probes:
262+
enabled: true
263+
port: 7001
260264
strategy:
261265
type: "Recreate"
262266
resources:
Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,80 @@
11
# frozen_string_literal: true
22
require 'spec_helper'
33

4-
describe 'imagePullSecrets configuration' do
4+
describe 'worker probes configuration' do
55
let(:template) { HelmTemplate.new(default_values) }
6+
let(:worker) { 'Deployment/optest-openproject-worker-default' }
67

7-
context 'when setting custom workers' do
8+
context 'when disabling probes' do
89
let(:default_values) do
910
HelmTemplate.with_defaults(<<~YAML
1011
workers:
1112
default:
1213
queues: ""
13-
replicaCount: 1
14-
strategy:
15-
type: "Recreate"
16-
multitenancy:
17-
queues: "multitenancy"
18-
replicaCount: 1
19-
strategy:
20-
type: "Recreate"
21-
bim:
22-
queues: "bim,ifc_conversion"
23-
replicaCount: 0
24-
strategy:
25-
type: "Recreate"
26-
YAML
14+
replicas: 1
15+
probes:
16+
enabled: false
17+
port: 7001
18+
YAML
2719
)
2820
end
2921

30-
it 'Creates the different worker deployments', :aggregate_failures do
31-
expect(template.keys).to include 'Deployment/optest-openproject-worker-default'
32-
expect(template.dig('Deployment/optest-openproject-worker-default', 'spec', 'replicas'))
33-
.to eq(1)
34-
expect(template.env('Deployment/optest-openproject-worker-default', 'openproject', 'QUEUE'))
35-
.to be_nil
36-
37-
expect(template.keys).to include 'Deployment/optest-openproject-worker-multitenancy'
38-
expect(template.dig('Deployment/optest-openproject-worker-multitenancy', 'spec', 'replicas'))
39-
.to eq(1)
40-
expect(template.env_named('Deployment/optest-openproject-worker-multitenancy', 'openproject', 'QUEUE')['value'])
41-
.to eq('multitenancy')
42-
43-
expect(template.keys).to include 'Deployment/optest-openproject-worker-bim'
44-
expect(template.dig('Deployment/optest-openproject-worker-bim', 'spec', 'replicas'))
45-
.to eq(0)
46-
expect(template.env_named('Deployment/optest-openproject-worker-bim', 'openproject', 'QUEUE')['value'])
47-
.to eq('bim,ifc_conversion')
22+
it 'does not define worker probes', :aggregate_failures do
23+
expect(template.keys).to include worker
24+
25+
spec = template.find_container(worker, 'openproject')
26+
expect(spec['livenessProbe']).to be_nil
27+
expect(spec['readinessProbe']).to be_nil
28+
29+
env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT')
30+
expect(env).to be_nil
4831
end
4932
end
5033

51-
context 'when setting no workers' do
34+
context 'when setting custom port' do
35+
let(:default_values) do
36+
HelmTemplate.with_defaults(<<~YAML
37+
workers:
38+
default:
39+
queues: ""
40+
replicas: 1
41+
probes:
42+
enabled: true
43+
port: 9999
44+
YAML
45+
)
46+
end
47+
48+
it 'does define the probe', :aggregate_failures do
49+
expect(template.keys).to include worker
50+
spec = template.find_container(worker, 'openproject')
51+
expect(spec['livenessProbe']).to be_a(Hash)
52+
expect(spec['readinessProbe']).to be_a(Hash)
53+
expect(spec['readinessProbe']['httpGet']['port']).to eq 9999
54+
expect(spec['livenessProbe']['httpGet']['port']).to eq 9999
55+
56+
env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT')
57+
expect(env).to be_a(Hash)
58+
expect(env['value']).to eq '9999'
59+
end
60+
end
61+
62+
context 'with default configuration' do
5263
let(:default_values) do
5364
{}
5465
end
5566

56-
it 'Creates the default worker', :aggregate_failures do
57-
expect(template.keys).to include 'Deployment/optest-openproject-worker-default'
67+
it 'uses the default probes', :aggregate_failures do
68+
expect(template.keys).to include worker
69+
spec = template.find_container(worker, 'openproject')
70+
expect(spec['livenessProbe']).to be_a(Hash)
71+
expect(spec['readinessProbe']).to be_a(Hash)
72+
expect(spec['readinessProbe']['httpGet']['port']).to eq 7001
73+
expect(spec['livenessProbe']['httpGet']['port']).to eq 7001
74+
75+
env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT')
76+
expect(env).to be_a(Hash)
77+
expect(env['value']).to eq '7001'
5878
end
5979
end
6080
end

0 commit comments

Comments
 (0)