Skip to content

Commit

Permalink
Remove default value of the config parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Malsourie committed May 16, 2024
1 parent 35c5cf3 commit 3c68779
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 3 additions & 2 deletions jobs/director/spec
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ properties:
default: 2000
director.tasks_retention_period:
description: the retention period for tasks and their log files (days)
default: ''
director.tasks_deployments_retention_period:
description: the retention period for tasks and their log files of specific deployments (days)
default: ''
example: |
- deployment_name: "deployment-name"
retention_period: 14
director.max_threads:
description: Max number of director concurrent threads
default: 32
Expand Down
10 changes: 8 additions & 2 deletions jobs/director/templates/director.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ params = {
},
'port' => p('director.backend_port'),
'max_tasks' => p('director.max_tasks'),
'tasks_retention_period' => p('director.tasks_retention_period'),
'tasks_deployments_retention_period' => p('director.tasks_deployments_retention_period'),
'max_threads' => p('director.max_threads'),
'puma_workers' => p('director.puma_workers'),
'logging' => {
Expand Down Expand Up @@ -108,6 +106,14 @@ params['config_server'] = config_server

params['scheduled_jobs'] = []

if_p('director.tasks_retention_period') do |tasks_retention_period|
params['tasks_retention_period'] = tasks_retention_period
end

if_p('director.tasks_deployments_retention_period') do |tasks_deployments_retention_period|
params['tasks_deployments_retention_period'] = tasks_deployments_retention_period
end

if_p('director.snapshot_schedule') do |snapshot_schedule|
params['scheduled_jobs'] << {
'command' => 'SnapshotDeployments',
Expand Down
4 changes: 2 additions & 2 deletions src/bosh-director/lib/bosh/director/api/task_remover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def remove(type)
tasks_removed += 1
remove_task(task)
end
unless @retention_period == ''
unless @retention_period.nil?
removal_retention_candidates_dataset(type).paged_each(strategy: :filter, stream: false) do |task|
tasks_removed += 1
remove_task(task)
end
end
unless @deployment_retention_period == ''
unless @deployment_retention_period.nil?
@deployment_retention_period.each do |d|
removal_deployment_retention_candidates_dataset(type, d).paged_each(strategy: :filter, stream: false) do |task|
tasks_removed += 1
Expand Down
4 changes: 2 additions & 2 deletions src/bosh-director/lib/bosh/director/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def configure(config)
@max_tasks = config.fetch('max_tasks', 2000).to_i

# by default keep all tasks of each type in disk if retention period is not set
@tasks_retention_period = config.fetch('tasks_retention_period', '')
@tasks_deployments_retention_period = config.fetch('tasks_deployments_retention_period', '')
@tasks_retention_period = config.fetch('tasks_retention_period', nil)
@tasks_deployments_retention_period = config.fetch('tasks_deployments_retention_period', nil)

@max_threads = config.fetch('max_threads', 32).to_i

Expand Down
8 changes: 4 additions & 4 deletions src/bosh-director/spec/unit/api/task_remover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def make_n_tasks(num_tasks, task_type: default_type, checkpoint_time: inside_ret
end
end

subject(:remover) { TaskRemover.new(3, '', '') }
subject(:remover) { TaskRemover.new(3, nil, nil) }
let(:default_type) { 'type' }
let(:inside_retention) { '2024-05-12 15:35:45.834392' }
let(:outside_retention) { '2023-05-12 15:35:45.834392' }
Expand Down Expand Up @@ -138,7 +138,7 @@ def tasks
end

context 'when task output is nil' do
subject(:remover) { described_class.new(0, '', '') }
subject(:remover) { described_class.new(0, nil, nil) }

before do
Bosh::Director::Models::Task.make(state: 'done', output: nil)
Expand Down Expand Up @@ -174,7 +174,7 @@ def tasks

context 'when there are tasks exceeding the retention period 1 day in the database' do
subject(:remover) do
TaskRemover.new(2000, '1', '')
TaskRemover.new(2000, 1, nil)
end

before do
Expand All @@ -194,7 +194,7 @@ def tasks

context 'when there is task exceeding the retention period 1 day in the database' do
subject(:remover) do
TaskRemover.new(2000, '', [{ 'deployment' => 'deployment1', 'retention_period' => '1' }])
TaskRemover.new(2000, nil, [{ 'deployment' => 'deployment1', 'retention_period' => '1' }])
end

before do
Expand Down

0 comments on commit 3c68779

Please sign in to comment.