From 48ab9fa95a43d35b7bd21b46c26e2d07e2b42b55 Mon Sep 17 00:00:00 2001 From: Carlos Goncalves Date: Fri, 22 Jun 2018 18:24:31 -0400 Subject: [PATCH] Option to upload Octavia amphora img in RAW format When deploying an overcloud with Octavia, the amphora image is uploaded to Glance as QCOW2. When using the RBD backend for Glance and Nova, this causes the image to be converted to RAW on each deployment. With slower storage, this leads to load balancer creation to fail with a compute timeout exception from Octavia. This patch adds an option to allow amphora image to be automatically uploaded to Glance in raw format. Partial-Bug: #1778303 Change-Id: I698ed96881756bb547f5338b147b0c795103acb5 (cherry picked from commit 73631a23ee3bc1abeaad30590dde3a62c3c387fb) --- playbooks/octavia-files.yaml | 1 + playbooks/roles/common/defaults/main.yml | 1 + .../octavia-undercloud/tasks/image_mgmt.yml | 31 +++++++++++++++++-- workbooks/octavia_post.yaml | 2 ++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/playbooks/octavia-files.yaml b/playbooks/octavia-files.yaml index 3f8096c26..70408bc94 100644 --- a/playbooks/octavia-files.yaml +++ b/playbooks/octavia-files.yaml @@ -6,6 +6,7 @@ amp_ssh_key_name: "{{ amp_ssh_key_name }}" amp_ssh_key_path: "{{ amp_ssh_key_path }}" amp_ssh_key_data: "{{ amp_ssh_key_data }}" + amp_to_raw: "{{ amp_to_raw | bool }}" auth_username: "{{ auth_username }}" auth_pasword: "{{ auth_password }}" auth_project_name: "{{ auth_project_name }}" diff --git a/playbooks/roles/common/defaults/main.yml b/playbooks/roles/common/defaults/main.yml index 314835802..3b9d778d1 100644 --- a/playbooks/roles/common/defaults/main.yml +++ b/playbooks/roles/common/defaults/main.yml @@ -4,6 +4,7 @@ amp_image_filename: "" amp_image_tag: "amphora-image" amp_ssh_key_name: "octavia-ssh-key" amp_ssh_key_path: "" +amp_to_raw: False auth_username: "octavia" auth_project_name: "service" lb_mgmt_net_name: "lb-mgmt-net" diff --git a/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml b/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml index bd16c96e1..a73073f57 100644 --- a/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml +++ b/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml @@ -48,10 +48,37 @@ upload_image: true when: current_md5 is not defined or replace_image + - block: + - name: create temporary directory + tempfile: + state: directory + register: amp_tmp_dir + + - name: set RAW file name + set_fact: + raw_filename: "{{ amp_tmp_dir.path }}/{{ image_filename|splitext|first|basename }}.img" + + - name: convert image from qcow2 to raw + shell: | + qemu-img convert -f qcow2 -O raw {{ image_filename }} {{ raw_filename }} + + - name: setting amphora format to raw + set_fact: + raw_format: raw + when: amp_to_raw + - name: upload image to glance shell: | - openstack image create --disk-format qcow2 --container-format bare --tag {{ amp_image_tag }} \ - --file {{ image_filename }} {{ amphora_image }} + openstack image create --disk-format {{ raw_format|default('qcow2') }} \ + --container-format bare --tag {{ amp_image_tag }} \ + --file {{ raw_filename|default(image_filename) }} \ + {{ amphora_image }} register: image_result changed_when: "image_result.stdout != ''" when: image_file_result.stat.exists and upload_image is defined + + - name: delete converted raw image + file: + path: "{{ amp_tmp_dir.path }}" + state: absent + when: amp_to_raw diff --git a/workbooks/octavia_post.yaml b/workbooks/octavia_post.yaml index 56a6d2ccb..6f69a6f9b 100644 --- a/workbooks/octavia_post.yaml +++ b/workbooks/octavia_post.yaml @@ -14,6 +14,7 @@ workflows: - amp_ssh_key_name - amp_ssh_key_path - amp_ssh_key_data + - amp_to_raw - auth_username - auth_password - auth_project_name @@ -103,6 +104,7 @@ workflows: amp_ssh_key_name: <% $.amp_ssh_key_name %> amp_ssh_key_path: <% $.amp_ssh_key_path %> amp_ssh_key_data: <% $.amp_ssh_key_data %> + amp_to_raw: <% $.amp_to_raw %> auth_username: <% $.auth_username %> auth_password: <% $.auth_password %> auth_project_name: <% $.auth_project_name %>