Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Not entirely sure what the root cause is, but my workaround is to trigger a udev event when the symlink is not found. This is my userdata script. Pass it through str_replace like this:

heat resource

  volume_provisioner:
    type: OS::Heat::SoftwareConfig
    properties:
      group: ungrouped
      config:
        str_replace:
          template: { get_file: ../user-data/format-cinder-volume.sh }
          params:
            $volume_id: { get_resource: data_volume }
            $volume_name: { get_attr: [data_volume, display_name] }
            $volume_mount: { get_param: data_drive_path }

format-cinder-vollume.sh

#!/bin/bash -x

# volume UUID
VOLUME_ID="$volume_id"
# nova passes truncated volume ID
VOLUME_DEV="/dev/disk/by-id/virtio-$(echo $VOLUME_ID | cut -c -20)"
# will get truncated in filesystem label
VOLUME_LABEL="$volume_name"
# path to mount data volume at
MOUNT_POINT="$volume_mount"
FILESYSTEM_TYPE="$volume_fileystem"
FILESYSTEM_TYPE=${FILESYSTEM_TYPE:-xfs}

if [[ ! -L "$VOLUME_DEV" ]]; then
    echo "triggering udev to create by-id symlink"
    /sbin/udevadm trigger \
        --action=change \
        --type=devices \
        --subsystem-match=block \
        --verbose
fi

if [[ ! -L "$VOLUME_DEV" ]]; then
    echo "volume device $VOLUME_DEV not found"
    exit 1
fi

# use Cinder volume ID as filesystem UUID and as much volume name that will fit in label
if [ "$FILESYSTEM_TYPE" == "ext4" ]; then
    mkfs.ext4 "$VOLUME_DEV" -U "$VOLUME_ID" -L "$(echo $VOLUME_LABEL | cut -c -16)"
elif [ "$FILESYSTEM_TYPE" == "xfs" ]; then
    mkfs.xfs "$VOLUME_DEV" -m "uuid=$VOLUME_ID" -L "$(echo $VOLUME_LABEL | cut -c -12)"
fi

if [ -n "$MOUNT_POINT" ]; then
  mkdir -p "$MOUNT_POINT"
  echo "UUID=${VOLUME_ID} ${MOUNT_POINT} ${FILESYSTEM_TYPE} defaults 0 1" >> /etc/fstab
  mount "$MOUNT_POINT"
fi