Skip to content

Commit 824e347

Browse files
authored
Add more deployment telemetry (#4297)
1 parent ad5d7eb commit 824e347

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

app/actions/deployment_create.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create(app:, user_audit_info:, message:)
2525

2626
if target_state.rollback_target_revision
2727
revision = RevisionResolver.rollback_app_revision(app, target_state.rollback_target_revision, user_audit_info)
28-
log_rollback_event(app.guid, user_audit_info.user_guid, target_state.rollback_target_revision.guid, message.strategy)
28+
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)
2929
else
3030
revision = RevisionResolver.update_app_revision(app, user_audit_info)
3131
end
@@ -201,7 +201,7 @@ def create_deployment(app, message, previous_deployment, previous_droplet, revis
201201
memory_in_mb: message.memory_in_mb,
202202
disk_in_mb: message.disk_in_mb,
203203
log_rate_limit_in_bytes_per_second: message.log_rate_limit_in_bytes_per_second,
204-
canary_steps: message.options&.dig(:canary, :steps),
204+
canary_steps: message.canary_steps,
205205
web_instances: message.web_instances
206206
)
207207
MetadataUpdate.update(deployment, message)
@@ -251,15 +251,19 @@ def starting_process_instances(deployment, desired_instances)
251251
[deployment.max_in_flight, starting_process_count].min
252252
end
253253

254-
def log_rollback_event(app_guid, user_id, revision_id, strategy)
254+
def log_rollback_event(app_guid, user_id, revision_id, strategy, max_in_flight, canary_steps)
255255
TelemetryLogger.v3_emit(
256256
'rolled-back-app',
257257
{
258258
'app-id' => app_guid,
259259
'user-id' => user_id,
260260
'revision-id' => revision_id
261261
},
262-
{ 'strategy' => strategy }
262+
{
263+
'strategy' => strategy,
264+
'max-in-flight' => max_in_flight,
265+
'canary-steps' => canary_steps
266+
}
263267
)
264268
end
265269
end

app/controllers/v3/deployments_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ def create
5858
'app-id' => app.guid,
5959
'user-id' => current_user.guid
6060
},
61-
{ 'strategy' => deployment.strategy }
61+
{
62+
'strategy' => deployment.strategy,
63+
'max-in-flight' => deployment.max_in_flight,
64+
'canary-steps' => deployment.canary_steps
65+
}
6266
)
6367
rescue DeploymentCreate::Error => e
6468
unprocessable!(e.message)

app/messages/deployment_create_message.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def log_rate_limit_in_bytes_per_second
6464
options&.dig(:log_rate_limit_in_bytes_per_second)
6565
end
6666

67+
def canary_steps
68+
options&.dig(:canary, :steps)
69+
end
70+
6771
private
6872

6973
def mutually_exclusive_droplet_sources

spec/request/deployments_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,12 @@
580580
let(:create_request) do
581581
{
582582
strategy: 'canary',
583+
options: {
584+
max_in_flight: 10,
585+
canary: {
586+
steps: [{ instance_weight: 1 }, { instance_weight: 2 }]
587+
}
588+
},
583589
relationships: {
584590
app: {
585591
data: {
@@ -594,6 +600,13 @@
594600
revision: {
595601
guid: revision.guid
596602
},
603+
strategy: 'canary',
604+
options: {
605+
max_in_flight: 10,
606+
canary: {
607+
steps: [{ instance_weight: 1 }, { instance_weight: 2 }]
608+
}
609+
},
597610
relationships: {
598611
app: {
599612
data: {
@@ -612,6 +625,8 @@
612625
'create-deployment' => {
613626
'api-version' => 'v3',
614627
'strategy' => 'canary',
628+
'max-in-flight' => 10,
629+
'canary-steps' => [{ 'instance_weight' => 1 }, { 'instance_weight' => 2 }],
615630
'app-id' => OpenSSL::Digest::SHA256.hexdigest(app_model.guid),
616631
'user-id' => OpenSSL::Digest::SHA256.hexdigest(user.guid)
617632
}
@@ -632,6 +647,8 @@
632647
'rolled-back-app' => {
633648
'api-version' => 'v3',
634649
'strategy' => 'canary',
650+
'max-in-flight' => 10,
651+
'canary-steps' => [{ 'instance_weight' => 1 }, { 'instance_weight' => 2 }],
635652
'app-id' => OpenSSL::Digest::SHA256.hexdigest(app_model.guid),
636653
'user-id' => OpenSSL::Digest::SHA256.hexdigest(user.guid),
637654
'revision-id' => OpenSSL::Digest::SHA256.hexdigest(revision.guid)

spec/unit/messages/deployment_create_message_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,5 +598,29 @@ module VCAP::CloudController
598598
end
599599
end
600600
end
601+
602+
describe 'canary steps' do
603+
context 'when options is not specified' do
604+
before do
605+
body['options'] = nil
606+
end
607+
608+
it 'returns nil' do
609+
message = DeploymentCreateMessage.new(body)
610+
expect(message.canary_steps).to be_nil
611+
end
612+
end
613+
614+
context 'when canary and steps are specified' do
615+
before do
616+
body['options'] = { canary: { steps: [{ instance_weight: 1 }] } }
617+
end
618+
619+
it 'returns the passed value' do
620+
message = DeploymentCreateMessage.new(body)
621+
expect(message.canary_steps).to eq [{ instance_weight: 1 }]
622+
end
623+
end
624+
end
601625
end
602626
end

0 commit comments

Comments
 (0)