71 Commits

Author SHA1 Message Date
Guillaume Boutry
93eabbfa72
Implement cinder-volume as a snap
This change includes cinder-volume and cinder-volume-ceph to manager the
cinder-volume service as snap that can be configured over multiple
backends.

Change-Id: Id520fc95710c8516aed5eae08cb20c8e54808cc7
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2025-02-24 13:22:53 +01:00
Guillaume Boutry
4d4b4a41b0
[ops-sunbeam] Ensure external connectivity for machine charms
Machine charms need external connectivity to access services hosted on a
K8S substrate.

Ensure rabbitmq / ovn relay are access remotely for machine charms.

Closes-Bug: #2098974
Change-Id: Ifadb196dd6d60e33feab7dc0d835a7ea84444b9e
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2025-02-21 17:39:48 +01:00
Guillaume Boutry
cb27776b43
[ops-sunbeam] Move handlers setup in post_init
Because handler setup was performed in __init__, this made using
attributes defined in constructor impossible to use in the setup
methods except by ensuring right order in object init. This, in
turn, added a lot of overhead.
Methods of an object should be able to use attributes defined in
the object constructor.

Move handler setup in __post_init__ hooks, called after object
initialiazation.
Remove constructors only calling super() constructor.
Re-order attribute definition to be called after super()
constructor.

Change-Id: Ieb9d23b1e4764e2c0e894c932b7584b5b7c38258
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2025-02-21 13:30:22 +01:00
Guillaume Boutry
9de7b1209d
[ops] consider model error as relation not ready
When removing relations / applications, identity relations lose access
to secrets. Consider ModelError as relation no longer ready.

Treafik route access to relation data is also forbidden during shutdown.

Change-Id: If91fbadeb8b2d81e20ab278ee0d9e499edd55c4c
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2024-11-27 14:58:48 +01:00
Hemanth Nakkina
0bdc19c4ea
Add support for masakarimonitors
* Add new interface service-ready to check for service
readiness of remote application.
* Create a placeholder charm sunbeam-libs to place all
the common libraries. The charm and the libraries need
not be published to charmhub since at this point of time
they are used internally by sunbeam.
* Add provider to service-ready in masakari-k8s
* Add requirer to service-ready in openstack-hypervisor
and enable/disable snap option masakari.enable based on
service-ready relation.

Change-Id: I99feccee2c871fc5a581fdea6f45a541efc2a968
2024-10-10 08:06:43 +05:30
Hemanth Nakkina
d6619680e1 Move GnocchiServiceRequiresHandler to ops_sunbeam
Move GnocchiServiceRequiresHandler to ops_sunbeam
library.

Change-Id: I9412b3e65b203c59252ad680ecfa65f83ad187bd
2024-08-29 11:31:46 +00:00
Guillaume Boutry
8c674de50e
[ops-sunbeam] Implement mypy linter
Implement mypy in the most non-breaking way possible. There's still some
changes of behavior that crept in, merely due to incorrect edge case
handling.

Charm libraries are generally well typed, include py.typed marker for
all of the libraries, to allow mypy analyzing their usage.

Change-Id: I7bda1913fa08dd4954a606526272ac80b45197cc
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2024-08-13 18:56:33 +02:00
Guillaume Boutry
e5fb16d6b9
Implement tracing
Implement tracing relation for all the charms.
Instrument most of ops.Object objects, including relation handlers,
pebble handlers, and relation objects.

Change-Id: I967ff858a63aa7d30094cf5a46491fce11195060
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2024-07-31 11:57:32 +02:00
Guillaume Boutry
0214e8f173
[*-k8s] implement log forwarder
Implement LogForwardHandler for every k8s charm to forward service
stdout to logging provider.

Tempest-k8s is excluded  because it implements its own logging handler.

Change-Id: Iccc9f1f911acfaaecf733fe78cc4bc3191a231d5
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2024-07-07 21:04:11 +02:00
Hemanth Nakkina
366b83e3eb Add necessary translators to peer handler context
BasePeer handler currently changes any '-' characters
in app databag keys to '_'. Handle '/' and '.' as well.
Charm microceph uses app databag keys like
'microceph/0,join_token'

Change-Id: I6091ba503e8711fcc6a43f672cfecc01eff44561
2024-07-03 11:54:45 +00:00
Guillaume Boutry
ed4ed712bb
[tls-certificates] refactor tls certificate handler
This change refactors tls-certificates relation handler.
List of changes:
- Allow management of multiple tls certificates on the same relation
- Allow easier override of certificate signing request (csr)
- Enable certificate renewal on expiration / revokation
- Upgrade tls-certificates relation from v1 to v3

Change-Id: I4f6ac6a5570635388cc10131b34fbc6b422e1bca
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
2024-06-26 23:59:37 +02:00
Guillaume Boutry
c42fd63af7
[ops-sunbeam] do not log private key when accessing
private_key property is currently logging to debug the actual private
key. Remove the log altogether as this should not be logged

Change-Id: Ibfbded3d0724dda06098f334218183f32be0ac28
2024-05-30 13:58:41 +02:00
Hemanth Nakkina
f611ba9e60
[nova] add support for nova spice proxy
lib changes
Add new library nova_service to exchange config
information like nova spice proxy url.

ops-sunbeam changes
Move TraefikRouteHandler from heat-k8s to
ops_sunbeam to reuse in nova-k8s charm as well.
Add nova-service requires handler

nova-k8s changes
Add new container in nova-k8s for nova spice proxy
Add the corresponding pebble handler with plan to
start nova spice proxy process
Change the ingress relation to use traefik-route so
that both nova-api and nova-spiceproxy applications
are exposed via traefik
Add new interface nova-service to provide nova
spiceproxy url to client openstack-hypervisor.
Add nova-service provider handler

openstack-hypervisor changes:
Add interace nova-service in requires section of
metadata.yaml
Handle nova-service requires and update snap config

Change-Id: I27dd6523628e492bef1d1dd851dc528e41c520c7
2024-04-19 14:28:46 +05:30
Hemanth Nakkina
7907fad1ef
Set refresh True for retrieving secret content
For retreiving content of secret using get_content(),
use flag refresh=True to always get the latest revision.

Change-Id: I1ec2b2de5c8607b1593be8e5351ddc2c1444ded7
2024-02-23 13:24:13 +05:30
Hemanth Nakkina
bd057784d5
Make keystone as certificate transfer provider
Add functionality to keystone to act as a
certificate transfer provider.
Add actions to add, remove, list CA certs
to keystone.
Add Certificate Transfer requires handler
in ops_sunbeam. Update keystone_auth section
cafile option if certificate is available
in receive-ca-cert relation.
Update metadata.yaml for keystone and rest of
k8s charms.

Change-Id: I9c800e8f8a0c9197b195331be7b445bafe794780
2024-02-14 17:10:28 +05:30
Hemanth Nakkina
a22d1409cc
Add tox fmt, pep8 to ops_sunbeam
Tox fmt, pep8 for ops_sunbeam are missed
when projects are moved to mono repo.
Add support for fmt, pep8 for ops_sunbeam.

Run tox fmt and tox pep8.

Change-Id: I41559410ff55020ef30ed4b824f7596a20e88bab
2024-02-08 10:54:58 +05:30
Guillaume Boutry
7285775f54
Read only provider side of database relation
Since upgrade of mysql relation (and secrets), only the application's
leader can lead the whole relation databag. Non-leader requiring units are only
allowed to read the provider side of the relation and their own unit's.

Change-Id: Iee073d654cabfbdefc817ea7c0207f3f28c457ac
2024-02-06 19:00:35 +01:00
Guillaume Boutry
943c9fd988
Migrate database interface
data_platform_libs.v0.database_requires was deprecated on January 4th,
2023 and has not received updates since then.
This change migrates to data_platform_libs.v0.data_interfaces which the
preferred way to interact with MySQL.

Most notable changes:
- User/password in a secret
- Keystone test 'test_on_peer_data_changed_with_fernet_keys_and_fernet_secret_different'
  is no longer mocking secrets to make sure it's using database secrets.

Change-Id: Ia1908c0828689458c6ff3fa8d9640c8debfc0a73
2024-01-27 14:29:40 +01:00
Guillaume Boutry
1cf33168ff
Reference ops.Object from its definition package
ops's Object is defined in the framework package. The charm package is
only a user.

Change-Id: I3683f30fed9cda28b25efce21c40beaf447e1fca
2023-12-06 13:45:10 +01:00
Zuul
6011477f08 Merge "stop services when mandatory integrations are removed" into main 2023-11-01 12:52:41 +00:00
Hemanth Nakkina
721a454853 stop services when mandatory integrations are removed
Stop all the services running in the container
when mandatory integrations are removed.
Currently the relation data is not cleared during
processing of gone away events. This is a bug in
juju reported at [1]. Due to this the relation is
still considered as ready.
Add workaround to check the event and mark the
relation to not ready if the event is gone away
event of the relation.
Catch database relation-broken event and block the
application.

[1] https://bugs.launchpad.net/juju/+bug/2024583

Change-Id: I80a0120d08b79561c13996c7a0f055824a1d5336
2023-11-01 17:45:31 +05:30
Liam Young
cc5fe344b0 Handle _private_key being None
Recent change Ieffac3732c95846d0e3ec2408a9be4d96e477603 broke the
neutron-k8s py3 tests due to self.private_key being
accessed (_request_certificates method, `if self.private_key`)
before it had been properly set causing an attempt to decode None

Change-Id: I33bbf65e1d170cbc80161c573a381db43468b413
2023-10-31 15:21:52 +00:00
Guillaume Boutry
72ee41376c Implement relation for user ops
Change-Id: I81f9cfc548e002de71dbafa9254c6059fb9226d9
2023-10-25 15:34:41 +02:00
Hemanth Nakkina
f4afc7a17b Fix TlsCertificate private key type
TlsCertificateHandler holds private_key variable
which is updated as type bytes sometimes and str
sometimes. Ensure private_key is of type str.

Change-Id: Ieffac3732c95846d0e3ec2408a9be4d96e477603
2023-10-20 06:09:32 +00:00
Liam Young
e380551b21 Use public method for url retrieval for traefik
Due to a bug in the public url method sunbeam was using the
private _get_url_from_relation_data. This ignores stored state
and interogates the relation data directly. This causes a
race condition when new traefik units are coming up. The bug in
url property is fixed in v2 of the traefik interface so switch
to using that instead.

Closes-Bug: #2036990
Change-Id: I883ca62f8b6e072648bf69d9481bd6c11014ae6b
2023-10-11 16:26:46 +00:00
Zuul
851ba137e2 Merge "Gate requesting certificates" into main 2023-10-11 01:18:56 +00:00
Liam Young
d29d36d9e5 Gate requesting certificates
Do not request certificates if the relation is not yet made.

Change-Id: I5417e58f55b0420615b3c926c01b9ff21641f094
2023-10-10 16:36:10 +00:00
Zuul
97ceb19e4b Merge "Handle secret retrieval on depature" into main 2023-10-10 15:18:58 +00:00
Liam Young
ac280d0407 Split IP and DNS SANs in CSR
Using the deprecated 'sans' keyword to the generate_csr method
from the tls interface results in IP address being added as
DNS Sans which is wrong and breaks verification. This updates
the relation adapter to split them up so they are registered
correctly in the csr.

Change-Id: I4fb5c60dba5636fc40fb76c4468e376b7f059924
2023-10-10 14:22:58 +00:00
Liam Young
dcac4b5f5f Handle secret retrieval on depature
Gracefully handle failure to access tls key secret when unit is
departing.

Change-Id: Ic27e059f09f0900192007b84e68ff7ded1f0f06f
2023-10-10 13:54:41 +00:00
Zuul
f24edf6a06 Merge "Update relation data from configure_charm" into main 2023-10-10 08:58:38 +00:00
Liam Young
92ec0fa3e8 Update relation data from configure_charm
This change adds a mechanism for charms to be able to update
relation data as part of configure_charm rather than responding
to an explicit relation event.

The reason for this is that pod can be recycled at any point
causing it to loose its defered events. So, if a relation
adapter method to send relation data contains a defer that
deferred event can be lost and when a pod comes back it is
never resent.

Closes-Bug: 2036188
Change-Id: I2e6b27cdc05e93ebb25a7859b3c039ae64d82d9d
2023-10-10 08:30:01 +00:00
Guillaume Boutry
a0d62d61e3 Migrate traefik ingress to v2
Current ingress relation only routes unit to requirer's leader.
Ingress V2 fixes that issue.

Change-Id: Ie17c31a8a3fc04c42e31ff424ce7bf1f9eff178f
2023-09-26 17:07:31 +02:00
gnuoy
a7ac636d28 Revert "Revert "Add relation handler for ceph-access relation""
This reverts commit 8f18062509d092330e303f94d84a8a4a80d7404f.

Reason for revert: This revert should have been targetted at the stable/2023.1.2 branch not main

Change-Id: Id446a017e3b38bf58c651102f97f72702da1347b
2023-09-19 15:28:23 +00:00
Liam Young
b03ebe18fc Revert "Add relation handler for ceph-access relation"
This relates to volume attatchment which is not landing as
part of 2023.1.2 and is currentrly causing the cinder-ceph
charm to fail as the ceph_access lib is missing.

This reverts commit 3bcd8ade511868f81be9a2db1834a558846e9744.

Change-Id: I7d8dae2729657a98ea5c9d6bba860fe316b248b4
2023-09-19 10:19:38 +00:00
Liam Young
db95a08cb4 Add relation handler for ceph-access relation
Change-Id: If5f91e9a8996db5bbc26b135d9956321b196589d
Signed-off-by: Liam Young <liam.young@canonical.com>
2023-09-06 11:07:15 +00:00
Hemanth Nakkina
4f7e98956b Add requires handler for ceilometer-service relation
Add Requires handler for ceilometer-service

Depends-On: https://review.opendev.org/c/openstack/charm-ceilometer-k8s/+/893159
Change-Id: Id52b0c388b62634588b133ea214a7c8057aaa3a5
2023-09-06 13:29:56 +05:30
Hemanth Nakkina
0b03d60129 Add identity resource requires handler
Implement Identity resource requires handler.

Depends-On: https://review.opendev.org/c/openstack/charm-keystone-k8s/+/891651
Change-Id: I0b320e37447e368619225c4c4832483bb476ec40
2023-08-17 14:19:08 +05:30
Liam Young
304f85fd68 Redact database password from logging
Change-Id: I5cb137a68ccfc928d0efba0a96c35805d50870e3
2023-07-28 09:54:32 +00:00
Guillaume Boutry
6eaef1e774 Add hostnames check for RMQ handler readiness
The hostnames field is filled later in the relation but templating the
context is not possible without this field. Making it mandatory to
consider RMQ Handler ready.

Change-Id: I017c4f563565503a1cc28d8db8b0b5dc406053d7
2023-05-16 17:03:42 +02:00
Zuul
370a3a6b0e Merge "Revert "Switch to using v1 cloud_credentials"" into main 2023-04-13 04:27:51 +00:00
gnuoy
c6246a22e6 Revert "Switch to using v1 cloud_credentials"
This reverts commit c2c6d588c78b7701f6ca8e6dfffa9b81a88c5b25.

Reason for revert: I misunderstood and v0 Identity credentials actually supersedes v1 cloud credentials 

Change-Id: Ia985e8c147d92ef593b785d18a1c31132d9b1551
2023-04-12 15:12:10 +00:00
Liam Young
e002891738 Fix get_private_key when key is not yet set
Handle case where private_key is not set yet

Change-Id: Ic0f713f73a6469e2dd67aa0f9cc8d273b06d72f9
2023-04-03 14:51:21 +00:00
Zuul
c400491d75 Merge "Support charms with no peer relation" into main 2023-04-03 08:14:25 +00:00
Liam Young
b58db9f65a Support charms with no peer relation
Change-Id: I8ce489e09b077f21fbd0d12a3e4ee81290e75f9a
2023-04-03 07:47:24 +00:00
Liam Young
73ce780a1d Switch to using v1 cloud_credentials
Change-Id: I2efd76b2e21528e5cfff0321f040af2aae35cc05
2023-04-02 13:01:39 +00:00
Zuul
5b6e0b1fa0 Merge "Rename cloud-credentials to identity-credentials" into main 2023-03-10 07:45:34 +00:00
Guillaume Boutry
9855f91713 Rename cloud-credentials to identity-credentials
Change-Id: Ic7b728bc116447e666481740ced084a7ad75f76b
2023-03-10 08:13:15 +01:00
Hemanth Nakkina
8b1c963ef1 Fix owner of private_key secret
The owner of private_key secret in TlsCertificatehandler
should be Unit instead of Application.

Change-Id: I4020f6e431602fdf1dbce92c8a9c99cba4b41104
2023-03-09 11:37:03 +05:30
Zuul
b19fcbc9fd Merge "Use library cloud_credentials v1.0" into main 2023-03-07 13:47:39 +00:00