Skip to content

Commit

Permalink
Merge pull request #293 from sap-contributions/broker-client-response…
Browse files Browse the repository at this point in the history
…-parser-logging-config

Add broker_client_response_parser logging config
  • Loading branch information
tjvman authored Apr 25, 2023
2 parents 6bab5ca + 125d31b commit 4ffaf3d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
10 changes: 10 additions & 0 deletions jobs/cloud_controller_ng/spec
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,16 @@ properties:
default: 1.0
description: "Exponential backoff for service related polling jobs. Default is 1.0, which means there is no exponential backoff."

cc.broker_client_response_parser.log_errors:
default: false
description: "Log errors happening when parsing service broker responses."
cc.broker_client_response_parser.log_validators:
default: false
description: "Log the stack of validators used to process the service broker response, e.g. for a 202 response to a 'provision' request, the following is logged: [\"CommonErrorValidator\", \"JsonSchemaValidator[provision_response_schema]\", \"SuccessValidator[in progress]\"]"
cc.broker_client_response_parser.log_response_fields:
default: {}
description: "Specify service broker response fields to be logged. This configuration is a hash, where the key indicates the request type and the value is a list of fields in the response JSON that should be logged. The following request types exist: catalog, provision, update, deprovision, bind, unbind, fetch_service_instance_last_operation, fetch_service_binding_last_operation, fetch_service_instance, fetch_service_binding"

cc.development_mode:
default: false
description: "Enable development features for monitoring and insight"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ broker_client_timeout_seconds: <%= p("cc.broker_client_timeout_seconds") %>
broker_client_default_async_poll_interval_seconds: <%= p('cc.broker_client_default_async_poll_interval_seconds') %>
broker_client_max_async_poll_duration_minutes: <%= p('cc.broker_client_max_async_poll_duration_minutes') %>
broker_client_async_poll_exponential_backoff_rate: <%= p('cc.broker_client_async_poll_exponential_backoff_rate') %>

broker_client_response_parser:
log_errors: <%= p("cc.broker_client_response_parser.log_errors") %>
log_validators: <%= p("cc.broker_client_response_parser.log_validators") %>
log_response_fields: <%= p("cc.broker_client_response_parser.log_response_fields").to_json %>

renderer:
max_results_per_page: <%= p("cc.renderer.max_results_per_page") %>
default_results_per_page: <%= p("cc.renderer.default_results_per_page") %>
Expand Down
10 changes: 10 additions & 0 deletions jobs/cloud_controller_worker/spec
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ properties:
default: 1.0
description: "Exponential backoff for service related polling jobs. Default is 1.0, which means there is no exponential backoff."

cc.broker_client_response_parser.log_errors:
default: false
description: "Log errors happening when parsing service broker responses."
cc.broker_client_response_parser.log_validators:
default: false
description: "Log the stack of validators used to process the service broker response, e.g. for a 202 response to a 'provision' request, the following is logged: [\"CommonErrorValidator\", \"JsonSchemaValidator[provision_response_schema]\", \"SuccessValidator[in progress]\"]"
cc.broker_client_response_parser.log_response_fields:
default: {}
description: "Specify service broker response fields to be logged. This configuration is a hash, where the key indicates the request type and the value is a list of fields in the response JSON that should be logged. The following request types exist: catalog, provision, update, deprovision, bind, unbind, fetch_service_instance_last_operation, fetch_service_binding_last_operation, fetch_service_instance, fetch_service_binding"

cc.diego.bbs.url:
description: "URL of the BBS Server"
default: https://bbs.service.cf.internal:8889
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ broker_client_default_async_poll_interval_seconds: <%= p('cc.broker_client_defau
broker_client_max_async_poll_duration_minutes: <%= p('cc.broker_client_max_async_poll_duration_minutes') %>
broker_client_async_poll_exponential_backoff_rate: <%= p('cc.broker_client_async_poll_exponential_backoff_rate') %>

broker_client_response_parser:
log_errors: <%= p("cc.broker_client_response_parser.log_errors") %>
log_validators: <%= p("cc.broker_client_response_parser.log_validators") %>
log_response_fields: <%= p("cc.broker_client_response_parser.log_response_fields").to_json %>

<% if_p("uaa.clients.cc_service_broker_client.secret") do %>
uaa_client_name: "cc_service_broker_client"
uaa_client_secret: <%= p("uaa.clients.cc_service_broker_client.secret") %>
Expand Down
25 changes: 25 additions & 0 deletions spec/cloud_controller_ng/cloud_controller_ng_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,31 @@ module Test
expect(template_hash['diego']['file_server_url']).to eq('http://somewhere')
end
end

describe 'broker_client_response_parser config' do
context 'when nothing is configured' do
it 'renders default values' do
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
expect(template_hash['broker_client_response_parser']['log_errors']).to be(false)
expect(template_hash['broker_client_response_parser']['log_validators']).to be(false)
expect(template_hash['broker_client_response_parser']['log_response_fields']).to eq({})
end
end

context 'when config values are provided' do
it 'renders the corresponding Cloud Controller config' do
merged_manifest_properties['cc']['broker_client_response_parser'] = {
'log_errors' => true,
'log_validators' => true,
'log_response_fields' => { 'a' => ['b'] }
}
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
expect(template_hash['broker_client_response_parser']['log_errors']).to be(true)
expect(template_hash['broker_client_response_parser']['log_validators']).to be(true)
expect(template_hash['broker_client_response_parser']['log_response_fields']).to eq({ 'a' => ['b'] })
end
end
end
end
end
end
Expand Down
25 changes: 25 additions & 0 deletions spec/cloud_controller_worker/cloud_controller_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,31 @@ module Test
end
end
end

describe 'broker_client_response_parser config' do
context 'when nothing is configured' do
it 'renders default values' do
template_hash = YAML.safe_load(template.render(manifest_properties, consumes: links))
expect(template_hash['broker_client_response_parser']['log_errors']).to be(false)
expect(template_hash['broker_client_response_parser']['log_validators']).to be(false)
expect(template_hash['broker_client_response_parser']['log_response_fields']).to eq({})
end
end

context 'when config values are provided' do
it 'renders the corresponding Cloud Controller Worker config' do
manifest_properties['cc']['broker_client_response_parser'] = {
'log_errors' => true,
'log_validators' => true,
'log_response_fields' => { 'a' => ['b'] }
}
template_hash = YAML.safe_load(template.render(manifest_properties, consumes: links))
expect(template_hash['broker_client_response_parser']['log_errors']).to be(true)
expect(template_hash['broker_client_response_parser']['log_validators']).to be(true)
expect(template_hash['broker_client_response_parser']['log_response_fields']).to eq({ 'a' => ['b'] })
end
end
end
end
end
end
Expand Down

0 comments on commit 4ffaf3d

Please sign in to comment.