Fixes missing provider mappings for OpenDaylight
[apex-tripleo-heat-templates.git] / extraconfig / tasks / major_upgrade_ceph_storage.sh
1 #!/bin/bash
2 #
3 # This delivers the ceph-storage upgrade script to be invoked as part of the tripleo
4 # major upgrade workflow.
5 #
6 set -eu
7 set -o pipefail
8
9 UPGRADE_SCRIPT=/root/tripleo_upgrade_node.sh
10
11 cat > $UPGRADE_SCRIPT << 'ENDOFCAT'
12 #!/bin/bash
13 ### DO NOT MODIFY THIS FILE
14 ### This file is automatically delivered to the ceph-storage nodes as part of the
15 ### tripleo upgrades workflow
16 set -eu
17
18 echo INFO: starting $(basename "$0")
19
20 # Exit if not running
21 if ! pidof ceph-osd &> /dev/null; then
22     echo INFO: ceph-osd is not running, skipping
23     exit 0
24 fi
25
26 # Exit if not Hammer
27 INSTALLED_VERSION=$(ceph --version | awk '{print $3}')
28 if ! [[ "$INSTALLED_VERSION" =~ ^0\.94.* ]]; then
29     echo INFO: version of Ceph installed is not 0.94, skipping
30     exit 0
31 fi
32
33 OSD_PIDS=$(pidof ceph-osd)
34 OSD_IDS=$(ls /var/lib/ceph/osd | awk 'BEGIN { FS = "-" } ; { print $2 }')
35
36 # "so that mirrors aren't rebalanced as if the OSD died" - gfidente / leseb
37 ceph osd set noout
38 ceph osd set norebalance
39 ceph osd set nodeep-scrub
40 ceph osd set noscrub
41
42 # Stop daemon using Hammer sysvinit script
43 for OSD_ID in $OSD_IDS; do
44     service ceph stop osd.${OSD_ID}
45 done
46
47 # Nice guy will return non-0 only when all failed
48 timeout 60 bash -c "while kill -0 ${OSD_PIDS} 2> /dev/null; do
49   sleep 2;
50 done"
51
52 # Update (Ceph to Jewel)
53 yum -y install python-zaqarclient  # needed for os-collect-config
54 yum -y update
55
56 # Restart/Exit if not on Jewel, only in that case we need the changes
57 UPDATED_VERSION=$(ceph --version | awk '{print $3}')
58 if [[ "$UPDATED_VERSION" =~ ^0\.94.* ]]; then
59     echo WARNING: Ceph was not upgraded, restarting daemon
60     for OSD_ID in $OSD_IDS; do
61         service ceph start osd.${OSD_ID}
62     done
63 elif [[ "$UPDATED_VERSION" =~ ^10\.2.* ]]; then
64     # RPM could own some of these but we can't take risks on the pre-existing files
65     for d in /var/lib/ceph/osd /var/log/ceph /var/run/ceph /etc/ceph; do
66         chown -L -R ceph:ceph $d || echo WARNING: chown of $d failed
67     done
68
69     # Replay udev events with newer rules
70     udevadm trigger && udevadm settle
71
72     # If on ext4, we need to enforce lower values for name and namespace len
73     # or ceph-osd will refuse to start, see: http://tracker.ceph.com/issues/16187
74     for OSD_ID in $OSD_IDS; do
75       OSD_FS=$(findmnt -n -o FSTYPE -T /var/lib/ceph/osd/ceph-${OSD_ID})
76       if [ ${OSD_FS} = ext4 ]; then
77         crudini --set /etc/ceph/ceph.conf global osd_max_object_name_len 256
78         crudini --set /etc/ceph/ceph.conf global osd_max_object_namespace_len 64
79       fi
80     done
81
82     # Enable systemd unit
83     systemctl enable ceph-osd.target
84     for OSD_ID in $OSD_IDS; do
85         systemctl enable ceph-osd@${OSD_ID}
86         systemctl start ceph-osd@${OSD_ID}
87     done
88
89     echo INFO: Ceph was upgraded to Jewel
90 else
91     echo ERROR: Ceph was upgraded to an unknown release, daemon is stopped, need manual intervention
92     exit 1
93 fi
94
95 ceph osd unset noout
96 ceph osd unset norebalance
97 ceph osd unset nodeep-scrub
98 ceph osd unset noscrub
99 ENDOFCAT
100
101 # ensure the permissions are OK
102 chmod 0755 $UPGRADE_SCRIPT