Skip to content

Commit

Permalink
infra: use dedicated variables for balancer status
Browse files Browse the repository at this point in the history
The balancer status is registered during the cephadm-adopt, rolling_update
and swith2container playbooks. But it is also used in the ceph-handler role
which is included in those playbooks too.
Even if the ceph-handler tasks are skipped for rolling_update and
switch2container, the balancer_status variable is erased with the skip task
result.

play1:
  register: balancer_status
play2:
  register: balancer_status <-- skipped
play3:
  when: (balancer_status.stdout | from_json)['active'] | bool

This leads to issue like:

The conditional check '(balancer_status.stdout | from_json)['active'] | bool'
failed. The error was: Unexpected templating type error occurred on
({% if (balancer_status.stdout | from_json)['active'] | bool %} True
{% else %} False {% endif %}): expected string or buffer.

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

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 3866616)
  • Loading branch information
dsavineau committed Aug 4, 2021
1 parent 1044940 commit 03ed9e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions infrastructure-playbooks/rolling_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@

- name: get balancer module status
command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
register: balancer_status
register: balancer_status_update
changed_when: false
check_mode: false

Expand All @@ -431,7 +431,7 @@
- name: disable balancer
command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
changed_when: false
when: (balancer_status.stdout | from_json)['active'] | bool
when: (balancer_status_update.stdout | from_json)['active'] | bool

- name: disable pg autoscale on pools
command: "{{ ceph_cmd }} --cluster {{ cluster }} osd pool set {{ item.name }} pg_autoscale_mode off"
Expand Down Expand Up @@ -569,7 +569,7 @@
- name: re-enable balancer
command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer on"
changed_when: false
when: (balancer_status.stdout | from_json)['active'] | bool
when: (balancer_status_update.stdout | from_json)['active'] | bool

- name: set_fact container_exec_cmd_osd
set_fact:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@

- name: get balancer module status
command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
register: balancer_status
register: balancer_status_switch
changed_when: false
check_mode: false

Expand All @@ -234,7 +234,7 @@
- name: disable balancer
command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
changed_when: false
when: (balancer_status.stdout | from_json)['active'] | bool
when: (balancer_status_switch.stdout | from_json)['active'] | bool

- name: disable pg autoscale on pools
command: "{{ ceph_cmd }} --cluster {{ cluster }} osd pool set {{ item.name }} pg_autoscale_mode off"
Expand Down Expand Up @@ -423,7 +423,7 @@
- name: re-enable balancer
command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer on"
changed_when: false
when: (balancer_status.stdout | from_json)['active'] | bool
when: (balancer_status_switch.stdout | from_json)['active'] | bool


- name: switching from non-containerized to containerized ceph mds
Expand Down

0 comments on commit 03ed9e1

Please sign in to comment.