[nova] add priority to traefik config

traefik-k8s adds router-tls dynamically and
middleware is removed. As a workaround rename
router-tls for nova-spiceproxy and add priority.

Update nova-service relation data for any
changes in traefik-route relation data. This
is to update nova-spiceproxy url if http/https
schema changes in traefik-route.

Change-Id: I2c4f26bc96deb1f149c1c1e1f624c114ad36a058
This commit is contained in:
Hemanth Nakkina
2024-04-25 15:27:18 +05:30
parent 693b8843d9
commit fe0fcaf659

View File

@@ -580,6 +580,8 @@ class NovaOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
model = self.model.name
router_cfg = {}
# Add routers for both nova-api and nova-spiceproxy
# Rename router tls and add priority as workaround for
# bug https://github.com/canonical/traefik-k8s-operator/issues/335
router_cfg.update(
{
f"juju-{model}-{NOVA_SPICEPROXY_INGRESS_NAME}-router": {
@@ -591,7 +593,7 @@ class NovaOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
"service": f"juju-{model}-{NOVA_SPICEPROXY_INGRESS_NAME}-service",
"entryPoints": ["web"],
},
f"juju-{model}-{NOVA_SPICEPROXY_INGRESS_NAME}-router-tls": {
f"juju-{model}-{NOVA_SPICEPROXY_INGRESS_NAME}-router-https": {
"rule": f"PathPrefix(`/{model}-{NOVA_SPICEPROXY_INGRESS_NAME}`)",
"middlewares": [
"custom-stripprefix",
@@ -600,6 +602,7 @@ class NovaOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
"service": f"juju-{model}-{NOVA_SPICEPROXY_INGRESS_NAME}-service",
"entryPoints": ["websecure"],
"tls": {},
"priority": 100,
},
}
)
@@ -716,6 +719,10 @@ class NovaOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
config=self.traefik_config
)
# Update nova spiceproxy url
# Any http/https changes are detected here
self.set_config_on_update()
if self.traefik_route_internal:
logger.debug("Sending traefik config for internal interface")
self.traefik_route_internal.interface.submit_to_traefik(