From 7a4f1c7d9e13731c9d3ae5c7d2beb9d06a6d9825 Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Tue, 24 Mar 2015 12:00:22 +0000 Subject: [PATCH] Fix dedicated replication network logic * Adjust the init scripts to be dropped * Ensure dedicated server is started for dedicated replication network * Remove the dedicated replication conf when no dedicated replication network is in use. Closes-Bug: 1435802 Change-Id: I8ccc32eb7d3cdeb36b3cae94ea51d8b0a1fd3e71 --- defaults/main.yml | 3 +++ tasks/swift_storage_hosts.yml | 2 +- tasks/swift_storage_hosts_account.yml | 22 +++++++++++++++++++ tasks/swift_storage_hosts_container.yml | 22 +++++++++++++++++++ ...ver.yml => swift_storage_hosts_object.yml} | 22 +++++++++++++++++++ templates/swift-upstart-init.j2 | 19 +++++++++------- 6 files changed, 81 insertions(+), 9 deletions(-) rename tasks/{swift_storage_hosts_object_server.yml => swift_storage_hosts_object.yml} (78%) diff --git a/defaults/main.yml b/defaults/main.yml index 8984f780..ff27c1e1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -133,6 +133,7 @@ swift_account_program_names: - swift-account-auditor - swift-account-replicator - swift-account-reaper + - swift-account-replicator-server swift_container_program_names: - swift-container-server @@ -140,12 +141,14 @@ swift_container_program_names: - swift-container-replicator - swift-container-sync - swift-container-updater + - swift-container-replicator-server swift_object_program_names: - swift-object-server - swift-object-auditor - swift-object-replicator - swift-object-updater + - swift-object-replicator-server swift_proxy_program_names: - swift-proxy-server diff --git a/tasks/swift_storage_hosts.yml b/tasks/swift_storage_hosts.yml index 8e34b157..d33f083f 100644 --- a/tasks/swift_storage_hosts.yml +++ b/tasks/swift_storage_hosts.yml @@ -14,6 +14,6 @@ # limitations under the License. - include: swift_storage_hosts_setup.yml -- include: swift_storage_hosts_object_server.yml +- include: swift_storage_hosts_object.yml - include: swift_storage_hosts_account.yml - include: swift_storage_hosts_container.yml diff --git a/tasks/swift_storage_hosts_account.yml b/tasks/swift_storage_hosts_account.yml index 62898c71..2cf0cdae 100644 --- a/tasks/swift_storage_hosts_account.yml +++ b/tasks/swift_storage_hosts_account.yml @@ -39,6 +39,19 @@ swift.replication_network is defined and swift.replication_network != swift.storage_network +# When using a replication network use a second server for dedicated replicator configuration +# This will be a blank file if not using dedicated replication network to prevent errors +# when the service attempts to start. +- include: swift_upstart_common_init.yml + vars: + program_name: "swift-account-replicator-server" + program_binary: "swift-account-server" + program_config_options: "{{ swift_account_replicator_program_config_options }}" + service_name: "{{ swift_service_name }}" + system_user: "{{ swift_system_user_name }}" + system_group: "{{ swift_system_group_name }}" + service_home: "{{ swift_system_home_folder }}" + - include: swift_upstart_common_init.yml vars: program_name: "swift-account-server" @@ -91,3 +104,12 @@ swift.replication_network is defined and swift.replication_network != swift.storage_network notify: Restart swift account services + +# Remove the dedicated replicator configuration when no dedicated replication network in use +- name: "Remove dedicated replicator configuration" + file: + state: absent + path: "/etc/swift/account-server/account-server-replicator.conf" + when: > + swift.replication_network is not defined or + swift.replication_network == swift.storage_network diff --git a/tasks/swift_storage_hosts_container.yml b/tasks/swift_storage_hosts_container.yml index fe8d04d6..8a7183b9 100644 --- a/tasks/swift_storage_hosts_container.yml +++ b/tasks/swift_storage_hosts_container.yml @@ -39,6 +39,19 @@ swift.replication_network is defined and swift.replication_network != swift.storage_network +# When using a replication network create a second server for dedicated replicator configuration +# This will be a blank file if not using dedicated replication network to prevent errors +# when the service attempts to start. +- include: swift_upstart_common_init.yml + vars: + program_name: "swift-container-replicator-server" + program_binary: "swift-container-server" + program_config_options: "{{ swift_container_replicator_program_config_options }}" + service_name: "{{ swift_service_name }}" + system_user: "{{ swift_system_user_name }}" + system_group: "{{ swift_system_group_name }}" + service_home: "{{ swift_system_home_folder }}" + - include: swift_upstart_common_init.yml vars: program_name: "swift-container-server" @@ -100,3 +113,12 @@ swift.replication_network is defined and swift.replication_network != swift.storage_network notify: Restart swift container services + +# Remove the dedicated replicator configuration when no dedicated replication network in use +- name: "Remove dedicated replicator configuration" + file: + state: absent + path: "/etc/swift/container-server/container-server-replicator.conf" + when: > + swift.replication_network is not defined or + swift.replication_network == swift.storage_network diff --git a/tasks/swift_storage_hosts_object_server.yml b/tasks/swift_storage_hosts_object.yml similarity index 78% rename from tasks/swift_storage_hosts_object_server.yml rename to tasks/swift_storage_hosts_object.yml index 9aa8d36e..60a3b695 100644 --- a/tasks/swift_storage_hosts_object_server.yml +++ b/tasks/swift_storage_hosts_object.yml @@ -39,6 +39,19 @@ swift.replication_network is defined and swift.replication_network != swift.storage_network +# When using a replication network use a second server for dedicated replicator configuration +# This will be a blank file if not using dedicated replication network to prevent errors +# when the service attempts to start. +- include: swift_upstart_common_init.yml + vars: + program_name: "swift-object-replicator-server" + program_binary: "swift-object-server" + program_config_options: "{{ swift_object_replicator_program_config_options }}" + service_name: "{{ swift_service_name }}" + system_user: "{{ swift_system_user_name }}" + system_group: "{{ swift_system_group_name }}" + service_home: "{{ swift_system_home_folder }}" + - include: swift_upstart_common_init.yml vars: program_name: "swift-object-server" @@ -91,3 +104,12 @@ swift.replication_network is defined and swift.replication_network != swift.storage_network notify: Restart swift object services + +# Remove the dedicated replicator configuration when no dedicated replication network in use +- name: "Remove dedicated replicator configuration" + file: + state: absent + path: "/etc/swift/object-server/object-server-replicator.conf" + when: > + swift.replication_network is not defined or + swift.replication_network == swift.storage_network diff --git a/templates/swift-upstart-init.j2 b/templates/swift-upstart-init.j2 index a9e477ac..e9b0954f 100644 --- a/templates/swift-upstart-init.j2 +++ b/templates/swift-upstart-init.j2 @@ -1,5 +1,7 @@ # {{ ansible_managed }} - +{% if (swift.replication_network is not defined or swift.replication_network == swift.storage_network) and 'replicator-server' in program_name %} +# Blank script - dedicated replication network not in use +{% else %} # vim:set ft=upstart ts=2 et: description "{{ program_name }}" @@ -12,28 +14,29 @@ respawn respawn limit 10 5 # Set the RUNBIN environment variable -env RUNBIN="/usr/local/bin/{{ program_name }}" +env RUNBIN="/usr/local/bin/{{ program_binary | default(program_name) }}" # Change directory to service users home chdir "{{ service_home }}" # Pre start actions pre-start script - mkdir -p "/var/run/{{ program_name }}" - chown {{ system_user }}:{{ system_group }} "/var/run/{{ program_name }}" + mkdir -p "/var/run/{{ program_binary | default(program_name) }}" + chown {{ system_user }}:{{ system_group }} "/var/run/{{ program_binary | default(program_name) }}" - mkdir -p "/var/lock/{{ program_name }}" - chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}" + mkdir -p "/var/lock/{{ program_binary | default(program_name) }}" + chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_binary | default(program_name) }}" end script # Post stop actions post-stop script - rm "/var/run/{{ program_name }}/{{ program_name }}.pid" + rm "/var/run/{{ program_binary | default(program_name) }}/{{ program_name }}.pid" end script # Run the start up job exec start-stop-daemon --start \ --chuid {{ system_user }} \ --make-pidfile \ - --pidfile /var/run/{{ program_name }}/{{ program_name }}.pid \ + --pidfile /var/run/{{ program_binary | default(program_name) }}/{{ program_name }}.pid \ --exec "{{ program_override|default('$RUNBIN') }}" "{{ program_config_options|default('') }}" +{% endif %}