From f77e90f0335e97ff9b5f621538e9dcc0db89d676 Mon Sep 17 00:00:00 2001 From: Kieron Browne Date: Thu, 21 Feb 2019 16:06:40 +0000 Subject: [PATCH] Temporarily remove BPM in order to produce 0.26.1 release Revert "Adds BPM to broker" This reverts commit de45cd25875319cc9ff4961c5766c84594226c96. Co-authored-by: Winna Bridgewater --- examples/deployment/operations/redis.yml | 4 - jobs/broker/monit | 6 +- jobs/broker/spec | 10 +- jobs/broker/templates/bpm.yml.erb | 34 ----- jobs/broker/templates/broker-ctl.sh.erb | 65 ++++++++++ jobs/broker/templates/drain.sh.erb | 2 +- spec/broker_bpm_spec.rb | 119 ------------------ ...-broker-bpm-config-custom-adapter-path.yml | 10 -- .../valid-broker-bpm-config-no-mounts.yml | 6 - spec/fixtures/valid-broker-bpm-config.yml | 10 -- 10 files changed, 72 insertions(+), 194 deletions(-) delete mode 100644 jobs/broker/templates/bpm.yml.erb create mode 100644 jobs/broker/templates/broker-ctl.sh.erb delete mode 100644 spec/broker_bpm_spec.rb delete mode 100644 spec/fixtures/valid-broker-bpm-config-custom-adapter-path.yml delete mode 100644 spec/fixtures/valid-broker-bpm-config-no-mounts.yml delete mode 100644 spec/fixtures/valid-broker-bpm-config.yml diff --git a/examples/deployment/operations/redis.yml b/examples/deployment/operations/redis.yml index 674a2f702..364531e7c 100644 --- a/examples/deployment/operations/redis.yml +++ b/examples/deployment/operations/redis.yml @@ -14,10 +14,6 @@ path: /instance_groups/name=broker/jobs/name=broker/properties/service_catalog/tags/- value: redis -- type: replace - path: /instance_groups/name=broker/jobs/name=broker/properties/service_adapter?/mount_paths?/- - value: /var/vcap/jobs/service-adapter/config/service-adapter.conf - - type: replace path: /instance_groups/name=broker/jobs/name=broker/properties/service_deployment? value: diff --git a/jobs/broker/monit b/jobs/broker/monit index a2ae39ec7..55a5efc86 100644 --- a/jobs/broker/monit +++ b/jobs/broker/monit @@ -5,7 +5,7 @@ # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. check process broker - with pidfile /var/vcap/sys/run/bpm/broker/broker.pid - start program "/var/vcap/jobs/bpm/bin/bpm start broker" - stop program "/var/vcap/jobs/bpm/bin/bpm stop broker" + with pidfile /var/vcap/sys/run/broker/broker.pid + start program "/var/vcap/jobs/broker/bin/broker-ctl.sh start" + stop program "/var/vcap/jobs/broker/bin/broker-ctl.sh stop" group vcap diff --git a/jobs/broker/spec b/jobs/broker/spec index 2bcaf4f19..b6eebfc26 100644 --- a/jobs/broker/spec +++ b/jobs/broker/spec @@ -8,11 +8,11 @@ name: broker templates: post-start.erb: bin/post-start + broker-ctl.sh.erb: bin/broker-ctl.sh broker.yml.erb: config/broker.yml drain.sh.erb: bin/drain broker.crt.erb: certs/broker.crt broker.key.erb: certs/broker.key - bpm.yml.erb: config/bpm.yml packages: - broker @@ -182,12 +182,8 @@ properties: description: Secret of UAA client with permissions to read and write to BOSH CredHub service_adapter.path: - description: The path to the service adapter binary located on the host with the broker - default: "/var/vcap/packages/odb-service-adapter/bin/service-adapter" - - service_adapter.mount_paths: - description: "Filesystem paths to be mounted for use by the service adapter. This should include the paths to any config files." - default: [] + description: the path to the service adapter binary located on the host with the broker + default: /var/vcap/packages/odb-service-adapter/bin/service-adapter service_deployment.releases: description: releases to deploy for each instance diff --git a/jobs/broker/templates/bpm.yml.erb b/jobs/broker/templates/bpm.yml.erb deleted file mode 100644 index 9cf25e1ab..000000000 --- a/jobs/broker/templates/bpm.yml.erb +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -<%= -unrestricted_volumes = [{ - 'path' => p("service_adapter.path"), - 'allow_executions' => true, - 'mount_only' => true, - 'writable' => false -}] - -p("service_adapter.mount_paths").each do |e| - unrestricted_volumes << { - 'path' => e, - 'allow_executions' => true, - 'mount_only' => true, - 'writable' => false - } -end - -bpm_config = { - 'processes' => [{ - 'name' => 'broker', - 'executable' => '/var/vcap/packages/broker/bin/on-demand-service-broker', - 'args' => [ - '-configFilePath', - '/var/vcap/jobs/broker/config/broker.yml' - ], - 'unsafe' => { - 'unrestricted_volumes' => unrestricted_volumes - } - }] -} - -bpm_config.to_yaml -%> diff --git a/jobs/broker/templates/broker-ctl.sh.erb b/jobs/broker/templates/broker-ctl.sh.erb new file mode 100644 index 000000000..e2ed3d09d --- /dev/null +++ b/jobs/broker/templates/broker-ctl.sh.erb @@ -0,0 +1,65 @@ +#!/bin/bash -eu + +# Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. +# This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + +set -o pipefail + +job_dir=/var/vcap/jobs/broker +log_dir=/var/vcap/sys/log/broker +run_dir=/var/vcap/sys/run/broker +run_script=/var/vcap/packages/broker/bin/on-demand-service-broker + +pidfile=$run_dir/broker.pid + +utils_path=/var/vcap/packages/broker_utils +source ${utils_path}/log.sh +source ${utils_path}/common.sh + +ensure_dir $job_dir +ensure_dir $log_dir +ensure_dir $run_dir + +export LOG_FILE=$log_dir/broker_ctl.log + +case $1 in + start) + log info "starting broker" + echo $$ > $pidfile + ensure_dir $run_dir + + exec chpst -u vcap:vcap $run_script \ + -configFilePath /var/vcap/jobs/broker/config/broker.yml \ + >> $log_dir/broker.log 2>&1 + ;; + + stop) + log info "stopping broker" + + set +e + kill -9 $(cat $pidfile) + kill_exit_code=$? + + pkill -9 -f $run_script + pkill_exit_code=$? + set -e + + if [[ $kill_exit_code -ne 0 && $pkill_exit_code -ne 0 ]]; then + echo "Failed to stop broker process" + exit 1 + fi + + rm -f $pidfile + ;; + + *) + log warning "operation '$1' is not supported" + echo "Usage: broker-ctl.sh start/stop" >&2 + exit 1 + ;; + +esac diff --git a/jobs/broker/templates/drain.sh.erb b/jobs/broker/templates/drain.sh.erb index 4b21a2dc5..ead0a9d76 100644 --- a/jobs/broker/templates/drain.sh.erb +++ b/jobs/broker/templates/drain.sh.erb @@ -5,7 +5,7 @@ set -eu source /var/vcap/packages/broker_utils/common.sh log_dir=/var/vcap/sys/log/broker -run_dir=/var/vcap/sys/run/bpm/broker +run_dir=/var/vcap/sys/run/broker drain_log="${log_dir}/drain.log" ensure_dir ${log_dir} diff --git a/spec/broker_bpm_spec.rb b/spec/broker_bpm_spec.rb deleted file mode 100644 index 884fca767..000000000 --- a/spec/broker_bpm_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ - -# frozen_string_literal: true - -# Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. This -# program and the accompanying materials are made available under the terms of -# the under the Apache License, Version 2.0 (the "License"); you may not use -# this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -require 'spec_helper' -require 'tempfile' - -RSpec.describe 'broker bpm templating' do - let(:links) { [] } - let(:renderer) do - Bosh::Template::Renderer.new(context: BoshEmulator.director_merge( - YAML.load_file(manifest_file.path), 'broker', links - ).to_json) - end - let(:rendered_template) { renderer.render('jobs/broker/templates/bpm.yml.erb') } - let(:manifest_file) { nil } - - after do - manifest_file.close unless manifest_file.nil? - end - - before(:all) do - release_path = File.join(File.dirname(__FILE__), '..') - release = Bosh::Template::Test::ReleaseDir.new(release_path) - job = release.job('broker') - @template = job.template('config/bpm.yml') - end - - describe 'successful templating' do - let(:manifest_file) { File.open 'spec/fixtures/valid-broker-bpm-config.yml' } - - it 'succeeds' do - config = YAML.safe_load(rendered_template) - expected = { - 'processes' => [{ - 'name' => 'broker', - 'executable' => '/var/vcap/packages/broker/bin/on-demand-service-broker', - 'args' => [ - '-configFilePath', - '/var/vcap/jobs/broker/config/broker.yml' - ], - 'unsafe' => { - 'unrestricted_volumes' => [ - { - 'path' => '/var/vcap/packages/odb-service-adapter/bin/service-adapter', - 'writable' => false, - 'allow_executions' => true, - 'mount_only' => true - }, - { - 'path' => '/var/vcap/path-to-some-config-directory', - 'writable' => false, - 'allow_executions' => true, - 'mount_only' => true - }, - { - 'path' => '/var/vcap/path-to-some-other-directory', - 'writable' => false, - 'allow_executions' => true, - 'mount_only' => true - } - ] - } - }] - } - expect(config).to eq(expected) - end - end - - describe 'with no mount paths configured' do - let(:manifest_file) { File.open 'spec/fixtures/valid-broker-bpm-config-no-mounts.yml' } - - it 'succeeds' do - config = YAML.safe_load(rendered_template) - expected_unrestricted_volumes = [ - { - 'path' => '/var/vcap/packages/odb-service-adapter/bin/service-adapter', - 'writable' => false, - 'allow_executions' => true, - 'mount_only' => true - } - ] - expect(config['processes'][0]['unsafe']['unrestricted_volumes']).to eq(expected_unrestricted_volumes) - end - end - - describe 'with a custom service adapter path' do - let(:manifest_file) { File.open 'spec/fixtures/valid-broker-bpm-config-custom-adapter-path.yml' } - it 'templates the directory of the adapter path into unrestricted_volumes' do - config = YAML.safe_load(rendered_template) - expected_unrestricted_volumes = [ - { - 'path' => '/var/vcap/custom/adapter/executable.sh', - 'writable' => false, - 'allow_executions' => true, - 'mount_only' => true - }, - { - 'path' => '/var/vcap/path-to-some-config-directory', - 'writable' => false, - 'allow_executions' => true, - 'mount_only' => true - } - ] - expect(config['processes'][0]['unsafe']['unrestricted_volumes']).to eq(expected_unrestricted_volumes) - end - end -end diff --git a/spec/fixtures/valid-broker-bpm-config-custom-adapter-path.yml b/spec/fixtures/valid-broker-bpm-config-custom-adapter-path.yml deleted file mode 100644 index 8e6cfb947..000000000 --- a/spec/fixtures/valid-broker-bpm-config-custom-adapter-path.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -instance_groups: - - name: broker - jobs: - - name: broker - properties: - service_adapter: - path: /var/vcap/custom/adapter/executable.sh - mount_paths: - - /var/vcap/path-to-some-config-directory diff --git a/spec/fixtures/valid-broker-bpm-config-no-mounts.yml b/spec/fixtures/valid-broker-bpm-config-no-mounts.yml deleted file mode 100644 index 1eae20d85..000000000 --- a/spec/fixtures/valid-broker-bpm-config-no-mounts.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -instance_groups: - - name: broker - jobs: - - name: broker - properties: {} diff --git a/spec/fixtures/valid-broker-bpm-config.yml b/spec/fixtures/valid-broker-bpm-config.yml deleted file mode 100644 index 394046666..000000000 --- a/spec/fixtures/valid-broker-bpm-config.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -instance_groups: - - name: broker - jobs: - - name: broker - properties: - service_adapter: - mount_paths: - - /var/vcap/path-to-some-config-directory - - /var/vcap/path-to-some-other-directory