Skip to content
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
2 changes: 2 additions & 0 deletions jobs/cloud_controller_ng/spec
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ properties:
cc.app_bits_max_body_size:
default: "2048M"
description: "Maximum body size for nginx bits uploads"
cc.nginx_client_body_timeout_for_uploads:
description: "nginx client_body_timeout in seconds for the public upload endpoints. When unset, nginx's built-in default applies."

cc.additional_allowed_process_users:
default: []
Expand Down
4 changes: 4 additions & 0 deletions jobs/cloud_controller_ng/templates/public_upload.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ upload_pass @cc_uploads;
# Allow large uploads
client_max_body_size <%= p("cc.app_bits_max_body_size") %>; #already enforced upstream/but doesn't hurt.

<% if_p("cc.nginx_client_body_timeout_for_uploads") do |timeout| -%>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it would be 0 or non-numeric garbage "abc"?

client_body_timeout <%= timeout %>s;
<% end -%>

# Store files to this directory
upload_store <%= p("cc.directories.tmpdir") %>/uploads;

Expand Down
23 changes: 23 additions & 0 deletions spec/cloud_controller_ng/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,29 @@ module Test
end
end
end

describe 'public_upload.conf' do
let(:template) { job.template('config/public_upload.conf') }
let(:manifest_properties) { {} }

before do
@rendered_file = template.render(manifest_properties, consumes: {})
end

context 'when nginx_client_body_timeout_for_uploads is not configured' do
it 'does not render a client_body_timeout directive' do
expect(@rendered_file).not_to match(/^\s*client_body_timeout/)
end
end

context 'when nginx_client_body_timeout_for_uploads is configured' do
let(:manifest_properties) { { 'cc' => { 'nginx_client_body_timeout_for_uploads' => 150 } } }

it 'renders client_body_timeout with the configured value in seconds' do
expect(@rendered_file).to match(/^client_body_timeout 150s;$/)
end
end
end
end
end
end
Expand Down
Loading