Skip to content

Commit

Permalink
Add threads parameter for delayed workers
Browse files Browse the repository at this point in the history
  • Loading branch information
johha committed Jul 26, 2024
1 parent 1771c64 commit 319cb54
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jobs/cloud_controller_ng/spec
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ properties:
description: "When enabled, the priority of asynchronous jobs will be increased by 1 for each active asynchronous job for that user.
This prevents that a single user, who creates many asynchronous jobs, slows down job execution for other users."
default: false
cc.jobs.threads:
description: "If set multiple delayed job workers will be started as threads in the same process. If not set there will be one delayed job worker per process."

cc.temporary_disable_deployments:
description: "Do not allow the API client to create app deployments (temporary)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ jobs:
<% if_p("cc.jobs.priorities") do |priorities| %>
priorities: <%= priorities.to_json %>
<% end %>
<% if_p("cc.jobs.threads") do |threads| %>
threads: <%= threads.to_json %>
<% end %>


cpu_weight_min_memory: <%= p("cc.cpu_weight_min_memory") %>
cpu_weight_max_memory: <%= p("cc.cpu_weight_max_memory") %>
Expand Down
2 changes: 2 additions & 0 deletions jobs/cloud_controller_worker/spec
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ properties:
description: "Maximum health check timeout (in seconds) that can be set for the app"
cc.jobs.priorities:
description: "List of hashes containing delayed jobs 'display_name' and its desired priority. This will overwrite the default priority of ccng"
cc.jobs.threads:
description: "If set multiple delayed job workers will be started as threads in the same process. If not set there will be one delayed job worker per process."

cc.staging_upload_user:
description: "User name used to access internal endpoints of Cloud Controller to upload files when staging"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
<% if_p("cc.jobs.priorities") do |priorities| %>
priorities: <%= priorities.to_json %>
<% end %>
<% if_p("cc.jobs.threads") do |threads| %>
threads: <%= threads.to_json %>
<% end %>

default_app_memory: <%= p("cc.default_app_memory") %>
default_app_disk_in_mb: <%= p("cc.default_app_disk_in_mb") %>
Expand Down
11 changes: 11 additions & 0 deletions spec/cloud_controller_ng/cloud_controller_ng_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,17 @@ module Test
end
end
end

describe 'cc_jobs_threads' do
context "when 'cc.jobs.threads' is set" do
before { merged_manifest_properties['cc']['jobs']['threads'] = 7 }

it 'renders the correct value into the ccng config' do
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
expect(template_hash['jobs']['threads']).to eq(7)
end
end
end
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions spec/cloud_controller_worker/cloud_controller_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ module Test
end
end
end

describe 'cc_jobs_threads' do
context "when 'cc.jobs.threads' is set" do
before { properties['cc']['jobs']['threads'] = 7 }

it 'renders the correct value into the ccng config' do
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
expect(template_hash['jobs']['threads']).to eq(7)
end
end
end
end
end
end
Expand Down

0 comments on commit 319cb54

Please sign in to comment.