Skip to content

Commit

Permalink
Configurable file_descriptors limit for warden container
Browse files Browse the repository at this point in the history
file_descriptors for a warden container is made configurable through
deployment manifest.
Currently the default is 16384 which is read from the database table
and is not configurable. To configure, cf operator needs to add the
following config variable under cc
cc:
  default_app_file_descriptors: 4096

[#82011156]
  • Loading branch information
shashidharatd committed Jan 7, 2015
1 parent cf61f10 commit d02025b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/models/runtime/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def after_initialize
:state, :version, :command, :console, :debug, :staging_task_id,
:package_state, :health_check_type, :health_check_timeout,
:staging_failed_reason, :docker_image, :package_updated_at,
:detected_start_command
:detected_start_command, :file_descriptors

import_attributes :name, :production, :space_guid, :stack_guid, :buildpack,
:detected_buildpack, :environment_json, :memory, :instances, :disk_quota,
:state, :command, :console, :debug, :staging_task_id,
:service_binding_guids, :route_guids, :health_check_type,
:health_check_timeout, :docker_image, :app_guid
:health_check_timeout, :docker_image, :app_guid, :file_descriptors

strip_attributes :name

Expand Down Expand Up @@ -137,6 +137,9 @@ def before_save
self.stack ||= Stack.default
self.memory ||= Config.config[:default_app_memory]
self.disk_quota ||= Config.config[:default_app_disk_in_mb]
if Config.config[:default_app_file_descriptors]
self.file_descriptors ||= Config.config[:default_app_file_descriptors]
end

set_new_version if version_needs_to_be_updated?

Expand Down
1 change: 1 addition & 0 deletions bosh-templates/cloud_controller_api.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ billing_event_writing_enabled: <%= p("cc.billing_event_writing_enabled") %>

default_app_memory: <%= p("cc.default_app_memory") %>
default_app_disk_in_mb: <%= p("cc.default_app_disk_in_mb") %>
default_app_file_descriptors: <%= p("cc.default_app_file_descriptors") %>
maximum_app_disk_in_mb: <%= p("cc.maximum_app_disk_in_mb") %>

request_timeout_in_seconds: <%= p("request_timeout_in_seconds") %>
Expand Down
1 change: 1 addition & 0 deletions bosh-templates/cloud_controller_clock.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ billing_event_writing_enabled: <%= p("cc.billing_event_writing_enabled") %>

default_app_memory: <%= p("cc.default_app_memory") %>
default_app_disk_in_mb: <%= p("cc.default_app_disk_in_mb") %>
default_app_file_descriptors: <%= p("cc.default_app_file_descriptors") %>
maximum_app_disk_in_mb: <%= p("cc.maximum_app_disk_in_mb") %>

request_timeout_in_seconds: <%= p("request_timeout_in_seconds") %>
Expand Down
1 change: 1 addition & 0 deletions bosh-templates/cloud_controller_worker.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ billing_event_writing_enabled: <%= p("cc.billing_event_writing_enabled") %>

default_app_memory: <%= p("cc.default_app_memory") %>
default_app_disk_in_mb: <%= p("cc.default_app_disk_in_mb") %>
default_app_file_descriptors: <%= p("cc.default_app_file_descriptors") %>
maximum_app_disk_in_mb: <%= p("cc.maximum_app_disk_in_mb") %>

request_timeout_in_seconds: <%= p("request_timeout_in_seconds") %>
Expand Down
1 change: 1 addition & 0 deletions lib/cloud_controller/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Config < VCAP::Config
optional(:billing_event_writing_enabled) => bool,
:default_app_memory => Fixnum,
:default_app_disk_in_mb => Fixnum,
optional(:default_app_file_descriptors) => Fixnum,
optional(:maximum_app_disk_in_mb) => Fixnum,
:maximum_health_check_timeout => Fixnum,

Expand Down
24 changes: 21 additions & 3 deletions spec/unit/models/runtime/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ def act_as_cf_admin(&block)
:staging_failed_reason,
:staging_task_id,
:state,
:version
:version,
:file_descriptors
)
}

Expand All @@ -455,7 +456,8 @@ def act_as_cf_admin(&block)
:space_guid,
:stack_guid,
:staging_task_id,
:state
:state,
:file_descriptors
)
}
end
Expand Down Expand Up @@ -1640,7 +1642,23 @@ def self.it_does_not_mark_for_re_staging
end
end

describe 'default disk_quota' do
describe "default_app_file_descriptors" do
before do
TestConfig.override({default_app_file_descriptors: 200})
end

it "uses the provided file descriptors limit" do
app = App.create_from_hash(name: "awesome app", space_guid: space.guid, file_descriptors: 100)
expect(app.file_descriptors).to eq(100)
end

it "uses the default_app_file_descriptors when none is provided" do
app = App.create_from_hash(name: "awesome app", space_guid: space.guid)
expect(app.file_descriptors).to eq(200)
end
end

describe "default disk_quota" do
before do
TestConfig.override({ default_app_disk_in_mb: 512 })
end
Expand Down

0 comments on commit d02025b

Please sign in to comment.