Skip to content

Commit b42f51b

Browse files
committed
dont set web_instances unless explicitly set
1 parent 0a313a1 commit b42f51b

File tree

5 files changed

+25
-45
lines changed

5 files changed

+25
-45
lines changed

app/actions/deployment_create.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def create_deployment(app, message, previous_deployment, previous_droplet, revis
202202
disk_in_mb: message.disk_in_mb,
203203
log_rate_limit_in_bytes_per_second: message.log_rate_limit_in_bytes_per_second,
204204
canary_steps: message.options&.dig(:canary, :steps),
205-
web_instances: message.web_instances || desired_instances(app.oldest_web_process, previous_deployment)
205+
web_instances: message.web_instances
206206
)
207207
MetadataUpdate.update(deployment, message)
208208
deployment

app/models/runtime/deployment_model.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ def continuable?
114114
end
115115

116116
def desired_web_instances
117-
# It seems redundant to have method since web_instances defaults to original_web_process_instance_count,
118-
# (in deployment create action)
119-
# but this should handle deployments created on old API vms mid bosh deployment
120-
# we can probably clean this up in the future
121117
web_instances || original_web_process_instance_count
122118
end
123119

app/presenters/v3/deployment_presenter.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ def new_processes
5757

5858
def options(deployment)
5959
options = {
60-
max_in_flight: deployment.max_in_flight,
61-
web_instances: deployment.desired_web_instances
60+
max_in_flight: deployment.max_in_flight
6261
}
63-
62+
options[:web_instances] = deployment.web_instances if deployment.web_instances
6463
options[:memory_in_mb] = deployment.memory_in_mb if deployment.memory_in_mb
6564
options[:disk_in_mb] = deployment.disk_in_mb if deployment.disk_in_mb
6665
options[:log_rate_limit_in_bytes_per_second] = deployment.log_rate_limit_in_bytes_per_second if deployment.log_rate_limit_in_bytes_per_second

spec/request/deployments_spec.rb

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
},
4646
'strategy' => 'rolling',
4747
'options' => {
48-
'max_in_flight' => 1,
49-
'web_instances' => 1
48+
'max_in_flight' => 1
5049
},
5150
'droplet' => {
5251
'guid' => droplet.guid
@@ -147,8 +146,7 @@
147146
},
148147
'strategy' => 'rolling',
149148
'options' => {
150-
'max_in_flight' => 1,
151-
'web_instances' => 1
149+
'max_in_flight' => 1
152150
},
153151
'droplet' => {
154152
'guid' => other_droplet.guid
@@ -234,8 +232,7 @@
234232
},
235233
'strategy' => 'rolling',
236234
'options' => {
237-
'max_in_flight' => 1,
238-
'web_instances' => 1
235+
'max_in_flight' => 1
239236
},
240237
'droplet' => {
241238
'guid' => other_droplet.guid
@@ -357,8 +354,7 @@
357354
},
358355
'strategy' => 'rolling',
359356
'options' => {
360-
'max_in_flight' => 1,
361-
'web_instances' => 1
357+
'max_in_flight' => 1
362358
},
363359
'droplet' => {
364360
'guid' => droplet.guid
@@ -440,8 +436,7 @@
440436
},
441437
'strategy' => 'rolling',
442438
'options' => {
443-
'max_in_flight' => 1,
444-
'web_instances' => 1
439+
'max_in_flight' => 1
445440
},
446441
'droplet' => {
447442
'guid' => other_droplet.guid
@@ -525,8 +520,7 @@
525520
},
526521
'strategy' => 'rolling',
527522
'options' => {
528-
'max_in_flight' => 1,
529-
'web_instances' => 1
523+
'max_in_flight' => 1
530524
},
531525
'droplet' => {
532526
'guid' => other_droplet.guid
@@ -698,8 +692,7 @@
698692
},
699693
'strategy' => 'rolling',
700694
'options' => {
701-
'max_in_flight' => 1,
702-
'web_instances' => 1
695+
'max_in_flight' => 1
703696
},
704697
'droplet' => {
705698
'guid' => droplet.guid
@@ -763,8 +756,7 @@
763756
},
764757
'strategy' => 'rolling',
765758
'options' => {
766-
'max_in_flight' => 1,
767-
'web_instances' => 1
759+
'max_in_flight' => 1
768760
},
769761
'droplet' => {
770762
'guid' => droplet.guid
@@ -849,8 +841,7 @@
849841
'type' => deployment.deploying_web_process.type
850842
}],
851843
'options' => {
852-
'max_in_flight' => 1,
853-
'web_instances' => 1
844+
'max_in_flight' => 1
854845
},
855846
'created_at' => iso8601,
856847
'updated_at' => iso8601,
@@ -924,8 +915,7 @@
924915
},
925916
'strategy' => 'rolling',
926917
'options' => {
927-
'max_in_flight' => 1,
928-
'web_instances' => 1
918+
'max_in_flight' => 1
929919
},
930920
'droplet' => {
931921
'guid' => droplet.guid
@@ -1001,8 +991,7 @@
1001991
},
1002992
'strategy' => 'rolling',
1003993
'options' => {
1004-
'max_in_flight' => 5,
1005-
'web_instances' => 1
994+
'max_in_flight' => 5
1006995
},
1007996
'droplet' => {
1008997
'guid' => droplet.guid
@@ -1110,7 +1099,6 @@
11101099
'strategy' => 'canary',
11111100
'options' => {
11121101
'max_in_flight' => 1,
1113-
'web_instances' => 1,
11141102
'canary' => {
11151103
'steps' => [
11161104
{ 'instance_weight' => 20 },
@@ -1414,11 +1402,11 @@
14141402
}
14151403
end
14161404

1417-
it 'defaults to original_web_process_instance_count' do
1405+
it 'is not set' do
14181406
post '/v3/deployments', create_request.to_json, user_header
14191407
expect(last_response.status).to eq(201), last_response.body
14201408

1421-
expect(parsed_response['options']['web_instances']).to eq(10)
1409+
expect(parsed_response['options'].key?('web_instances')).to be false
14221410
end
14231411
end
14241412
end
@@ -1490,8 +1478,7 @@
14901478
},
14911479
'strategy' => 'rolling',
14921480
'options' => {
1493-
'max_in_flight' => 1,
1494-
'web_instances' => 1
1481+
'max_in_flight' => 1
14951482
},
14961483
'droplet' => {
14971484
'guid' => droplet.guid
@@ -1599,8 +1586,7 @@
15991586
'metadata' => metadata,
16001587
'strategy' => 'rolling',
16011588
'options' => {
1602-
'max_in_flight' => 1,
1603-
'web_instances' => 1
1589+
'max_in_flight' => 1
16041590
},
16051591
'relationships' => {
16061592
'app' => {
@@ -1812,9 +1798,9 @@ def json_for_status(deployment, status_value, status_reason)
18121798

18131799
def json_for_options(deployment)
18141800
options = {
1815-
max_in_flight: deployment.max_in_flight,
1816-
web_instances: deployment.desired_web_instances
1801+
max_in_flight: deployment.max_in_flight
18171802
}
1803+
options[:web_instances] = deployment.web_instances if deployment.web_instances
18181804
if deployment.canary_steps
18191805
options[:canary] = {
18201806
steps: deployment.canary_steps
@@ -2079,8 +2065,7 @@ def json_for_options(deployment)
20792065
},
20802066
'strategy' => 'rolling',
20812067
'options' => {
2082-
'max_in_flight' => 1,
2083-
'web_instances' => 1
2068+
'max_in_flight' => 1
20842069
},
20852070
'droplet' => {
20862071
'guid' => droplet.guid

spec/unit/actions/deployment_create_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,9 @@ module VCAP::CloudController
617617
context 'when web_instances is not set' do
618618
let(:web_instances) { nil }
619619

620-
it 'sets web_instances to the original web process\'s instance count' do
620+
it 'sets web_instances to nil' do
621621
deployment = DeploymentCreate.create(app:, message:, user_audit_info:)
622-
expect(deployment.web_instances).to eq(3)
622+
expect(deployment.web_instances).to be_nil
623623
expect(app.reload.newest_web_process.instances).to eq(3)
624624
end
625625
end
@@ -839,9 +839,9 @@ module VCAP::CloudController
839839
context 'when web_instances is not set' do
840840
let(:web_instances) { nil }
841841

842-
it 'sets web_instances to the original web process\'s instance count' do
842+
it 'sets web_instances to nil' do
843843
deployment = DeploymentCreate.create(app:, message:, user_audit_info:)
844-
expect(deployment.web_instances).to eq(3)
844+
expect(deployment.web_instances).to be_nil
845845
end
846846
end
847847

0 commit comments

Comments
 (0)