Merge "Create a separate class for [swift-constraints] options"
This commit is contained in:
		
							
								
								
									
										121
									
								
								manifests/constraints.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								manifests/constraints.pp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,121 @@
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2022 Red Hat
 | 
			
		||||
#
 | 
			
		||||
# Licensed 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.
 | 
			
		||||
#
 | 
			
		||||
# == Class: swift::constraints
 | 
			
		||||
#
 | 
			
		||||
# Configre the [swift-constraints] options
 | 
			
		||||
#
 | 
			
		||||
# == Parameters
 | 
			
		||||
#
 | 
			
		||||
# [*max_file_size*]
 | 
			
		||||
#   (Optional) The largest "normal" object that can be saved in the cluster.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_meta_name_length*]
 | 
			
		||||
#   (Optional) Max number of bytes in the utf8 encoding of the name portion of
 | 
			
		||||
#   a metadata header.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_meta_value_length*]
 | 
			
		||||
#   (Optional) Max number of bytes in the utf8 encoding of a metadata value.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_meta_count*]
 | 
			
		||||
#   (Optional) Max number of metadata keys that can be store on a single
 | 
			
		||||
#   account, container or object.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_meta_overall_size*]
 | 
			
		||||
#   (Optional) The max number of bytes in the utf8 encoding of the metadata.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_header_size*]
 | 
			
		||||
#   (Optional) Max HTTP header size for incoming requests for all swift
 | 
			
		||||
#   services.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*extra_header_count*]
 | 
			
		||||
#   (Optional) Allow additional headers in addition to max allowed metadata
 | 
			
		||||
#   plus a default value of 36 for swift internally generated headers and
 | 
			
		||||
#   regular http headers.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_object_name_length*]
 | 
			
		||||
#   (Optional) Max number of bytes in the utf8 encoding of an object name.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*container_listing_limit*]
 | 
			
		||||
#   (Optional) Default (and max) number of items returned for a container
 | 
			
		||||
#   listing request.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*account_listing_limit*]
 | 
			
		||||
#   (Optional) Default (and max) number of items returned for an account
 | 
			
		||||
#   listing request.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_account_name_length*]
 | 
			
		||||
#   (Optional) Max number of bytes in the utf8 encoding of an account name.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*max_container_name_length*]
 | 
			
		||||
#   (Optional) Max number of bytes in the utf8 encoding of a container name.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*valid_api_versions*]
 | 
			
		||||
#   (Optional) Allowed version strings for all REST API calls.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
# [*auto_create_account_prefix*]
 | 
			
		||||
#   (Optional) Prefix used for hiddne auto-created accounts.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#
 | 
			
		||||
class swift::constraints(
 | 
			
		||||
  $max_file_size              = $::os_service_default,
 | 
			
		||||
  $max_meta_name_length       = $::os_service_default,
 | 
			
		||||
  $max_meta_value_length      = $::os_service_default,
 | 
			
		||||
  $max_meta_count             = $::os_service_default,
 | 
			
		||||
  $max_meta_overall_size      = $::os_service_default,
 | 
			
		||||
  $max_header_size            = $::os_service_default,
 | 
			
		||||
  $extra_header_count         = $::os_service_default,
 | 
			
		||||
  $max_object_name_length     = $::os_service_default,
 | 
			
		||||
  $container_listing_limit    = $::os_service_default,
 | 
			
		||||
  $account_listing_limit      = $::os_service_default,
 | 
			
		||||
  $max_account_name_length    = $::os_service_default,
 | 
			
		||||
  $max_container_name_length  = $::os_service_default,
 | 
			
		||||
  $valid_api_versions         = $::os_service_default,
 | 
			
		||||
  $auto_create_account_prefix = $::os_service_default,
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  include swift::deps
 | 
			
		||||
  include swift::params
 | 
			
		||||
 | 
			
		||||
  swift_config {
 | 
			
		||||
    'swift-constraints/max_file_size':              value => $max_file_size;
 | 
			
		||||
    'swift-constraints/max_meta_name_length':       value => $max_meta_name_length;
 | 
			
		||||
    'swift-constraints/max_meta_value_length':      value => $max_meta_value_length;
 | 
			
		||||
    'swift-constraints/max_meta_count':             value => $max_meta_count;
 | 
			
		||||
    'swift-constraints/max_meta_overall_size':      value => $max_meta_overall_size;
 | 
			
		||||
    'swift-constraints/max_header_size':            value => pick($::swift::max_header_size, $max_header_size);
 | 
			
		||||
    'swift-constraints/extra_header_count':         value => $extra_header_count;
 | 
			
		||||
    'swift-constraints/max_object_name_length':     value => $max_object_name_length;
 | 
			
		||||
    'swift-constraints/container_listing_limit':    value => $container_listing_limit;
 | 
			
		||||
    'swift-constraints/account_listing_limit':      value => $account_listing_limit;
 | 
			
		||||
    'swift-constraints/max_account_name_length':    value => $max_account_name_length;
 | 
			
		||||
    'swift-constraints/max_container_name_length':  value => $max_container_name_length;
 | 
			
		||||
    'swift-constraints/valid_api_versions':         value => join(any2array($valid_api_versions), ',');
 | 
			
		||||
    'swift-constraints/auto_create_account_prefix': value => $auto_create_account_prefix;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -27,10 +27,12 @@
 | 
			
		||||
#   (Optional) The ensure state for the swift package.
 | 
			
		||||
#   Defaults to present.
 | 
			
		||||
#
 | 
			
		||||
# DEPRECATED PARAMETERS
 | 
			
		||||
#
 | 
			
		||||
# [*max_header_size*]
 | 
			
		||||
#   (Optional) Max HTTP header size for incoming requests for all swift
 | 
			
		||||
#   services.
 | 
			
		||||
#   Defaults to $::os_service_default
 | 
			
		||||
#   Defaults to undef
 | 
			
		||||
#
 | 
			
		||||
# == Dependencies
 | 
			
		||||
#
 | 
			
		||||
@@ -48,7 +50,8 @@ class swift(
 | 
			
		||||
  $swift_hash_path_suffix = $::os_service_default,
 | 
			
		||||
  $swift_hash_path_prefix = $::os_service_default,
 | 
			
		||||
  $package_ensure         = 'present',
 | 
			
		||||
  $max_header_size        = $::os_service_default,
 | 
			
		||||
  # DEPRECATED PARAMETERS
 | 
			
		||||
  $max_header_size        = undef
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  include swift::deps
 | 
			
		||||
@@ -68,6 +71,10 @@ class swift(
 | 
			
		||||
  swift_config {
 | 
			
		||||
    'swift-hash/swift_hash_path_suffix': value => $swift_hash_path_suffix;
 | 
			
		||||
    'swift-hash/swift_hash_path_prefix': value => $swift_hash_path_prefix;
 | 
			
		||||
    'swift-constraints/max_header_size': value => $max_header_size;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if $max_header_size != undef {
 | 
			
		||||
    warning('The swift::max_header_size parameter is deprecated. Use the swift::constraints class.')
 | 
			
		||||
    include swift::constraints
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,10 +17,6 @@
 | 
			
		||||
#    (optional) The list of elements of the object expirer pipeline.
 | 
			
		||||
#    Defaults to ['catch_errors', 'proxy-logging', 'cache', 'proxy-server']
 | 
			
		||||
#
 | 
			
		||||
#  [*auto_create_account_prefix*]
 | 
			
		||||
#    (optional) Prefix to use when automatically creating accounts.
 | 
			
		||||
#    Defaults to $::os_service_default.
 | 
			
		||||
#
 | 
			
		||||
#  [*concurrency*]
 | 
			
		||||
#    (optional) Number of replication workers to spawn.
 | 
			
		||||
#    Defaults to $::os_service_default.
 | 
			
		||||
@@ -105,12 +101,17 @@
 | 
			
		||||
#    (optional) Log level
 | 
			
		||||
#    Defaults to 'LOG_LOCAL2'.
 | 
			
		||||
#
 | 
			
		||||
# DEPRECATED PARAMETERS
 | 
			
		||||
#
 | 
			
		||||
#  [*auto_create_account_prefix*]
 | 
			
		||||
#    (optional) Prefix to use when automatically creating accounts.
 | 
			
		||||
#    Defaults to undef
 | 
			
		||||
#
 | 
			
		||||
class swift::objectexpirer(
 | 
			
		||||
  $manage_service                = true,
 | 
			
		||||
  $enabled                       = true,
 | 
			
		||||
  $package_ensure                = 'present',
 | 
			
		||||
  $pipeline                      = ['catch_errors', 'proxy-logging', 'cache', 'proxy-server'],
 | 
			
		||||
  $auto_create_account_prefix    = $::os_service_default,
 | 
			
		||||
  $concurrency                   = $::os_service_default,
 | 
			
		||||
  $expiring_objects_account_name = $::os_service_default,
 | 
			
		||||
  $interval                      = $::os_service_default,
 | 
			
		||||
@@ -127,12 +128,18 @@ class swift::objectexpirer(
 | 
			
		||||
  $cache_tls_keyfile             = undef,
 | 
			
		||||
  $log_level                     = 'INFO',
 | 
			
		||||
  $log_facility                  = 'LOG_LOCAL2',
 | 
			
		||||
  # DEPRECATED PARAMETERS
 | 
			
		||||
  $auto_create_account_prefix    = undef,
 | 
			
		||||
) inherits swift::params {
 | 
			
		||||
 | 
			
		||||
  include swift::deps
 | 
			
		||||
  Swift_config<| |> ~> Service['swift-object-expirer']
 | 
			
		||||
  Swift_object_expirer_config<||> ~> Service['swift-object-expirer']
 | 
			
		||||
 | 
			
		||||
  if $auto_create_account_prefix != undef {
 | 
			
		||||
    warning('The auto_create_account_prefix parameter is deprecated. Use the swift::constraints class.')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  # On Red Hat platforms, it may be defined already,
 | 
			
		||||
  # because it is part of openstack-swift-proxy
 | 
			
		||||
  if $::swift::params::object_expirer_package_name != $::swift::params::proxy_package_name {
 | 
			
		||||
@@ -174,7 +181,7 @@ class swift::objectexpirer(
 | 
			
		||||
 | 
			
		||||
  swift_object_expirer_config {
 | 
			
		||||
    'pipeline:main/pipeline':                       value => join($pipeline, ' ');
 | 
			
		||||
    'object-expirer/auto_create_account_prefix':    value => $auto_create_account_prefix;
 | 
			
		||||
    'object-expirer/auto_create_account_prefix':    value => pick($auto_create_account_prefix, $::os_service_default);
 | 
			
		||||
    'object-expirer/concurrency':                   value => $concurrency;
 | 
			
		||||
    'object-expirer/expiring_objects_account_name': value => $expiring_objects_account_name;
 | 
			
		||||
    'object-expirer/interval':                      value => $interval;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								releasenotes/notes/swift-constraints-818407c7fc2c1025.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								releasenotes/notes/swift-constraints-818407c7fc2c1025.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
---
 | 
			
		||||
features:
 | 
			
		||||
  - |
 | 
			
		||||
    The new ``swift::constraints`` class, which manages the
 | 
			
		||||
    ``[swift-constraints]`` options, has been added.
 | 
			
		||||
 | 
			
		||||
deprecations:
 | 
			
		||||
  - |
 | 
			
		||||
    The ``swift::max_header_size`` parameter has been deprecated in favor of
 | 
			
		||||
    the new ``swift::constraints`` class.
 | 
			
		||||
 | 
			
		||||
  - |
 | 
			
		||||
    The ``swift::objectexpirer::auto_create_account_prefix`` parameter has been
 | 
			
		||||
    deprecated. Use the ``swift::constraints::auto_create_account_prefix``
 | 
			
		||||
    parameter instead.
 | 
			
		||||
							
								
								
									
										73
									
								
								spec/classes/swift_constraints_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								spec/classes/swift_constraints_spec.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
require 'spec_helper'
 | 
			
		||||
 | 
			
		||||
describe 'swift::constraints' do
 | 
			
		||||
  shared_examples 'swift::constraints' do
 | 
			
		||||
    context 'with defaults' do
 | 
			
		||||
      it 'should configure swift.conf' do
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_file_size').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_name_length').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_value_length').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_count').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_overall_size').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_header_size').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/extra_header_count').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_object_name_length').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/container_listing_limit').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/account_listing_limit').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_account_name_length').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_container_name_length').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/valid_api_versions').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/auto_create_account_prefix').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with parameters' do
 | 
			
		||||
      let :params do
 | 
			
		||||
        {
 | 
			
		||||
          :max_file_size              => 5368709122,
 | 
			
		||||
          :max_meta_name_length       => 128,
 | 
			
		||||
          :max_meta_value_length      => 256,
 | 
			
		||||
          :max_meta_count             => 20,
 | 
			
		||||
          :max_meta_overall_size      => 4096,
 | 
			
		||||
          :max_header_size            => 8192,
 | 
			
		||||
          :extra_header_count         => 0,
 | 
			
		||||
          :max_object_name_length     => 1024,
 | 
			
		||||
          :container_listing_limit    => 10000,
 | 
			
		||||
          :account_listing_limit      => 10000,
 | 
			
		||||
          :max_account_name_length    => 256,
 | 
			
		||||
          :max_container_name_length  => 256,
 | 
			
		||||
          :valid_api_versions         => ['v1', 'v1.0'],
 | 
			
		||||
          :auto_create_account_prefix => '.',
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
      it 'should configure swift.conf' do
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_file_size').with_value(5368709122)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_name_length').with_value(128)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_value_length').with_value(256)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_count').with_value(20)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_meta_overall_size').with_value(4096)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_header_size').with_value(8192)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/extra_header_count').with_value(0)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_object_name_length').with_value(1024)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/container_listing_limit').with_value(10000)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/account_listing_limit').with_value(10000)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_account_name_length').with_value(256)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/max_container_name_length').with_value(256)
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/valid_api_versions').with_value('v1,v1.0')
 | 
			
		||||
        is_expected.to contain_swift_config('swift-constraints/auto_create_account_prefix').with_value('.')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  on_supported_os({
 | 
			
		||||
    :supported_os => OSDefaults.get_supported_os
 | 
			
		||||
  }).each do |os,facts|
 | 
			
		||||
    context "on #{os}" do
 | 
			
		||||
      let (:facts) do
 | 
			
		||||
        facts.merge(OSDefaults.get_facts())
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it_configures 'swift::constraints'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@@ -24,8 +24,6 @@ describe 'swift' do
 | 
			
		||||
          'swift-hash/swift_hash_path_suffix').with_value('string')
 | 
			
		||||
        is_expected.to contain_swift_config(
 | 
			
		||||
          'swift-hash/swift_hash_path_prefix').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
        is_expected.to contain_swift_config(
 | 
			
		||||
          'swift-constraints/max_header_size').with_value('<SERVICE DEFAULT>')
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user