projects
/
osm
/
devops.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug 1681 to run stage-test only if changes in installer charms
[osm/devops.git]
/
installers
/
charm
/
mon
/
src
/
charm.py
diff --git
a/installers/charm/mon/src/charm.py
b/installers/charm/mon/src/charm.py
index
ab6dd2d
..
8c0a6bc
100755
(executable)
--- a/
installers/charm/mon/src/charm.py
+++ b/
installers/charm/mon/src/charm.py
@@
-70,6
+70,7
@@
class ConfigModel(ModelValidator):
vca_secret: str
vca_cacert: str
database_commonkey: str
vca_secret: str
vca_cacert: str
database_commonkey: str
+ mongodb_uri: Optional[str]
log_level: str
openstack_default_granularity: int
global_request_timeout: int
log_level: str
openstack_default_granularity: int
global_request_timeout: int
@@
-92,6
+93,12
@@
class ConfigModel(ModelValidator):
_extract_certificates(v)
return v
_extract_certificates(v)
return v
+ @validator("mongodb_uri")
+ def validate_mongodb_uri(cls, v):
+ if v and not v.startswith("mongodb://"):
+ raise ValueError("mongodb_uri is not properly formed")
+ return v
+
@property
def certificates_dict(cls):
return _extract_certificates(cls.certificates) if cls.certificates else {}
@property
def certificates_dict(cls):
return _extract_certificates(cls.certificates) if cls.certificates else {}
@@
-126,7
+133,7
@@
class MonCharm(CharmedOsmBase):
if self.kafka_client.is_missing_data_in_unit():
missing_relations.append("kafka")
if self.kafka_client.is_missing_data_in_unit():
missing_relations.append("kafka")
- if self.mongodb_client.is_missing_data_in_unit():
+ if
not config.mongodb_uri and
self.mongodb_client.is_missing_data_in_unit():
missing_relations.append("mongodb")
if self.prometheus_client.is_missing_data_in_app():
missing_relations.append("prometheus")
missing_relations.append("mongodb")
if self.prometheus_client.is_missing_data_in_app():
missing_relations.append("prometheus")
@@
-149,15
+156,23
@@
class MonCharm(CharmedOsmBase):
def build_pod_spec(self, image_info):
# Validate config
config = ConfigModel(**dict(self.config))
def build_pod_spec(self, image_info):
# Validate config
config = ConfigModel(**dict(self.config))
+
+ if config.mongodb_uri and not self.mongodb_client.is_missing_data_in_unit():
+ raise Exception("Mongodb data cannot be provided via config and relation")
+
# Check relations
self._check_missing_dependencies(config)
# Check relations
self._check_missing_dependencies(config)
+
# Create Builder for the PodSpec
pod_spec_builder = PodSpecV3Builder()
# Create Builder for the PodSpec
pod_spec_builder = PodSpecV3Builder()
+
# Build Container
container_builder = ContainerV3Builder(self.app.name, image_info)
certs_files = self._build_cert_files(config)
# Build Container
container_builder = ContainerV3Builder(self.app.name, image_info)
certs_files = self._build_cert_files(config)
+
if certs_files:
container_builder.add_volume_config("certs", "/certs", certs_files)
if certs_files:
container_builder.add_volume_config("certs", "/certs", certs_files)
+
container_builder.add_port(name=self.app.name, port=PORT)
container_builder.add_envs(
{
container_builder.add_port(name=self.app.name, port=PORT)
container_builder.add_envs(
{
@@
-174,7
+189,8
@@
class MonCharm(CharmedOsmBase):
"OSMMON_MESSAGE_PORT": self.kafka_client.port,
# Database configuration
"OSMMON_DATABASE_DRIVER": "mongo",
"OSMMON_MESSAGE_PORT": self.kafka_client.port,
# Database configuration
"OSMMON_DATABASE_DRIVER": "mongo",
- "OSMMON_DATABASE_URI": self.mongodb_client.connection_string,
+ "OSMMON_DATABASE_URI": config.mongodb_uri
+ or self.mongodb_client.connection_string,
"OSMMON_DATABASE_COMMONKEY": config.database_commonkey,
# Prometheus configuration
"OSMMON_PROMETHEUS_URL": f"http://{self.prometheus_client.hostname}:{self.prometheus_client.port}",
"OSMMON_DATABASE_COMMONKEY": config.database_commonkey,
# Prometheus configuration
"OSMMON_PROMETHEUS_URL": f"http://{self.prometheus_client.hostname}:{self.prometheus_client.port}",
@@
-200,10
+216,11
@@
class MonCharm(CharmedOsmBase):
"OSMMON_KEYSTONE_SERVICE_PROJECT": self.keystone_client.service,
}
)
"OSMMON_KEYSTONE_SERVICE_PROJECT": self.keystone_client.service,
}
)
-
container = container_builder.build()
container = container_builder.build()
+
# Add container to pod spec
pod_spec_builder.add_container(container)
# Add container to pod spec
pod_spec_builder.add_container(container)
+
return pod_spec_builder.build()
return pod_spec_builder.build()