Skip to content

Commit 5ea4069

Browse files
committed
chore(TNZ-44895): Validate max in flight and canary steps against the recreate strategy
Max in flight and canary steps are not valid options for the recreate deployment strategy
1 parent 09be7f2 commit 5ea4069

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

app/messages/deployment_create_message.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DeploymentCreateMessage < MetadataBaseMessage
2626

2727
validates_with NoAdditionalKeysValidator
2828
validates :strategy,
29-
inclusion: { in: %w[rolling canary], message: "'%<value>s' is not a supported deployment strategy" },
29+
inclusion: { in: %w[rolling canary recreate], message: "'%<value>s' is not a supported deployment strategy" },
3030
allow_nil: true
3131
validate :mutually_exclusive_droplet_sources
3232

@@ -113,6 +113,10 @@ def validate_scaling_options
113113

114114
def validate_max_in_flight
115115
max_in_flight = options[:max_in_flight]
116+
if max_in_flight && strategy == 'recreate'
117+
errors.add(:'options.max_in_flight', 'is not a supported option for recreate deployment strategy')
118+
return
119+
end
116120

117121
return unless !max_in_flight.is_a?(Integer) || max_in_flight < 1
118122

spec/unit/messages/deployment_create_message_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,16 @@ module VCAP::CloudController
132132
end
133133
end
134134

135-
context 'when set with recreate strategy'
135+
context 'when set with recreate strategy' do
136+
before do
137+
body['options'] = { max_in_flight: 2 }
138+
end
139+
136140
it 'is not valid' do
137141
body['strategy'] = 'recreate'
138142
message = DeploymentCreateMessage.new(body)
139143
expect(message).not_to be_valid
140-
expect(message.errors.full_messages).to include('Max in flight is not a supported option for recreate deployment strategy')
144+
expect(message.errors.full_messages).to include('Options max in flight is not a supported option for recreate deployment strategy')
141145
end
142146
end
143147
end

0 commit comments

Comments
 (0)