3 # This delivers the ceph-storage upgrade script to be invoked as part of the tripleo
4 # major upgrade workflow.
9 UPGRADE_SCRIPT=/root/tripleo_upgrade_node.sh
11 cat > $UPGRADE_SCRIPT << 'ENDOFCAT'
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
18 echo INFO: starting $(basename "$0")
21 if ! pidof ceph-osd &> /dev/null; then
22 echo INFO: ceph-osd is not running, skipping
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
33 OSD_PIDS=$(pidof ceph-osd)
34 OSD_IDS=$(ls /var/lib/ceph/osd | awk 'BEGIN { FS = "-" } ; { print $2 }')
36 # "so that mirrors aren't rebalanced as if the OSD died" - gfidente / leseb
38 ceph osd set norebalance
39 ceph osd set nodeep-scrub
42 # Stop daemon using Hammer sysvinit script
43 for OSD_ID in $OSD_IDS; do
44 service ceph stop osd.${OSD_ID}
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
52 # Special-case OVS for https://bugs.launchpad.net/tripleo/+bug/1635205
53 if [[ -n $(rpm -q --scripts openvswitch | awk '/postuninstall/,/*/' | grep "systemctl.*try-restart") ]]; then
54 echo "Manual upgrade of openvswitch - restart in postun detected"
55 mkdir OVS_UPGRADE || true
57 echo "Attempting to downloading latest openvswitch with yumdownloader"
58 yumdownloader --resolve openvswitch
59 echo "Updating openvswitch with nopostun option"
60 rpm -U --replacepkgs --nopostun ./*.rpm
63 echo "Skipping manual upgrade of openvswitch - no restart in postun detected"
66 # Update (Ceph to Jewel)
67 yum -y install python-zaqarclient # needed for os-collect-config
70 # Restart/Exit if not on Jewel, only in that case we need the changes
71 UPDATED_VERSION=$(ceph --version | awk '{print $3}')
72 if [[ "$UPDATED_VERSION" =~ ^0\.94.* ]]; then
73 echo WARNING: Ceph was not upgraded, restarting daemon
74 for OSD_ID in $OSD_IDS; do
75 service ceph start osd.${OSD_ID}
77 elif [[ "$UPDATED_VERSION" =~ ^10\.2.* ]]; then
78 # RPM could own some of these but we can't take risks on the pre-existing files
79 for d in /var/lib/ceph/osd /var/log/ceph /var/run/ceph /etc/ceph; do
80 chown -L -R ceph:ceph $d || echo WARNING: chown of $d failed
83 # Replay udev events with newer rules
84 udevadm trigger && udevadm settle
86 # If on ext4, we need to enforce lower values for name and namespace len
87 # or ceph-osd will refuse to start, see: http://tracker.ceph.com/issues/16187
88 for OSD_ID in $OSD_IDS; do
89 OSD_FS=$(findmnt -n -o FSTYPE -T /var/lib/ceph/osd/ceph-${OSD_ID})
90 if [ ${OSD_FS} = ext4 ]; then
91 crudini --set /etc/ceph/ceph.conf global osd_max_object_name_len 256
92 crudini --set /etc/ceph/ceph.conf global osd_max_object_namespace_len 64
97 systemctl enable ceph-osd.target
98 for OSD_ID in $OSD_IDS; do
99 systemctl enable ceph-osd@${OSD_ID}
100 systemctl start ceph-osd@${OSD_ID}
103 echo INFO: Ceph was upgraded to Jewel
105 echo ERROR: Ceph was upgraded to an unknown release, daemon is stopped, need manual intervention
110 ceph osd unset norebalance
111 ceph osd unset nodeep-scrub
112 ceph osd unset noscrub
115 # ensure the permissions are OK
116 chmod 0755 $UPGRADE_SCRIPT