Merge "[glance-k8s] change defaults for image-size-cap" into main

This commit is contained in:
Zuul 2024-12-10 07:24:22 +00:00 committed by Gerrit Code Review
commit 8fcfaf96b4
2 changed files with 13 additions and 4 deletions

View File

@ -264,12 +264,12 @@ config:
description: Enable notifications to send to telemetry.
image-size-cap:
type: string
default: 1GB
description: |
Maximum size of image a user can upload. Defaults to 5GB
(5368709120 bytes). Example values: 500M, 500MB, 5G, 5TB.
Valid units: K, KB, M, MB, G, GB, T, TB, P, PB. If no units provided,
bytes are assumed.
Defaults to 30G for ceph storage and 1G for local storage.
.
WARNING: this value should only be increased after careful consideration
and must be set to a value under 8EB (9223372036854775808 bytes).

View File

@ -215,10 +215,16 @@ class GlanceConfigContext(sunbeam_ctxts.ConfigContext):
def context(self) -> dict:
"""Context used when rendering templates."""
image_size_cap = self.charm.config.get("image-size-cap")
if not image_size_cap:
# Defaults to 30G for ceph storage and 1G for local storage
if self.charm.has_ceph_relation():
image_size_cap = "30G"
else:
image_size_cap = "1G"
return {
"image_size_cap": bytes_from_string(
self.charm.config["image-size-cap"]
),
"image_size_cap": bytes_from_string(image_size_cap),
"image_import_plugins": json.dumps(
["image_conversion"]
if self.charm.config["image-conversion"]
@ -542,6 +548,9 @@ class GlanceOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
def _validate_image_size_cap(self):
"""Check image size is valid."""
if self.config.get("image-size-cap") is None:
return
try:
image_cap_size = bytes_from_string(self.config["image-size-cap"])
except ValueError as e: