Skip to content

Commit

Permalink
Add good_job worker probes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 17, 2024
1 parent 19a6353 commit 8a9809c
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 37 deletions.
26 changes: 26 additions & 0 deletions charts/openproject/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ spec:
{{- include "openproject.env" . | nindent 12 }}
- name: "QUEUE"
value: "{{ $workerValues.queues }}"
{{- if $workerValues.probes.enabled }}
- name: "GOOD_JOB_PROBE_PORT"
value: "{{ $workerValues.probes.port }}"
{{- end }}
volumeMounts:
{{- include "openproject.tmpVolumeMounts" . | indent 12 }}
{{- if .Values.persistence.enabled }}
Expand All @@ -94,6 +98,28 @@ spec:
readOnly: false
{{- end }}
{{- include "openproject.extraVolumeMounts" . | indent 12 }}
{{- if and .Values.probes.liveness.enabled $workerValues.probes.enabled }}
livenessProbe:
httpGet:
path: "/status/connected"
port: {{ $workerValues.probes.port }}
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
successThreshold: {{ .Values.probes.liveness.successThreshold }}
{{- end }}
{{- if and .Values.probes.readiness.enabled $workerValues.probes.enabled }}
readinessProbe:
httpGet:
path: "/status"
port: {{ $workerValues.probes.port }}
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
successThreshold: {{ .Values.probes.readiness.successThreshold }}
{{- end }}
resources:
{{- coalesce $workerValues.resources .Values.resources | toYaml | nindent 12 }}
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/openproject/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ workers:
default:
queues: ""
replicas: 1
# Enable monitoring probe for background workers
probes:
enabled: true
port: 7001
strategy:
type: "Recreate"
resources:
Expand Down
94 changes: 57 additions & 37 deletions spec/charts/openproject/worker_probes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,60 +1,80 @@
# frozen_string_literal: true
require 'spec_helper'

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

context 'when setting custom workers' do
context 'when disabling probes' do
let(:default_values) do
HelmTemplate.with_defaults(<<~YAML
workers:
default:
queues: ""
replicaCount: 1
strategy:
type: "Recreate"
multitenancy:
queues: "multitenancy"
replicaCount: 1
strategy:
type: "Recreate"
bim:
queues: "bim,ifc_conversion"
replicaCount: 0
strategy:
type: "Recreate"
YAML
replicas: 1
probes:
enabled: false
port: 7001
YAML
)
end

it 'Creates the different worker deployments', :aggregate_failures do
expect(template.keys).to include 'Deployment/optest-openproject-worker-default'
expect(template.dig('Deployment/optest-openproject-worker-default', 'spec', 'replicas'))
.to eq(1)
expect(template.env('Deployment/optest-openproject-worker-default', 'openproject', 'QUEUE'))
.to be_nil

expect(template.keys).to include 'Deployment/optest-openproject-worker-multitenancy'
expect(template.dig('Deployment/optest-openproject-worker-multitenancy', 'spec', 'replicas'))
.to eq(1)
expect(template.env_named('Deployment/optest-openproject-worker-multitenancy', 'openproject', 'QUEUE')['value'])
.to eq('multitenancy')

expect(template.keys).to include 'Deployment/optest-openproject-worker-bim'
expect(template.dig('Deployment/optest-openproject-worker-bim', 'spec', 'replicas'))
.to eq(0)
expect(template.env_named('Deployment/optest-openproject-worker-bim', 'openproject', 'QUEUE')['value'])
.to eq('bim,ifc_conversion')
it 'does not define worker probes', :aggregate_failures do
expect(template.keys).to include worker

spec = template.find_container(worker, 'openproject')
expect(spec['livenessProbe']).to be_nil
expect(spec['readinessProbe']).to be_nil

env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT')
expect(env).to be_nil
end
end

context 'when setting no workers' do
context 'when setting custom port' do
let(:default_values) do
HelmTemplate.with_defaults(<<~YAML
workers:
default:
queues: ""
replicas: 1
probes:
enabled: true
port: 9999
YAML
)
end

it 'does define the probe', :aggregate_failures do
expect(template.keys).to include worker
spec = template.find_container(worker, 'openproject')
expect(spec['livenessProbe']).to be_a(Hash)
expect(spec['readinessProbe']).to be_a(Hash)
expect(spec['readinessProbe']['httpGet']['port']).to eq 9999
expect(spec['livenessProbe']['httpGet']['port']).to eq 9999

env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT')
expect(env).to be_a(Hash)
expect(env['value']).to eq '9999'
end
end

context 'with default configuration' do
let(:default_values) do
{}
end

it 'Creates the default worker', :aggregate_failures do
expect(template.keys).to include 'Deployment/optest-openproject-worker-default'
it 'uses the default probes', :aggregate_failures do
expect(template.keys).to include worker
spec = template.find_container(worker, 'openproject')
expect(spec['livenessProbe']).to be_a(Hash)
expect(spec['readinessProbe']).to be_a(Hash)
expect(spec['readinessProbe']['httpGet']['port']).to eq 7001
expect(spec['livenessProbe']['httpGet']['port']).to eq 7001

env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT')
expect(env).to be_a(Hash)
expect(env['value']).to eq '7001'
end
end
end
6 changes: 6 additions & 0 deletions spec/charts/openproject/worker_queues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@
default:
queues: ""
replicaCount: 1
probes:
enabled: false
strategy:
type: "Recreate"
multitenancy:
queues: "multitenancy"
replicaCount: 1
probes:
enabled: false
strategy:
type: "Recreate"
bim:
queues: "bim,ifc_conversion"
replicaCount: 0
probes:
enabled: false
strategy:
type: "Recreate"
YAML
Expand Down

0 comments on commit 8a9809c

Please sign in to comment.