Skip to content

Commit

Permalink
containers: introduce target systemd unit
Browse files Browse the repository at this point in the history
This adds ceph-*.target systemd unit files support for containerized
deployments.
This also fixes a regression introduced by PR #6719 (rgw and nfs systemd
units not getting purged)

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1962748

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 09ef465)
  • Loading branch information
guits authored and dsavineau committed Aug 18, 2021
1 parent e7d9d0a commit afe442a
Show file tree
Hide file tree
Showing 25 changed files with 239 additions and 82 deletions.
115 changes: 50 additions & 65 deletions infrastructure-playbooks/cephadm-adopt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,14 @@
failed_when: false
when: containerized_deployment | bool

- name: remove ceph-mon systemd unit file
- name: remove ceph-mon systemd files
file:
path: /etc/systemd/system/ceph-mon@.service
path: "{{ item }}"
state: absent
when: containerized_deployment | bool

- name: remove ceph-mon systemd override directory
file:
path: /etc/systemd/system/ceph-mon@.service.d
state: absent
when: not containerized_deployment | bool
loop:
- /etc/systemd/system/ceph-mon@.service
- /etc/systemd/system/ceph-mon@.service.d
- /etc/systemd/system/ceph-mon.target

- name: waiting for the monitor to join the quorum...
command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} quorum_status --format json"
Expand Down Expand Up @@ -393,17 +390,15 @@
failed_when: false
when: containerized_deployment | bool

- name: remove ceph-mgr systemd unit file
- name: remove ceph-mgr systemd files
file:
path: /etc/systemd/system/ceph-mgr@.service
path: "{{ item }}"
state: absent
when: containerized_deployment | bool
loop:
- /etc/systemd/system/ceph-mgr@.service
- /etc/systemd/system/ceph-mgr@.service.d
- /etc/systemd/system/ceph-mgr.target

- name: remove ceph-mgr systemd override directory
file:
path: /etc/systemd/system/ceph-mgr@.service.d
state: absent
when: not containerized_deployment | bool

- name: set osd flags
hosts: "{{ mon_group_name|default('mons') }}[0]"
Expand Down Expand Up @@ -521,20 +516,15 @@
firewalld: "{{ true if configure_firewall | bool else false }}"
loop: '{{ (osd_list.stdout | from_json).keys() | list }}'

- name: remove ceph-osd systemd unit and ceph-osd-run.sh files
- name: remove ceph-osd systemd and ceph-osd-run.sh files
file:
path: '{{ item }}'
path: "{{ item }}"
state: absent
loop:
- /etc/systemd/system/ceph-osd@.service
- /etc/systemd/system/ceph-osd@.service.d
- /etc/systemd/system/ceph-osd.target
- "{{ ceph_osd_docker_run_script_path | default('/usr/share') }}/ceph-osd-run.sh"
when: containerized_deployment | bool

- name: remove ceph-osd systemd override directory
file:
path: /etc/systemd/system/ceph-osd@.service.d
state: absent
when: not containerized_deployment | bool

- name: waiting for clean pgs...
command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} pg stat --format json"
Expand Down Expand Up @@ -628,25 +618,22 @@
name: ceph-mds.target
state: stopped
enabled: false
when: not containerized_deployment | bool
failed_when: false

- name: reset failed ceph-mds systemd unit
command: "systemctl reset-failed ceph-mds@{{ ansible_facts['hostname'] }}" # noqa 303
changed_when: false
failed_when: false
when: containerized_deployment | bool

- name: remove ceph-mds systemd unit file
file:
path: /etc/systemd/system/ceph-mds@.service
state: absent
when: containerized_deployment | bool

- name: remove ceph-mds systemd override directory
- name: remove ceph-mds systemd files
file:
path: /etc/systemd/system/ceph-mds@.service.d
path: "{{ item }}"
state: absent
when: not containerized_deployment | bool
loop:
- /etc/systemd/system/ceph-mds@.service
- /etc/systemd/system/ceph-mds@.service.d
- /etc/systemd/system/ceph-mds.target

- name: remove legacy ceph mds data
file:
Expand Down Expand Up @@ -740,10 +727,10 @@

- name: stop and disable ceph-radosgw systemd target
service:
name: ceph-rgw.target
name: ceph-radosgw.target
state: stopped
enabled: false
when: not containerized_deployment | bool
failed_when: false

- name: reset failed ceph-radosgw systemd unit
command: "systemctl reset-failed ceph-radosgw@rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}" # noqa 303
Expand All @@ -752,17 +739,14 @@
loop: '{{ rgw_instances }}'
when: containerized_deployment | bool

- name: remove ceph-radosgw systemd unit file
- name: remove ceph-radosgw systemd files
file:
path: /etc/systemd/system/ceph-radosgw@.service
path: "{{ item }}"
state: absent
when: containerized_deployment | bool

- name: remove ceph-radosgw systemd override directory
file:
path: /etc/systemd/system/ceph-radosgw@.service.d
state: absent
when: not containerized_deployment | bool
loop:
- /etc/systemd/system/ceph-radosgw@.service
- /etc/systemd/system/ceph-radosgw@.service.d
- /etc/systemd/system/ceph-radosgw.target

- name: remove legacy ceph radosgw data
file:
Expand Down Expand Up @@ -809,17 +793,13 @@
failed_when: false
when: containerized_deployment | bool

- name: remove ceph-nfs systemd unit file
- name: remove ceph-nfs systemd unit files
file:
path: /etc/systemd/system/ceph-nfs@.service
path: "{{ item }}"
state: absent
when: containerized_deployment | bool

- name: remove ceph-nfs systemd override directory
file:
path: /etc/systemd/system/ceph-nfs@.service.d
state: absent
when: not containerized_deployment | bool
loop:
- /etc/systemd/system/ceph-nfs@.service
- /etc/systemd/system/ceph-nfs@.service.d

- name: remove legacy ceph radosgw directory
file:
Expand Down Expand Up @@ -953,25 +933,23 @@
name: ceph-rbd-mirror.target
state: stopped
enabled: false
when: not containerized_deployment | bool
failed_when: false

- name: reset failed rbd-mirror systemd unit
command: "systemctl reset-failed ceph-rbd-mirror@rbd-mirror.{{ ansible_facts['hostname'] }}" # noqa 303
changed_when: false
failed_when: false
when: containerized_deployment | bool

- name: remove rbd-mirror systemd unit file
- name: remove rbd-mirror systemd files
file:
path: /etc/systemd/system/ceph-rbd-mirror@.service
path: "{{ item }}"
state: absent
when: containerized_deployment | bool
loop:
- /etc/systemd/system/ceph-rbd-mirror@.service
- /etc/systemd/system/ceph-rbd-mirror@.service.d
- /etc/systemd/system/ceph-rbd-mirror.target

- name: remove rbd-mirror systemd override directory
file:
path: /etc/systemd/system/ceph-rbd-mirror@.service.d
state: absent
when: not containerized_deployment | bool

- name: redeploy iscsigw daemons
hosts: "{{ iscsi_gw_group_name|default('iscsigws') }}"
Expand Down Expand Up @@ -1030,6 +1008,7 @@
- tcmu-runner
when: containerized_deployment | bool


- name: redeploy ceph-crash daemons
hosts:
- "{{ mon_group_name|default('mons') }}"
Expand All @@ -1052,6 +1031,11 @@
enabled: false
failed_when: false

- name: remove ceph-crash systemd unit file
file:
path: /etc/systemd/system/ceph-crash@.service
state: absent

- name: update the placement of ceph-crash hosts
command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} orch apply crash --placement='label:ceph'"
run_once: true
Expand All @@ -1060,6 +1044,7 @@
environment:
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'


- name: redeploy alertmanager/grafana/prometheus daemons
hosts: "{{ grafana_server_group_name|default('grafana-server') }}"
serial: 1
Expand Down
39 changes: 30 additions & 9 deletions infrastructure-playbooks/purge-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@

- name: remove ceph mds service
file:
path: /etc/systemd/system/ceph-mds@.service
path: /etc/systemd/system/ceph-mds{{ item }}
state: absent
loop:
- '@.service'
- '.target'


- name: purge ceph mgr cluster
Expand All @@ -267,9 +270,11 @@

- name: remove ceph mgr service
file:
path: /etc/systemd/system/ceph-mgr@.service
path: /etc/systemd/system/ceph-mgr{{ item }}
state: absent

loop:
- '@.service'
- '.target'

- name: purge rgwloadbalancer cluster
hosts: rgwloadbalancers
Expand Down Expand Up @@ -304,6 +309,14 @@
failed_when: false
with_items: "{{ rgw_instances }}"

- name: remove ceph rgw service
file:
path: /etc/systemd/system/ceph-radosgw{{ item }}
state: absent
loop:
- '@.service'
- '.target'


- name: purge ceph rbd-mirror cluster
hosts: rbdmirrors
Expand All @@ -317,6 +330,14 @@
enabled: no
failed_when: false

- name: remove ceph rbd-mirror service
file:
path: /etc/systemd/system/ceph-rbd-mirror{{ item }}
state: absent
loop:
- '@.service'
- '.target'


- name: purge ceph osd cluster
vars:
Expand Down Expand Up @@ -599,9 +620,11 @@

- name: remove ceph osd service
file:
path: /etc/systemd/system/ceph-osd@.service
path: /etc/systemd/system/ceph-osd{{ item }}
state: absent
when: containerized_deployment | bool
loop:
- '@.service'
- '.target'

- name: purge ceph mon cluster
hosts: mons
Expand Down Expand Up @@ -633,11 +656,9 @@

- name: remove ceph mon and mgr service
file:
path: "/etc/systemd/system/ceph-{{ item }}@.service"
path: "/etc/systemd/system/ceph-{{ item.0 }}{{ item.1 }}"
state: absent
with_items:
- mon
- mgr
loop: "{{ ['mon', 'mgr'] | product(['@.service', '.target']) | list }}"


- name: purge ceph-crash daemons
Expand Down
5 changes: 5 additions & 0 deletions roles/ceph-container-common/files/ceph.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=ceph target allowing to start/stop all ceph*@.service instances at once

[Install]
WantedBy=multi-user.target
11 changes: 11 additions & 0 deletions roles/ceph-container-common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
- name: generate systemd ceph-mon target file
copy:
src: ceph.target
dest: /etc/systemd/system/ceph.target

- name: enable ceph.target
service:
name: ceph.target
enabled: yes
daemon_reload: yes

- name: include prerequisites.yml
include_tasks: prerequisites.yml

Expand Down
2 changes: 1 addition & 1 deletion roles/ceph-crash/templates/ceph-crash.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ TimeoutStartSec=120
TimeoutStopSec=10

[Install]
WantedBy=multi-user.target
WantedBy=ceph.target
9 changes: 9 additions & 0 deletions roles/ceph-mds/files/ceph-mds.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-mds@.service instances at once
PartOf=ceph.target
After=ceph-mon.target
Before=ceph.target
Wants=ceph.target ceph-mon.target

[Install]
WantedBy=multi-user.target ceph.target
7 changes: 7 additions & 0 deletions roles/ceph-mds/tasks/containerized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
- name: include_tasks systemd.yml
include_tasks: systemd.yml

- name: enable ceph-mds.target
service:
name: ceph-mds.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool

- name: systemd start mds container
systemd:
name: ceph-mds@{{ ansible_facts['hostname'] }}
Expand Down
6 changes: 6 additions & 0 deletions roles/ceph-mds/tasks/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
group: "root"
mode: "0644"
notify: restart ceph mdss

- name: generate systemd ceph-mds target file
copy:
src: ceph-mds.target
dest: /etc/systemd/system/ceph-mds.target
when: containerized_deployment | bool
3 changes: 2 additions & 1 deletion roles/ceph-mds/templates/ceph-mds.service.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[Unit]
Description=Ceph MDS
PartOf=ceph-mds.target
{% if container_binary == 'docker' %}
After=docker.service
Requires=docker.service
Expand Down Expand Up @@ -53,4 +54,4 @@ PIDFile=/%t/%n-pid
{% endif %}

[Install]
WantedBy=multi-user.target
WantedBy=ceph.target
Loading

0 comments on commit afe442a

Please sign in to comment.