From 9b9e43f0382313df8d2c4d8f3c0cfb339496c19a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 18 Jul 2022 12:05:18 +0900 Subject: [PATCH] Fail if pipeline does not include the proper server The pipeline parameter of each server should contain the server itself. This change makes this enforced during deployment. Also, the server application should be placed at the end of pipeline. This change also makes this requirement validated. Change-Id: I04dec572e3cfae7f166daf933b7c1afd7e38ef83 --- manifests/internal_client.pp | 4 ++-- manifests/proxy.pp | 4 ++-- manifests/storage/server.pp | 5 +++-- spec/classes/swift_storage_all_spec.rb | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifests/internal_client.pp b/manifests/internal_client.pp index 89344c6a..f92cde84 100644 --- a/manifests/internal_client.pp +++ b/manifests/internal_client.pp @@ -62,8 +62,8 @@ class swift::internal_client ( validate_legacy(Array, 'validate_array', $pipeline) - if(! member($pipeline, 'proxy-server')) { - warning('pipeline parameter must contain proxy-server') + if empty($pipeline) or $pipeline[-1] != 'proxy-server' { + fail('proxy-server must be the last element in pipeline') } swift_internal_client_config { diff --git a/manifests/proxy.pp b/manifests/proxy.pp index 8de6f3a9..864f2e25 100644 --- a/manifests/proxy.pp +++ b/manifests/proxy.pp @@ -212,8 +212,8 @@ class swift::proxy( warning('no auth type provided in the pipeline') } - if(! member($pipeline, 'proxy-server')) { - warning('pipeline parameter must contain proxy-server') + if empty($pipeline) or $pipeline[-1] != 'proxy-server' { + fail('proxy-server must be the last element in pipeline') } if($auth_type == 'tempauth' and ! $account_autocreate ){ diff --git a/manifests/storage/server.pp b/manifests/storage/server.pp index 3a39eba5..ddbced13 100644 --- a/manifests/storage/server.pp +++ b/manifests/storage/server.pp @@ -246,10 +246,11 @@ define swift::storage::server( # Warn if ${type-server} isn't included in the pipeline $pipeline_array = any2array($pipeline) - if !member($pipeline_array, "${type}-server") { - warning("swift storage server ${type} must specify ${type}-server") + if empty($pipeline_array) or $pipeline_array[-1] != "${type}-server" { + fail("${type}-server must be the last element in pipeline") } + if ($log_udp_port and !$log_udp_host) { fail ('log_udp_port requires log_udp_host to be set') } diff --git a/spec/classes/swift_storage_all_spec.rb b/spec/classes/swift_storage_all_spec.rb index fe63583d..f5bd574b 100644 --- a/spec/classes/swift_storage_all_spec.rb +++ b/spec/classes/swift_storage_all_spec.rb @@ -36,9 +36,9 @@ describe 'swift::storage::all' do :object_port => "7000", :container_port => "7001", :account_port => "7002", - :object_pipeline => ["healthcheck"], - :container_pipeline => ["healthcheck"], - :account_pipeline => ["healthcheck"], + :object_pipeline => ['healthcheck', 'object-server'], + :container_pipeline => ['healthcheck', 'container-server'], + :account_pipeline => ['healthcheck', 'account-server'], :splice => true, :log_facility => ['LOG_LOCAL2', 'LOG_LOCAL3'], :incoming_chmod => '0644',