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
This commit is contained in:
Andy McCrae 2015-03-24 12:00:22 +00:00
parent 3f89385863
commit 7a4f1c7d9e
6 changed files with 81 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 %}