From 0ea991e4d2c633ec97c1c9e9b7c96ee3b053a446 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= <radoslaw.piliszek@gmail.com>
Date: Tue, 18 Jun 2019 11:31:51 +0200
Subject: [PATCH] Make Ceph upgrade check Ceph release to avoid EPERM
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Since we have different upgrade paths, we must use the actually
installed Ceph release name when doing require-osd-release

Closes-Bug: #1832989

Change-Id: I6aaa4b4ac0fb739f7ad885c13f55b6db969996a2
Signed-off-by: Radosław Piliszek <radoslaw.piliszek@gmail.com>
---
 ansible/roles/ceph/tasks/upgrade.yml | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/ansible/roles/ceph/tasks/upgrade.yml b/ansible/roles/ceph/tasks/upgrade.yml
index 61ec87db35..0669732510 100644
--- a/ansible/roles/ceph/tasks/upgrade.yml
+++ b/ansible/roles/ceph/tasks/upgrade.yml
@@ -35,11 +35,17 @@
     - enable_ceph_nfs | bool
     - inventory_hostname in groups['ceph-nfs']
 
-# NOTE(chenxing): Disallowing pre-luminous OSDs and enabling all
-# new Luminous-only functionality
-- name: Enabling all new Luminous-only functionality
+- name: Check final release (as running on MONs)
   become: true
-  command: docker exec ceph_mon ceph osd require-osd-release luminous
+  shell: docker exec ceph_mon ceph version | cut -d' ' -f5
+  changed_when: false
+  register: ceph_release_command
   delegate_to: "{{ groups['ceph-mon'][0] }}"
-  changed_when: False
-  run_once: True
+  run_once: true
+
+- name: Finalize the upgrade by disallowing older OSDs
+  become: true
+  command: docker exec ceph_mon ceph osd require-osd-release {{ ceph_release_command.stdout }}
+  changed_when: false
+  delegate_to: "{{ groups['ceph-mon'][0] }}"
+  run_once: true