Skip to content

Add good_job worker probes #131

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

Open
wants to merge 3 commits into
base: main
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
5 changes: 5 additions & 0 deletions .changeset/lazy-queens-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openproject/helm-charts": major
---

Add good_job background worker livenessProbe and readinessProbe
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.3
3.3.4
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
80 changes: 80 additions & 0 deletions spec/charts/openproject/worker_probes_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# frozen_string_literal: true
require 'spec_helper'

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

context 'when disabling probes' do
let(:default_values) do
HelmTemplate.with_defaults(<<~YAML
workers:
default:
queues: ""
replicas: 1
probes:
enabled: false
port: 7001
YAML
)
end

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 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 '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
Loading