Merge "[glance-k8s] change defaults for image-size-cap" into main
This commit is contained in:
commit
8fcfaf96b4
@ -264,12 +264,12 @@ config:
|
|||||||
description: Enable notifications to send to telemetry.
|
description: Enable notifications to send to telemetry.
|
||||||
image-size-cap:
|
image-size-cap:
|
||||||
type: string
|
type: string
|
||||||
default: 1GB
|
|
||||||
description: |
|
description: |
|
||||||
Maximum size of image a user can upload. Defaults to 5GB
|
Maximum size of image a user can upload. Defaults to 5GB
|
||||||
(5368709120 bytes). Example values: 500M, 500MB, 5G, 5TB.
|
(5368709120 bytes). Example values: 500M, 500MB, 5G, 5TB.
|
||||||
Valid units: K, KB, M, MB, G, GB, T, TB, P, PB. If no units provided,
|
Valid units: K, KB, M, MB, G, GB, T, TB, P, PB. If no units provided,
|
||||||
bytes are assumed.
|
bytes are assumed.
|
||||||
|
Defaults to 30G for ceph storage and 1G for local storage.
|
||||||
.
|
.
|
||||||
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).
|
||||||
|
@ -215,10 +215,16 @@ class GlanceConfigContext(sunbeam_ctxts.ConfigContext):
|
|||||||
|
|
||||||
def context(self) -> dict:
|
def context(self) -> dict:
|
||||||
"""Context used when rendering templates."""
|
"""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 {
|
return {
|
||||||
"image_size_cap": bytes_from_string(
|
"image_size_cap": bytes_from_string(image_size_cap),
|
||||||
self.charm.config["image-size-cap"]
|
|
||||||
),
|
|
||||||
"image_import_plugins": json.dumps(
|
"image_import_plugins": json.dumps(
|
||||||
["image_conversion"]
|
["image_conversion"]
|
||||||
if self.charm.config["image-conversion"]
|
if self.charm.config["image-conversion"]
|
||||||
@ -542,6 +548,9 @@ class GlanceOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
|
|||||||
|
|
||||||
def _validate_image_size_cap(self):
|
def _validate_image_size_cap(self):
|
||||||
"""Check image size is valid."""
|
"""Check image size is valid."""
|
||||||
|
if self.config.get("image-size-cap") is None:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image_cap_size = bytes_from_string(self.config["image-size-cap"])
|
image_cap_size = bytes_from_string(self.config["image-size-cap"])
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user