diff --git a/jobs/cloud_controller_ng/spec b/jobs/cloud_controller_ng/spec index 6f72c74f42..4f06805b7d 100644 --- a/jobs/cloud_controller_ng/spec +++ b/jobs/cloud_controller_ng/spec @@ -370,6 +370,10 @@ properties: description: "The longest this job can take before it is cancelled" 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.enable_dynamic_job_priorities: + 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.temporary_disable_deployments: description: "Do not allow the API client to create app deployments (temporary)" diff --git a/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb b/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb index 6602fd84e9..434ca2eab5 100644 --- a/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb +++ b/jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb @@ -80,6 +80,7 @@ reserved_private_domains: <%= p("cc.reserved_private_domains", nil) %> disable_private_domain_cross_space_context_path_route_sharing: <%= p("cc.disable_private_domain_cross_space_context_path_route_sharing", false) %> jobs: + enable_dynamic_job_priorities: <%= p("cc.jobs.enable_dynamic_job_priorities") %> global: timeout_in_seconds: <%= p("cc.jobs.global.timeout_in_seconds") %> <% if_p("cc.jobs.blobstore_delete.timeout_in_seconds") do |timeout| %> diff --git a/spec/cloud_controller_ng/cloud_controller_ng_spec.rb b/spec/cloud_controller_ng/cloud_controller_ng_spec.rb index 6dfa5b4e92..3ac2d2081a 100644 --- a/spec/cloud_controller_ng/cloud_controller_ng_spec.rb +++ b/spec/cloud_controller_ng/cloud_controller_ng_spec.rb @@ -670,6 +670,26 @@ module Test end end end + + describe 'enable_dynamic_job_priorities' do + context "when 'enable_dynamic_job_priorities' is set to true" do + before do + merged_manifest_properties['cc']['jobs'] = { 'enable_dynamic_job_priorities' => true } + end + + it 'renders true into ccng config' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['jobs']['enable_dynamic_job_priorities']).to be(true) + end + end + + context "when 'enable_dynamic_job_priorities' is not set" do + it 'renders false into ccng config' do + template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links)) + expect(template_hash['jobs']['enable_dynamic_job_priorities']).to be(false) + end + end + end end end end