Merge "Add per-store weight config element"

This commit is contained in:
Zuul 2023-06-21 14:20:58 +00:00 committed by Gerrit Code Review
commit f627d69f04
2 changed files with 24 additions and 1 deletions

View File

@ -39,7 +39,15 @@ This option will be used to provide a constructive information about
the store backend to end users. Using /v2/stores-info call user can
seek more information on all available backends.
"""))
""")),
cfg.IntOpt('weight',
help=_("""
This option is used to define a relative weight for this store over
any others that are configured. The actual value of the weight is meaningless
and only serves to provide a "sort order" compared to others. Any stores
with the same weight will be treated as equivalent.
"""),
default=0),
]
@ -79,6 +87,15 @@ class Store(capabilities.StoreCapability):
def url_prefix(self):
return self._url_prefix
@property
def weight(self):
if self.backend_group is None:
# NOTE(danms): A backend with no config group can not have a
# weight set, so just return the default
return 0
else:
return getattr(self.conf, self.backend_group).weight
def configure(self, re_raise_bsc=False):
"""
Configure the store to use the stored configuration options

View File

@ -0,0 +1,6 @@
---
features:
- |
A `weight` option has been added to the store configuration definition.
This allows configuring stores with *relative* weights to each other for
sorting when an image exists in multiple stores.