Kolla provides production-ready containers and deployment tools for operating OpenStack clouds
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extend_start.sh 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. if [[ ! -d "/var/log/kolla/ceph" ]]; then
  3. mkdir -p /var/log/kolla/ceph
  4. fi
  5. if [[ $(stat -c %a /var/log/kolla/ceph) != "755" ]]; then
  6. chmod 755 /var/log/kolla/ceph
  7. fi
  8. # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
  9. # of the KOLLA_BOOTSTRAP variable being set, including empty.
  10. if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
  11. # NOTE(SamYaple): Static gpt partcodes
  12. CEPH_JOURNAL_TYPE_CODE="45B0969E-9B03-4F30-B4C6-B4B80CEFF106"
  13. CEPH_OSD_TYPE_CODE="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
  14. # Wait for ceph quorum before proceeding
  15. ceph quorum_status
  16. if [[ "${USE_EXTERNAL_JOURNAL}" == "False" ]]; then
  17. # Formatting disk for ceph
  18. sgdisk --zap-all -- "${OSD_DEV}"
  19. sgdisk --new=2:1M:5G -- "${JOURNAL_DEV}"
  20. sgdisk --largest-new=1 -- "${OSD_DEV}"
  21. # NOTE(SamYaple): This command may throw errors that we can safely ignore
  22. partprobe || true
  23. fi
  24. OSD_ID=$(ceph osd create)
  25. OSD_DIR="/var/lib/ceph/osd/ceph-${OSD_ID}"
  26. mkdir -p "${OSD_DIR}"
  27. if [[ "${OSD_FILESYSTEM}" == "btrfs" ]]; then
  28. mkfs.btrfs -f "${OSD_PARTITION}"
  29. elif [[ "${OSD_FILESYSTEM}" == "ext4" ]]; then
  30. mkfs.ext4 "${OSD_PARTITION}"
  31. else
  32. mkfs.xfs -f "${OSD_PARTITION}"
  33. fi
  34. mount "${OSD_PARTITION}" "${OSD_DIR}"
  35. # This will through an error about no key existing. That is normal. It then
  36. # creates the key in the next step.
  37. ceph-osd -i "${OSD_ID}" --mkfs --osd-journal="${JOURNAL_PARTITION}" --mkkey
  38. ceph auth add "osd.${OSD_ID}" osd 'allow *' mon 'allow profile osd' -i "${OSD_DIR}/keyring"
  39. umount "${OSD_PARTITION}"
  40. if [[ "${!CEPH_CACHE[@]}" ]]; then
  41. CEPH_ROOT_NAME=cache
  42. fi
  43. if [[ "${OSD_INITIAL_WEIGHT}" == "auto" ]]; then
  44. OSD_INITIAL_WEIGHT=$(parted --script ${OSD_PARTITION} unit TB print | awk 'match($0, /^Disk.* (.*)TB/, a){printf("%.2f", a[1])}')
  45. fi
  46. # These commands only need to be run once per host but are safe to run
  47. # repeatedly. This can be improved later or if any problems arise.
  48. ceph osd crush add-bucket "${HOSTNAME}${CEPH_ROOT_NAME:+-${CEPH_ROOT_NAME}}" host
  49. ceph osd crush move "${HOSTNAME}${CEPH_ROOT_NAME:+-${CEPH_ROOT_NAME}}" root=${CEPH_ROOT_NAME:-default}
  50. # Adding osd to crush map
  51. ceph osd crush add "${OSD_ID}" "${OSD_INITIAL_WEIGHT}" host="${HOSTNAME}${CEPH_ROOT_NAME:+-${CEPH_ROOT_NAME}}"
  52. # Setting partition name based on ${OSD_ID}
  53. sgdisk "--change-name=${OSD_PARTITION_NUM}:KOLLA_CEPH_DATA_${OSD_ID}" "--typecode=${OSD_PARTITION_NUM}:${CEPH_OSD_TYPE_CODE}" -- "${OSD_DEV}"
  54. sgdisk "--change-name=${JOURNAL_PARTITION_NUM}:KOLLA_CEPH_DATA_${OSD_ID}_J" "--typecode=${JOURNAL_PARTITION_NUM}:${CEPH_JOURNAL_TYPE_CODE}" -- "${JOURNAL_DEV}"
  55. exit 0
  56. fi
  57. OSD_DIR="/var/lib/ceph/osd/ceph-${OSD_ID}"
  58. ARGS="-i ${OSD_ID} --osd-journal ${JOURNAL_PARTITION} -k ${OSD_DIR}/keyring"