diff --git a/charms/glance-k8s/charmcraft.yaml b/charms/glance-k8s/charmcraft.yaml index bc2d791b..02fb032c 100644 --- a/charms/glance-k8s/charmcraft.yaml +++ b/charms/glance-k8s/charmcraft.yaml @@ -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). diff --git a/charms/glance-k8s/src/charm.py b/charms/glance-k8s/src/charm.py index 25d179e7..cfca5d46 100755 --- a/charms/glance-k8s/src/charm.py +++ b/charms/glance-k8s/src/charm.py @@ -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: