Skip to content
Merged
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
12 changes: 8 additions & 4 deletions app/actions/deployment_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create(app:, user_audit_info:, message:)

if target_state.rollback_target_revision
revision = RevisionResolver.rollback_app_revision(app, target_state.rollback_target_revision, user_audit_info)
log_rollback_event(app.guid, user_audit_info.user_guid, target_state.rollback_target_revision.guid, message.strategy)
log_rollback_event(app.guid, user_audit_info.user_guid, target_state.rollback_target_revision.guid, message.strategy, message.max_in_flight, message.canary_steps)
else
revision = RevisionResolver.update_app_revision(app, user_audit_info)
end
Expand Down Expand Up @@ -201,7 +201,7 @@ def create_deployment(app, message, previous_deployment, previous_droplet, revis
memory_in_mb: message.memory_in_mb,
disk_in_mb: message.disk_in_mb,
log_rate_limit_in_bytes_per_second: message.log_rate_limit_in_bytes_per_second,
canary_steps: message.options&.dig(:canary, :steps),
canary_steps: message.canary_steps,
web_instances: message.web_instances
)
MetadataUpdate.update(deployment, message)
Expand Down Expand Up @@ -251,15 +251,19 @@ def starting_process_instances(deployment, desired_instances)
[deployment.max_in_flight, starting_process_count].min
end

def log_rollback_event(app_guid, user_id, revision_id, strategy)
def log_rollback_event(app_guid, user_id, revision_id, strategy, max_in_flight, canary_steps)
TelemetryLogger.v3_emit(
'rolled-back-app',
{
'app-id' => app_guid,
'user-id' => user_id,
'revision-id' => revision_id
},
{ 'strategy' => strategy }
{
'strategy' => strategy,
'max-in-flight' => max_in_flight,
'canary-steps' => canary_steps
}
)
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/v3/deployments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def create
'app-id' => app.guid,
'user-id' => current_user.guid
},
{ 'strategy' => deployment.strategy }
{
'strategy' => deployment.strategy,
'max-in-flight' => deployment.max_in_flight,
'canary-steps' => deployment.canary_steps
}
)
rescue DeploymentCreate::Error => e
unprocessable!(e.message)
Expand Down
4 changes: 4 additions & 0 deletions app/messages/deployment_create_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def log_rate_limit_in_bytes_per_second
options&.dig(:log_rate_limit_in_bytes_per_second)
end

def canary_steps
options&.dig(:canary, :steps)
end

private

def mutually_exclusive_droplet_sources
Expand Down
17 changes: 17 additions & 0 deletions spec/request/deployments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,12 @@
let(:create_request) do
{
strategy: 'canary',
options: {
max_in_flight: 10,
canary: {
steps: [{ instance_weight: 1 }, { instance_weight: 2 }]
}
},
relationships: {
app: {
data: {
Expand All @@ -594,6 +600,13 @@
revision: {
guid: revision.guid
},
strategy: 'canary',
options: {
max_in_flight: 10,
canary: {
steps: [{ instance_weight: 1 }, { instance_weight: 2 }]
}
},
relationships: {
app: {
data: {
Expand All @@ -612,6 +625,8 @@
'create-deployment' => {
'api-version' => 'v3',
'strategy' => 'canary',
'max-in-flight' => 10,
'canary-steps' => [{ 'instance_weight' => 1 }, { 'instance_weight' => 2 }],
'app-id' => OpenSSL::Digest::SHA256.hexdigest(app_model.guid),
'user-id' => OpenSSL::Digest::SHA256.hexdigest(user.guid)
}
Expand All @@ -632,6 +647,8 @@
'rolled-back-app' => {
'api-version' => 'v3',
'strategy' => 'canary',
'max-in-flight' => 10,
'canary-steps' => [{ 'instance_weight' => 1 }, { 'instance_weight' => 2 }],
'app-id' => OpenSSL::Digest::SHA256.hexdigest(app_model.guid),
'user-id' => OpenSSL::Digest::SHA256.hexdigest(user.guid),
'revision-id' => OpenSSL::Digest::SHA256.hexdigest(revision.guid)
Expand Down
24 changes: 24 additions & 0 deletions spec/unit/messages/deployment_create_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -598,5 +598,29 @@ module VCAP::CloudController
end
end
end

describe 'canary steps' do
context 'when options is not specified' do
before do
body['options'] = nil
end

it 'returns nil' do
message = DeploymentCreateMessage.new(body)
expect(message.canary_steps).to be_nil
end
end

context 'when canary and steps are specified' do
before do
body['options'] = { canary: { steps: [{ instance_weight: 1 }] } }
end

it 'returns the passed value' do
message = DeploymentCreateMessage.new(body)
expect(message.canary_steps).to eq [{ instance_weight: 1 }]
end
end
end
end
end