[glance-k8s] enable image-conversion on import

Allow configuring the images to be imported and converted to row.
Disabled by default.

Change-Id: If69f7c0260f45038a58ed0695f71e5559730fc32
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
This commit is contained in:
Guillaume Boutry 2024-07-31 17:18:04 +02:00
parent bd0990f2ad
commit f22c3d06cb
No known key found for this signature in database
GPG Key ID: E95E3326872E55DE
4 changed files with 32 additions and 1 deletions

View File

@ -252,3 +252,10 @@ options:
. .
WARNING: this value should only be increased after careful consideration WARNING: this value should only be increased after careful consideration
and must be set to a value under 8EB (9223372036854775808 bytes). and must be set to a value under 8EB (9223372036854775808 bytes).
image-conversion:
type: boolean
default: False
description: |
Enable conversion of all images to raw format during image import.
This only works on imported images (for example using 'openstack image create --import').
Does not work on regular image uploads (like 'openstack image create')

View File

@ -21,6 +21,7 @@
This charm provide Glance services as part of an OpenStack deployment This charm provide Glance services as part of an OpenStack deployment
""" """
import json
import logging import logging
import re import re
from typing import ( from typing import (
@ -216,6 +217,11 @@ class GlanceConfigContext(sunbeam_ctxts.ConfigContext):
"image_size_cap": bytes_from_string( "image_size_cap": bytes_from_string(
self.charm.config["image-size-cap"] self.charm.config["image-size-cap"]
), ),
"image_import_plugins": json.dumps(
["image_conversion"]
if self.charm.config["image-conversion"]
else []
),
} }
@ -327,6 +333,12 @@ class GlanceOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
self.service_group, self.service_group,
0o640, 0o640,
), ),
sunbeam_core.ContainerConfigFile(
"/etc/glance/glance-image-import.conf",
self.service_user,
self.service_group,
0o640,
),
sunbeam_core.ContainerConfigFile( sunbeam_core.ContainerConfigFile(
"/usr/local/share/ca-certificates/ca-bundle.pem", "/usr/local/share/ca-certificates/ca-bundle.pem",
self.service_user, self.service_user,

View File

@ -49,4 +49,3 @@ rbd_store_ceph_conf = /etc/ceph/ceph.conf
flavor = keystone flavor = keystone
{% include "parts/section-oslo-messaging-rabbit" %} {% include "parts/section-oslo-messaging-rabbit" %}

View File

@ -0,0 +1,13 @@
###############################################################################
# [ WARNING ]
# glance configuration file maintained by Juju
# local changes may be overwritten.
###############################################################################
[image_import_opts]
image_import_plugins = {{ glance_config.image_import_plugins }}
{% if "image_conversion" in glance_config.image_import_plugins -%}
[image_conversion]
output_format = raw
{% endif %}