Enable sparse image upload

When you use Red Hat Ceph Storage RADOS Block Device (RBD) as the storage back end for the Image service (glance), you can use sparse image upload to reduce network traffic and storage space. With a sparse image file, the Image service can use offsets instead of writing null byte sequences.

Before you begin

  • Your Red Hat OpenStack Services on OpenShift (RHOSO) deployment uses Ceph Storage RBD as the storage back end for the Image service.

Procedure

  1. Open your OpenStackControlPlane CR file, openstack_control_plane.yaml, and add the following parameters to the glance template. Enable sparse image upload by setting the rbd_thin_provisioning parameter to True:
    apiVersion: core.openstack.org/v1beta1
    kind: OpenStackControlPlane
    spec:
        ...
      glance:
        template:
          databaseInstance: openstack
          databaseUser: glance
          customServiceConfig: |
            [DEFAULT]
            enabled_backends = <backend_name>:rbd
            enabled_import_methods=[web-download]
            [glance_store]
            default_backend = <backend_name>
            [<backend_name>]
            rbd_store_ceph_conf = /etc/ceph/ceph.conf
            store_description = "RBD backend"
            rbd_store_pool = images
            rbd_store_user = openstack
            rbd_thin_provisioning = True
      ...
    • Replace <backend_name> with the name of the default back end.
  2. Update the control plane:
    $ oc apply -f openstack_control_plane.yaml -n openstack
  3. Wait until RHOCP creates the resources related to the OpenStackControlPlane CR. Run the following command to check the status:
    $ oc get openstackcontrolplane -n openstack

    The OpenStackControlPlane resources are created when the status is "Setup complete".

    Tip
    Append the -w option to the end of the get command to track deployment progress.

Results

You can import an image and check its size to verify sparse image upload.

  1. Download the image file locally:
    $ wget <file_location>/<file_name>
    • Replace <file_location> with the location of the file.
    • Replace <file_name> with the name of the file.

      For example:

      $ wget https://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-1508.qcow2
  2. Check the disk size and the virtual size of the image to be uploaded:
    $ qemu-img info <file_name>

    For example:

    $ qemu-img info CentOS-6-x86_64-GenericCloud-1508.qcow2
    
    image: CentOS-6-x86_64-GenericCloud-1508.qcow2
    file format: qcow2
    virtual size: 8 GiB (8589934592 bytes)
    disk size: 1.09 GiB
    cluster_size: 65536
    Format specific information:
    compat: 0.10
    refcount bits: 1
  3. Import the image:
    $ glance image-create-via-import --disk-format qcow2 --container-format bare --name centos_1 --file <file_name>
  4. Record the image ID. It is required in a subsequent step.
  5. Verify that the image is imported and in an active state:
    • Access the remote shell for the OpenStackClient pod from your workstation:
      $ oc rsh -n openstack openstackclient
    • View the image:
      $ openstack image show <image_id>
    • Exit the openstackclient pod:
      $ exit
  6. From a Ceph Storage node, verify that the size of the image is less than the virtual size from the output of step 2:
    $ sudo rbd -p images diff <image_id> | awk '{ SUM += $2 } END { print SUM/1024/1024/1024 " GB" }'
    
    1.03906 GB