Commit Graph

186 Commits

Author SHA1 Message Date
Trent Lloyd 0042bc36de Replace deprecated _ows_check_services_running
_ows_check_services_running was made public without the underscore and
it's private function name was made an alias and marked deprecated by:
https://github.com/juju/charm-helpers/pull/658

Switch to the new name to avoid many deprecation warnings being printed
by dependant charms every time update-status hooks run:
DEPRECATION WARNING: Function _ows_check_services_running is being
removed on/around 2022-05 : use ows_check_services_running() instead

Change-Id: I4758330db81a95ac2aa17f9bc316afdc2eab2d44
2024-03-22 13:39:55 +00:00
Erlon R. Cruz fd042afdf1 Skip version caching for subordinate charms
Caching the charm OpenStack version will cause undesired behaviors
if the charm is a subordinate. The charm local cache is firstly
populated during the charm install. If the charm is a subordinate,
the version will remain the same regardless of future OpenStack
upgrades because today, the hook that updates the cache to the new
version in only called for principal charms.

Related-bug: #1949074
Change-Id: I76abbd29ca910fe4c4d62da09e2d2dd3b5c798a6
2023-04-25 11:18:58 -03:00
James Page bf2e867e9e adapters: fix compat for auto accessors
The keystone interface rebase to the Endpoint base class re-uses
the auto_accessors approach from RelationBase which makes the
interface smell a little different to other Endpoint based interfaces.

Check and map any keys listed in auto_accessors for all relation
class types rather than just for RelationBase.

This also fixes a minor issue where self.accessors was reset to []
when the auto_accessors attribute was not found in the relation
overwriting any accessors passed in during object construction.

Change-Id: I4481c6d8ad5c9f0a8bc5e892d1d7472be83f3454
2022-09-21 11:02:44 +01:00
fdesi d049eee8f4 fix in config flags features
* fix name clashing
* fix regex
* fix test case

Change-Id: I2dbc4432a4be2b23dd39e66680abbe33da5ae5af
2022-07-02 01:21:51 +02:00
fdesi 18ac668cd7 Add observer for add multiple arbitrary options with config-flags
Add config_property_with_config_flags observer to handle extra option.
The config-flags are comma separated list of key-value pairs.

Change-Id: I74a693df95bebb14a6edcb796f1c8e6b17a95317
2022-07-01 10:46:09 +02:00
Liam Young 1079a19e2e Add new Trilio version template property
This change adds a new `trilio_compat_version` that can be used
in templates when an option is gated on the trilio Major and
Minor version. The config option cannot be used for examining
atch versions as it relies on a float representation of the
package version.

Change-Id: I9221188b817fbb570700406b97e194aacf6ef786
2022-06-16 10:02:47 +00:00
Liam Young 055fb499b8 Support Trilio 4.2 Share hashes
The Trilio 4.2 changes the way that hashes are generated for nfs
mount points. The hash is now generated from the directory only,
the source IP address is ignored. This patch updates the ghost-share
action to accommodate that.

Change-Id: I64a1cc95a3a78ce79d57f5b840edb29996f04f9c
2022-06-13 16:33:05 +00:00
Frode Nordahl 13ef220ce3
core: Gracefully handle missing config option
The ``get_os_codename_package`` function will be called by all
charms.  The newly added call to the ``configure_source`` method
may in some circumstances raise an exception due to missing
source configuration option.

Handle this situation gracefully.

Related-Bug: #1951462
Change-Id: I2bb9c2561b89fea366bd7b7f6a10c3140ce09000
2022-02-26 07:38:20 +01:00
Frode Nordahl 55cc044ea8 Fix use of ``openstack-release`` to determine codename
The current code will oportunisticly attempt to install the
``openstack-release`` package, but it does so without configuring
the UCA sources.

Attempt to configure sources to avoid charms getting stuck in a
chicken and egg situation.

Closes-Bug: #1951462
Change-Id: I8ed6e2dfc7ce83c2e56fd072458e2ef189968e41
2022-02-25 11:29:23 +01:00
Frode Nordahl dda431eaf9
core: Move package version helpers to BaseOpenStackCharmActions
To resolve a inter-dependency issue between the various package
version helpers and the UCA ``configure_source`` method, co-locate
all of them in ``BaseOpenStackCharmActions``.

Partial-Bug: #1951462
Change-Id: If42ad980ff2b0430eba24531eae9a80204768388
2022-02-25 11:22:53 +01:00
Corey Bryant fd6581ecab Add support for package-upgrade action
The package-upgrade action is similar to the openstack-upgrade
action except that it performs package upgrades within the current
openstack release. If a new openstack release is available, the
package-upgrade action will not perform any upgrades.

Change-Id: Ie783f8da67494f31abe574d99b1f2433dc622be9
2022-01-13 14:21:50 +00:00
Zuul 7aa1c0e4d0 Merge "Use unittest.mock instead of mock" 2021-12-14 18:53:42 +00:00
Hervé Beraud 2812f9f664 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Change-Id: I491ca9f482a00b7ca3fa44aa8c26ef73559c178f
2021-12-14 13:06:13 +00:00
Felipe Reyes 58fc4dadac Register previously vip set for deletion.
When the vip is changed the ones that are no longer present need to be
registered for deletion from pacemaker's configuration. This change
relies on hookenv.config.changed() to determine what vip(s) are no
longer present in the configuration and ask hacluster to remove them.

Closes-Bug: #1952363
Change-Id: I1afe987ff26af0e10604dd507daef4ac282d9aab
2021-11-30 15:49:40 -03:00
Olivier Dufour-Cuvillier 6b0c1c7cad Replace deprecated call from charmhelpers policyd
The use of function maybe_do_policyd_overrides_on_config_changed
is deprecated in favor of maybe_do_policyd_overrides.
This would trigger deprecation warning messages not only in logs
but also in actions such as seen in Octavia Charm

The unittest covering the call has also been updated accordingly

Closes-Bug: #1939840
Change-Id: Iec91d60727533e6291c3ec20442197ac44f4607c
2021-11-23 11:59:36 +01:00
Liam Young 6c8eb01162 Config adapters for trilio s3 cert
Change-Id: I2351baa89b3f9d33eb2f9ad6bf4f82d044b2d330
2021-06-14 11:31:27 +00:00
Corey Bryant 8960e070f2 Use openstack-release package to determine codename
The use of package versions to look up OpenStack codenames is
deprecated for in favor of using the openstack-release package.
The openstack-release package is available for Wallaby onward.

Change-Id: I9038c9785a4f36b854a1fb7e8d5baaf91a99c70e
2021-04-23 08:07:20 -04:00
Zuul bcd0c9b4b4 Merge "core: Add all supported releases - packages map" 2021-03-23 22:28:38 +00:00
Frode Nordahl ccb778f111
core: Add all supported releases - packages map
For principal - subordinate plugin type relations where the
principal Python payload imports code from packages managed by a
subordinate, upgrades can be problematic.

This helper will allow a subordinate charm to inform its principal
about all implemented release - packages combinations ahead of time.
With this information in place the principal can do the upgrade in
one operation without risk of charm relation RPC type processing at
a critical moment.

Related-Bug: #1806111
Change-Id: I455501c1c2cdb53e62b533be95d2493bf1a5027a
2021-03-19 03:44:53 +01:00
Liam Young 6719913853 Use restart_on_change from charmhelpers
Switch to using restart_on_change from charmhelpers rather than
duplicating the code in charms.openstack.

I have run designate smoke with this change: https://paste.ubuntu.com/p/ZyQmyK92Yr/

Change-Id: I4925243747dd00471bc828c65278dd16ed951b0c
2021-03-18 12:42:59 +00:00
Billy Olsen df9a2eddec Use application_name by default for creating pools
Charms consuming Ceph storage typically follow the convention that
pools are named for the application rather than the service name. Most
charms also allow for the pool name to be defined via a config option.
Charms which inherit from the BaseOpenStackCephCharm class will not
follow this typical behavior as the pool created is based on the charm
name.

This change updates the create_pool function to allow for a concrete
charm to optionally provide the name of the pool to be created,
defaulting to the application_name if one is not provided. This is a
change in behavior as the previous behavior was to use the charm
class's name property. Reviewing all known charms which inherit
from/mixin the BaseOpenStackCephCharm reveals that Gnocchi is the only
user of the create_pool method.

As such, it stands to reason that a change in behavior is safe in this
context since the charm class's name for gnocchi was set to the
'gnocchi' which is also the typical application name.

Change-Id: I1756ff4e1362fbc7584551249c583f8d3cb0c8dc
Closes-Bug: #1918821
2021-03-17 09:21:54 -07:00
Liam Young bf521e6d5b Stop getting {public,private}-address from unit-get
In Juju 2.8rc3 unit-get public-address became unreliable
(Bug #1910973). Since getting an address this was is deprecated
switch the OpenStack functions to prefer network-get. However,
fallback to the old method to support old versions of Juju for
the time being.

Change-Id: I33020deefa1f814b77767653dad34c228def91fa
2021-01-15 08:32:56 +00:00
Liam Young 2520764264 Support upgrades to Trilio 4.1
Adding support for Trilio 4.1 includes the following changes:

* Add Trilio_properties config property to enables templates to
  distinguish between 4.0 and 4.1 release.
* Add get_trilio_codename_install_source to attempt to derive the
  Trilio version supported by an apt repo.
* Add get_trilio_charm_instance which overrides the default
  get_charm_instance.  This will pick the correct charm class based
  on both the Trilio release and the OpenStack release.
* Add select_trilio_release which overrides the default
  select_release and calculates the target OpenStack and Trilio
  release.
* Add a specialist Trilio metaclass BaseTrilioCharmMeta. This
  registers charm classes using their OpenStack release, Trilio
  release and package type.
* Move code shared between TrilioVaultCharm &
  TrilioVaultSubordinateCharm to TrilioVaultCharmMixin. Add support
  for Trilio upgrades to TrilioVaultCharmMixina.

NOTE: An earlier version of this change
      (I5a5e5721d9a713b66f8c796896c400481e9733a2) was landed and
      reverted. It was reverted because get_trilio_charm_instance
      and select_trilio_release were both registered as handlers
      irrespective of whether a charm explicitly imported
      charms_openstack.plugins.trilio This caused reactive charms
      which used the default handlers to fail as they imported the
      Trilio functions and the default ones and only one can ever
      registered. This patch fixes this by wrapping the trilio
      function definitions inside make_* methods, so the decorator
      only registers the methods when the make_* methods are
      explicitly called.

Change-Id: Id3bb13aff6d0e6df2d5ec144689c992cf09c1b4c
2021-01-07 09:48:13 +00:00
gnuoy 390a426d31 Revert "Support upgrades to Trilio 4.1"
This reverts commit 3b72a8ba2f.

Reason for revert: Registering a second release_selector_function is breaking non-trilio charms

Change-Id: I5a4b8f8602c2a46b340765a8a22fdc218560dfc6
2021-01-06 13:43:58 +00:00
Liam Young 3b72a8ba2f Support upgrades to Trilio 4.1
Adding support for Trilio 4.1 includes the following changes:

* Add Trilio_properties config property to enables templates to distinguish
  between 4.0 and 4.1 release.
* Add get_trilio_codename_install_source to attempt to derive the Trilio
  version supported by an apt repo.
* Add get_trilio_charm_instance which overrides the default get_charm_instance.
  This will pick the correct charm class based on both the Trilio release and
  the OpenStack release.
* Add select_trilio_release which overrides the default select_release and
  calculates the target OpenStack and Trilio release.
* Add a specialist Trilio metaclass BaseTrilioCharmMeta. This registers
  charm classes using their OpenStack release, Trilio release and package
  type.
* Move code shared between TrilioVaultCharm & TrilioVaultSubordinateCharm
  to TrilioVaultCharmMixin. Add support for Trilio upgrades to
  TrilioVaultCharmMixina.

Change-Id: I5a5e5721d9a713b66f8c796896c400481e9733a2
2020-12-17 11:57:38 +00:00
Liam Young 38de241ce6 Allow bespoke get_charm_instance method to be used
Allow a charm to use the new register_get_charm_instance decorator
to register the method to be used when getting a charm instance.
Currently get_charm_instance expects standard OpenStack
versioning, this change allows are a charm to register an
alternative get_charm_instance method that can handle an
alternative versioning system.

Perhaps controversially the default method is not defined in
charms_openstack.charm.defaults. I have kept it in core
because it felt a more natural fit there given it relies on
core._releases but I am open to moving it if that is
preferable.

Change-Id: I42574654bc1f314b49049e80861d4039f8484dff
2020-12-03 13:46:07 +00:00
Linda Guo 8c2283a508 Checked if release_pkg is set. If not, ensure a RuntimeError raised.
Added test case to verify RuntimeError is raised when release_pkg is not set.

Closes-Bug: #1904494
Change-Id: I421b52d502644b52f4e31162e74dea8a1befdfa0
2020-11-30 10:00:05 +11:00
Zuul 8b2eed06c4 Merge "plugins/ceph: Add common pool creation method" 2020-10-02 14:18:29 +00:00
Frode Nordahl af1dd4cdee
plugins/ceph: Add common pool creation method
The new helper supports to optionally retrieve common
configuration options for BlueStore Compression.

Fix ordering of Ceph class composition. Both the CephCharm and the
fake charm class used in the unit test had the wrong order for the
composition making it impossible to override already existing
methods inherited from OpenStackCharm.

Change-Id: I9fb543f297522c7217acdcfa950bb2810b26c4a0
2020-10-02 14:57:36 +02:00
Liam Young c1db249cfb Optionally change service port for ssl
If a charm class sets ssl_port_bump to True then when configuring
the service for TLS also change the port it is listening on.

The need for this comes from the nova-scheduler and nova-compute
services which cache the url for the placement service, when the
placement service switches protocol the nova services fail which
does not trigger them to reexamine the catalogue.

Closes-Bug: #1862974

Change-Id: I790c55e78439b9a5ea2c3f12edbe5928a4f08e05
2020-09-28 13:03:34 +00:00
Dmitrii Shcherbakov 69eb753b02 Configure TLS on config-changed events
Ensure that TLS is potentially reconfigured in the event of a
config-changed hook execution - ssl_* configuration options may
have been changed so certs, keys and CA files on disk will need
to be updated.

Change-Id: I00d2eb16714785b15e13b196ea12716dc8a5b527
Related-Bug: 1865842
Co-Authored-By: James Page <james.page@ubuntu.com>
2020-09-21 09:39:08 +03:00
Zuul d0d3e2b1ea Merge "Allow service actions to be overridden" 2020-09-10 10:05:04 +00:00
James Page 4c2486660f trilio: Support multiple NFS share configurations
TrilioVault supports use of multiple NFS shares using a comma
separated list.  Update the ghost-nfs-share action code to
support this type of configuration.

The assumption is that the order of shares provided to the
action is the same as the order of shares in the nfs-shares
configuration option in terms of replication between sites.

Mismatched length lists will generate an exception which can
be propagated back to the operator.

Change-Id: I7d501a3e44d4e7c732e7625fa2a8cde9a34ff564
Closes-Bug: 1894817
2020-09-08 11:49:49 +01:00
Dmitrii Shcherbakov c9b4009810 Allow service actions to be overridden
In order to allow child classes to use other means of controlling
service lifetime, this change introduces methods that call
systemd/upstart via charm-helpers by default but allow for something
else to be used in overrides.

The example use-case in question is the use of crm tools to restart
services:

crm_resource --restart --wait --node <node-name>

Which will restart a resource on a given node if it is running there or
return ENXIO otherwise.

Change-Id: Ifb16f6743296a1ef6dcb212cad517afd57270f7f
Closes-Bug: #1891160
2020-08-12 16:40:05 +03:00
Zuul 7e8c5c1461 Merge "Enable Database TLS" 2020-07-17 16:14:17 +00:00
David Ames 2ed7b212ef Enable Database TLS
Bring the charms.openstack Database handling into line with classic
charms and charm-helpers.

* Write out the SSL key and certs from relation data
* Point sqlalchamy at the files

Change-Id: I78218aa972ead49f144bb19a988bd6f0bbf4a539
2020-07-17 07:44:15 -07:00
Zuul 84da63c663 Merge "Stop to use the __future__ module." 2020-07-13 05:41:43 +00:00
James Page 2b143b9687 Refactor Trilio charms base classes
Move into separate module to avoid explosion in size of
adapters classes module.

Refactor principle and subordinate classes to have the
correct super classes.

Provide install and configure source helpers as functions
so they can be used in both class types.

Split ghost share action out into a mixin as its not used
everywhere.

Add TrilioVault charm classes to main module __all__.

Change-Id: Ic6c81a812445010052fa65803a9016652bf353c5
2020-06-11 05:57:44 +01:00
Zuul bb7e58460a Merge "plugins/ceph: Add support for core Ceph charms" 2020-06-09 16:19:41 +00:00
Frode Nordahl e03f6a6a1c
plugins/ceph: Add support for core Ceph charms
Also adds missing release combinations to package_codenames.

Change-Id: I6fbde855ba8f83ef5e265bd5b5dfb0d01eae830b
Related-Bug: #1879072
2020-06-09 15:59:28 +02:00
James Page 037ea8bdf7 Add TrilioVault charm classes
Add two helper classes to support common behaviour across the
TrilioVault charm set.

Change-Id: Ibe6c920f577326dfe0f6c3339de69a3cc060eb36
2020-06-09 14:57:32 +01:00
James Page f0a486c59d Drop flake8 upper version constraint
Clear up lint as a result of new pep8/flake8 version.

Change-Id: I3698766cb751b31ef1e6b806baa45c1cf6f7d899
2020-06-08 10:29:45 +01:00
Hervé Beraud f72403ad3c Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
2020-06-02 20:06:38 +02:00
David Ames 89d60a48df Set port for mysql connection in Shared-DB
Change-Id: I2e7e95a4ee7d25b520af823085bd8c577e232e30
2020-05-05 15:14:51 -07:00
Frode Nordahl 21da52526c
Allow specifying config key in call to configure_source
A charm may be in need of adding multiple sources (for
example vendor specific PPAs), and it would be useful
if the ``configure_source`` method would allow to do
this.

In such a use case overriding the ``source_config_key``
class variable would not be practical, so we allow
to optionally specify it as a argument to the method.

Change-Id: Ia5a8f05e863251520771a1c01a5f7dddf4be34d0
Closes-Bug: #1876720
2020-05-04 15:57:38 +02:00
Frode Nordahl f9bd43ff5d
Support charms providing templates with same basename
Replicate functionaltiy of ``charmhelpers.contrib.openstack``
where template files named after the absolute path of target
with path separators repalced by underscores can be used.

This convention is useful when charm author need to provide
templates with ambiguous basename.

Change-Id: I534fe52f38df7d1e409246115836223e90f080bc
Closes-Bug: #1872689
2020-04-14 13:26:20 +02:00
Frode Nordahl d8b376cde2
Allow release selection to work for subordinate charms
The release selection function bases its decision on installed
packages and falls back to looking up OpenStack release codename
from source configuration option when no packages are installed.

Subordinate charms do not have a source configuration option,
thus we want to make it possible for a charm author to request
the release selection decision be made based on what is currently
available in the system APT cache alone.

Our principle charm should already have configured the system
with the desired UCA pocket enabled.

The charm author requests this behaviour by setting the
``source_config_key`` to an empty string.

Note that functions for upgrading between releases etc also
depend on the charm having a source configuration option but
that is OK as the subordinate has no business dealing with
that and should defer such operations to its principle charm.

Change-Id: Ieae81619e06dc287c2c42ec944425be4de13d0d6
Closes-Bug: #1865510
2020-03-19 07:56:44 +01:00
David Ames 72cfde8308 Avoid multiple calls to create_ip_cert_links
Prior to this change, the call to create_ip_cert_links was inside the
for loop of tls objects. This caused LP Bug#1866741 where a sym link
with the same certificate name would get overwritten with a new cert.
This meant the last certificate of [internal, admin, public] would be
written to all three.

This change calls create_ip_cert_links and state sets only once. It also
adds a warning log entry if we accidentally overwrite sym linked files in
the future.

Change-Id: I4b36d7fd5e74ab3a894eb4a2451b5876fd777552
Partial-Bug: #1866741
2020-03-10 13:56:53 -07:00
Frode Nordahl 5deeb8afb8
release select: Handle None return from get_os_codename_package
Change If7f35e7d00533599c3800aa4a22c51861017969e introduced a bug
that roots in the assumption that the ``get_os_codename_package``
function when called with ``fatal=True`` would raise an exception
in the event package or major version was not present in the map
provided to the function.

Instead of changing the API of ``get_os_codename_package`` method
we detect a ``None`` return in the default select handler.

Change-Id: Icad1811d1f183da25872b81192b69284373fbefb
Related-Bug: #1863774
2020-03-06 10:03:57 +01:00
Zuul d0f6150d4d Merge "Use charm codenames for select release when provided" 2020-02-19 14:26:36 +00:00