Commit Graph

42 Commits

Author SHA1 Message Date
David Negreira ab565c71bd separate rndc.key file per application
This change fixes an issue that when the charm-designate is
related to two different designate-bind applications, the same
rndc key file is used for the two different applications.

We fix this by writing an rndc_key_file per application rather than in
a single rndc.key file for all the units.

Closes-Bug: #1995975

Change-Id: I5dafeb2b4dcf9549260081d3674038f836d29f0f
Signed-off-by: David Negreira <david.negreira@canonical.com>
2024-03-25 09:24:08 +00:00
Olivier Dufour-Cuvillier f84cee2634 Prevent update-status to run unrequired handlers
Before, the update-status hook would run many handlers
that would have been normally done only during
configuration changes.
Consequently it creates an impact on the service and
apply changes every time the hook is triggered, which is
in most deployments every 5 minutes.
This prevents the DNS zones managed by Designate to be
updated constantly and potentially avoid race conditions
within designate components.

Closes-bug: #2003528
Change-Id: I0d4fea182da1316c0c30c143e64fcd2ca682afff
2023-01-30 11:19:04 +00:00
Tiago Pasqualini 8a4940bbb1 Add check to expose internal endpoints
Currently, the charm ignores the use-internal-endpoints config
option that is being inherited from the Openstack Layer. This
patch adds a check to ensure that the internal endpoint is exposed
if this is set to True.

Closes-bug: #1995188
Change-Id: I48a04ac619204ba109d87ca05de7cbe308592486
2022-11-22 11:33:49 -03:00
Corey Bryant 1dc253a098 Ensure services are not started while unit paused
Closes-Bug: #1983594
Change-Id: Ib05687d0146fee7609f36ca8692dafe0082846bc
2022-09-06 19:29:11 +00:00
Francesco de Simone 1fef3793f5 Disable designate-mdns service until the configuration has been rendered
As per the bug report, designate-mdns service appear to restart multiple time.
This patch disable the service until the configuration has been rendered.

Closes-Bug: #1925233
Change-Id: Ib9843bda9c6967ce50cec8d721079bd70f7f3040
2022-07-18 13:35:00 +00:00
Nicholas Malacarne 3fce0cb6c0 Add NRPE service checks for upstream DNS
Added NRPE checks to detect when upstream DNS servers
are unreachable. We had a case where a customer changed
settings on their DNS servers which caused an outage.

The added check will allow our alerting to capture
cases where the upstream DNS servers become unreachable.

One service check is generated for each value found
in the 'nameservers' charm config params. The checks
use the 'check_dns' command with a host value of
'canonical.com', and each command checks a corresponding
nameserver value from the 'nameservers' config params. All
other optional flags for 'check_dns' are using the default
values.

Closes-bug: #1850216
Change-Id: Iea601977851d5c4ea2b9b79071d94b2385637d57
2022-04-15 15:25:57 -04:00
Hervé Beraud f6121b5691 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.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: I7b12f467e329e2693e4c7349f328133a1ec3cb00
2021-12-15 10:28:37 +00:00
Zuul cdd9a7a4dc Merge "Stop to use the __future__ module." 2021-12-14 11:41:11 +00:00
Felipe Reyes 81c8cbf4a6 Add final dot when missing in nameservers
The configuration option nameserver expects each value to have a dot (.)
at the end, currently when this dot is missing the servers creation
fail, the error doesn't bubble up. On the neutron-api charm adds the dot
automatically when it's missing in the dns-domain config option, this
change makes the Designate charm behave in the same way.

Change-Id: If335c9b5b1b2adca3e39fa4f1d182dfbe362f874
Closes-Bug: #1952656
2021-11-29 15:43:22 -03:00
Xav Paice 3ae0be599b Add NRPE checks for services
Adds the nrpe-external-master layer and checks for services managed by
this charm.

func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/436

Change-Id: Ice5eada838626059f8cb2c427f7b9b0884317660
Closes-Bug: #1897809
Related-Bug: #1933643
Co-authored-by: Aurelien Lourot <aurelien.lourot@canonical.com>
2021-08-26 11:18:24 +02:00
David Ames 4e9d4756a2 Clear shared-db.setup when departing shared-db
When shared-db is rejoined the charm will reconfigure the DB IFF DB
related flags are cleared.

Change-Id: Ieb575d6aa220f10c519425f1e1a6f59e29c512f1
Closes-Bug: #1887265
2021-07-20 10:28:15 +00:00
Chris MacNaughton 5c929b3ba9 Request a restart of memcached after a service upgrade after queens
Change-Id: I54b235de947e63e3d7b86ccfdba9f1b968b75650
Closes-Bug: #1828534
2020-06-03 14:03:08 +02:00
Hervé Beraud b6d8796ce5 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: Idd8168f297ae3d969b4c52c93ecfbc7ef02bf791
2020-06-02 19:40:57 +02:00
David Ames 21db962b16 Use default_update_peers
Use default_update_peers which will publish admin, internal and public
addresses to peers. Remove duplicate update_peers from handlers.

Includes fixes for pep8 failures.

Change-Id: I89f2448b4deb71271f7ef0560d9a2607f21ae6c7
Closes-Bug: #1858132
2020-03-30 10:37:05 +01:00
Frode Nordahl 84ed3d8437
Enable default certificates handler
Previously the default ``certificates.available`` handler was
enabled without the charm authors intervention, this was changed
in I12f45236632b608e07fdd35d31b90b84ca92eb1f.

Change-Id: I1e3e0d417b11aeb75281345d575ae77270a1b5fc
2019-09-03 09:06:03 +02:00
Liam Young 66dab6d3e7 Ensure pool manager is restarted when pools change
The designate pool manager needs to be restarted on all designate
units when the update pools command is run with a new version of
the pools yaml.

Previously it was assumed that it was sufficient to trigger a new
hook execution but in the following scenario the update is missed:

1) Non-leader reacts to a change in pools and renders a new
   pools.yaml but does not run the db update as it is not the leader
2) leader reacts to a change in pools, renders a new pools.yaml,
   updates the db and finally sets pool-yaml-hash with the new
   value to trigger hooks executions on peers.
3) Non-leader reacts to leader db change, re-renders pools.yaml with
   the same values as step 1 and does not perform the pool manager
   restart even though it is needed.

The above scenario is fixed by adding a handler looking for a
change in the pool-yaml-hash and restarting the pool manager if it
changes. The leadership layer is needed to get the flags raised on
leader db changes.

The leader can also fail to restart pool manager as services are
restarted as soon as the config is rendered and before the
update_pools call is made. This scenario is fixed by adding a
handler to look for a change in the pools.yaml and restart pool
manager if it changes. This works because update pools is run in
the same handler as config render which means the new handler runs
after this render & update handler.

Closes-Bug: 1752895
Change-Id: I54b316788ea5176ca63ca761ceceb106ce903f3b
2019-04-09 06:34:03 +00:00
James Page 53c204a796 Drop use of 'amqp.requested-access' flag
In an amqp relation is removed and re-added, the charm won't
make a new request for access.  As the handler simply sets two
data items on the relation, avoid the use of the requested-access
flag.

Change-Id: Ibbffabe277adacf966443bae04a6a64a07964261
Closes-Bug: 1784076
2018-11-27 13:59:06 +00:00
Tytus Kurek 4f7c0a6e37 Add "also-notifies" option
This patchset adds "also-notifies" option which is an optional part
of the "pools.yaml" configuration and should only be used to define
DNS servers other than the backend servers which should receive
notifications on zone changes.

Change-Id: I10faa6ec4ea4fd1f1f17c7234662cd5c23624c1d
Closes-Bug: 1758008
2018-03-26 10:22:09 +02:00
Tytus Kurek ad34f1e889 Change pool manager cache driver
This patchset changes the default pool manager cache driver used by
the designate charm from "memcached" to "sqlalchemy".

Change-Id: If61a28f572137b0e3041d17bd9296929074faf7d
Closes-Bug: #1739012
2018-02-02 16:14:29 +01:00
Tytus Kurek 61ae382152 Designate - Neutron integration
This patchset implements Designate - Neutron integration feature
based on Neutron extension drivers. As a result DNS records can be
automatically created in Designate when Neutron ports or floating
IPs are created.

Closes-Bug: #1704769
Depends-On: I13b2ab39bd1daac13112398762f2be06022594b0
Change-Id: I001507eff6a3342cc77188e0f4087fa4fcc67b95
2018-01-18 13:49:27 -08:00
Tytus Kurek 9bc1b2c05b Implement "dns-backend" binding
This patchset implements support for "dns-backend" binding. Use the
"dns-backend" relation network space binding to populate the list
of dns master servers in the designate pool configuration,
ensuring that communication between master and slave servers
happens over the correct network space.

Depends-On: I927e3958cf929ace9d43f8b3d9509b90b9eab60f
Depends-On: Icbe0cc790c565f125f0fe8c903e9b755fe764d7c
Change-Id: I2c7b95e630611ac16c19e7f9efb81f54802849e9
Closes-Bug: #1722794
2017-11-13 11:30:43 +01:00
Liam Young 9bee68d19d Add memcache as the coordinator backend
Both the zone and pool manager daemons require a coordination
backend to be configured when there is more than one worker. There
is almost always more than one worker as the charm user a multiplier
based on the number of cpus to configure the number of workes.

This change adds the coordinator-memcached relation and makes is
compulsory for designate deployments.

Change-Id: Ic1b35e33ba9b6f015b199c35ccff64d626c29582
2017-11-02 14:10:30 +00:00
Alex Kavanagh 1ef3522f86 Do less work in the update-status hook
This patchset, along with the corresponding ones in charms.openstack
and interface-hacluster reduce the amount of work that the charm does
during an update-status hook.  This also fixes the issue where an
update-status hook triggered activity in the hacluster subordinate due
to data being set on the interface.  There is still work to be done in
this area, as the configs for the charm are still being written on every
update-status hook, although this doesn't result in a restart of any of
the services.  This probably requires a re-think of how the
charm-helpers function runs; patch to charm-helpers coming up soon.

This also fixes bug 1712973 where the update-pools command with empty
pools errors causing the charm to error out and fail.  This is
undesirable, so this condition is caught and logged instead.

Change-Id: I6db68a479dc903ce620ba62c1898247f71d14701
Depends-On: I3717387d1d8d2ab875d51f262efd1df7f2529689
Depends-On: I750f3c41a2f0447a47cfd19bab1d4958de4577f2
Closes-Bug: #1708396
Closes-Bug: #1712973
2017-08-31 10:28:58 +01:00
Alex Kavanagh fd98fa0722 Resolve config option dns-slaves not working properly
The charm didn't work unless a mandatory bind-rndc interface was
present.  However, the dns-slaves option was supposed to provide an
alternative to needing to relate the unit to the (say) designate-bind
charm.  This change allows dns-slaves and/or a bind-rndc relation
and configures the underlying service accordingly.

Also some fixups to the tests to simplify handler verification using
more recent charms.openstack features.

Also note that the bind-rndc interface needed a fix (the depends-on)
for if/when a bind-rndc relation is removed; the interface incorrectly
maintained that the relation was present when it was not.

Change-Id: Ib2c883e623292520224f882aef09d3710e1e1348
Closes-Bug: #1693162
Depends-On: I523fecff4e80734772872a8a6d2507f1e2162ae3
2017-05-31 17:44:57 +01:00
Alex Kavanagh e36573791b Use charms.openstack charmhelpers test_mocks
Every reactive charm that uses charms.openstack and implements unit
testing needs to mock charmhelpers, as otherwise the tests blow up.
This patch uses the mocking of charmhelpers in charms.openstack so that
a charm layer can just import test_mocks and charmhelpers will be mocked
out along with setting up a default
charmhelpers.c.o.u.OPENSTACK_RELEASES so that when an OpenStackCharm()
derived charm class won't fail on definition.

Change-Id: Ibe30604dd53a47ac382438fc23c6b61016f62079
Related-Bug: #1693017
Depends-On: I5ac40617ee30e5f421ec16fc7592177a5e6aa166
2017-05-24 20:59:07 +01:00
Jenkins cf8dd4fd66 Merge "Replace assertEquals with assertEqual" 2017-02-10 21:19:00 +00:00
James Page 42609d7cef Fix support for network-spaces
Drop provision of hostname parameter for mysql-shared/shared-db
relations; newer interface versions automatically set the
hostname parameter based on Juju 2.0 network space bindings or
the units private-address in older Juju versions.

Change-Id: I55ff32c26478399fd8486ce0a618ad1a80b6476b
2017-01-26 10:29:31 +00:00
Liam Young c46a805a1b Fix unit tests (lower layer changed)
Due to a change in a lower layer additional calls needed to be
mocked out to fix a broken unit test

Change-Id: If05a0c2e0d58d7002d0a2436a8f955acd0775923
2017-01-19 13:25:47 +00:00
Nam Nguyen Hoai 903d42c090 Replace assertEquals with assertEqual
The method assertEquals has been deprecated since python 2.7.
http://docs.python.org/2/library/unittest.html#deprecated-aliases

Also in Python 3, a deprecated warning is raised when using assertEquals
therefore we should use assertEqual instead.

Change-Id: Iac491ecdefa638664f515b15724ddbfffba3d25a
2017-01-17 14:42:38 +07:00
Jenkins 16107f92a9 Merge "Change assertTrue(isinstance()) by optimal assert" 2016-11-30 12:32:57 +00:00
Liam Young a5e874b91c Upgrade Openstack release if available
If there is a new release of the designate packages available due
to the user changing the 'openstack-origin' option then upgrade
the packages.

Closes-Bug: 1632760
Change-Id: If2aedac6de0a76bd8e081ba1313cf72887f6978f
2016-10-12 16:38:28 +00:00
gecong1973 0dc1ff03f7 Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of
assertTrue(isinstance(A, B)) or assertEqual(type(A), B).
The correct way is to use assertIsInstance(A, B) provided
by testtools

Change-Id: If16d3c28a7c0d40b291f5f59d7413d401acd0502
2016-10-08 12:03:25 +08:00
James Page 06d7b798f8 Rebuild with new charms.openstack
Pickup changes to charms.openstack including application-version
support for Juju 2.0.

Fixup unit test failure due to charms.openstack changes in adapters.

Change-Id: Ia681fab88900494b1942e6b41114055db9f7b4f6
2016-10-05 12:09:22 +01:00
Alex Kavanagh 4e8b851f1e Delete *.pyc files from repo and add ignore to .gitignore
There were a bunch of .pyc files in the repository, so this patchset
removes them and adds a *.pyc to the .gitignore

Change-Id: Ib53bc1516d159c975b03a78b5762519519668828
2016-08-26 10:34:07 +00:00
Liam Young 4a9444a673 Make domain config mutable
Previously domain config has been immutable. Meaning that it could
be amended or set for the first time post deployment. This change
fixes that. In the process some other enhancements were made.

* Create and use check_zone_ids contextmanager to detect if domain
  ids have changed. If they have then update peers via leadership db.
* Rendering all configs is now a two stage process.
  render_base_config is called first to ensure that the Designate API
  servce is up and configured as the sink configs query the designate
  API to retrieve the domain ids for the neutron and nova domains.
* designate_handlers.py has been simplified to reduce the number
  of handlers and stop gating on domains.created which previously
  made domain config options immutable.
* templates/novarc was hard coded to use http. this has been updated
  to set the protocol based on whats passed back from keystone.

Change-Id: I477ad22bf9131672f6521d6afbf6f16a01d8b112
2016-08-01 11:31:22 +00:00
Liam Young a1d0b7aaa2 Render configs always needs the cluster relation
Render configs always needs the cluster relation if it is available.
There is logic in OpenStackAPIRelationAdapters that checks to see if
this unit is alone. If it is it creates a 'cluster' namespace and
populates it with data specific to this node.  If this unit has peers
then OpenStackAPIRelationAdapters populates the cluster namespace with
PeerHARelationAdapter *if* a cluster relation has been passed in. If
the unit has peers but the Peer relation has *not* been passed in
there is no cluster namespace and rendering of config that relies on
it (namely haproxy) fails.

To fix this, check if the relation exists and if it does add it to
the list of relations used to render configs

Change-Id: I6f34c28411db957d0b55155b8671bf981084bb6b
2016-07-27 15:24:14 +00:00
Liam Young a4cb37b0b9 Fix bad config defaults
* Remove strings used for testing from config.yaml defaults
* neutron-* and nova-* config options are no longer compulsary. These
  are only needed for automatic generation of records when guests are
  booted or floating-ips associated. Manual management of records is
  a valid option.
* Add assess status to catch the situation where neutron-* or nova-*
  variables have been set but nameservers has not. In thios scenraio
  the domains cannot be created as there is no server defined.
* Extend amulet tests to create a server as well as domains
* 'domains' no longer resolves in sink file regex and has been
  replaces with zones
* Add missing relation for auto-generated nova records
* Rename dns-server-record config option to nameservers which is more
  consistant with upstream docs. Unused old 'nameservers' property
  needed to be removed to allow this

Change-Id: Ibd58aa8ffb3931a2fb359fad6292a9d33775a0f8
2016-07-26 09:02:34 +00:00
Ryan Beisner 3fd2b6a0a4 Add .gitreview and clean up repo
Add src/README.md placeholder to prevent inheritence of the
base layer's readme file in the built charm.

Use the official charms.openstack repo in test-requirements.txt.

Use official designate-bind charm location in the Amulet tests.

Remove upload-and-publish so as not to encourage out-of-band
pushing and publishing.  That is handled by CI.

Fix a test filename typo.

Add tests readme.

Update tox.ini for Amulet environment variables.

Update metadata.yaml, removing EOL release and adding tags.

Fix unit tests

Change-Id: If842a5409c2d284bc118d70d6e8caba7cb6205c3
2016-07-22 12:01:10 +00:00
Liam Young 335fd1501c Unit tests fixes and pool updates 2016-07-13 10:08:04 +00:00
Liam Young 2cd20a2004 More unit tests 2016-07-07 18:01:04 +01:00
Liam Young f082c343b4 More unit tests 2016-07-07 15:00:15 +01:00
Liam Young be8cee7db2 Unit tests and lint fixes 2016-07-07 09:36:22 +01:00