Commit Graph

187 Commits

Author SHA1 Message Date
Harry Rybacki 265146ed2e Become 1.3.0
Change-Id: Ia5d9f82219ceffd50e5d1b3f3be3c216a63e2e74
2019-12-17 09:43:36 -05:00
Harry Rybacki a71617627a Add locks to cache and cleanup kinit logic
After reviewing reports of multiple CCache cropping up in logs, we
found an issue in the way novajoin is initiating and updating
cache files containing keytabs. The result was numerous extra cache
files being created and overwritten.

With this change we ensure that the credentials cache is properly
shared across workers and that when new credentials are being
created, the cache files are locked to avoid potential conflicts.

Updates DEBUG level logging to include useful cache troubleshooting
breadcrumbs.

Change-Id: I07e0004f77e0d52ab2a2707c5fe50f48f718b717
Co-Authored-By: Ade Lee <alee@redhat.com>
2019-12-09 13:21:15 -05:00
Ade Lee e418762753 Conditionally import nss
python-nss does not exist (and is not needed) in RHEL8.
We need to conditionally import nss to avoid errors in RHEL8.

Change-Id: I699fbfab4c2106f24260c99905b1bd40a8e683a8
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1758771
2019-12-04 16:35:04 +00:00
Harry Rybacki c9299d5c37 Add configurable delay to connection rety attempts with IPA
Presently, when novajoin fails to make a connection with the IPA
server, for any reason, it will immediately re-attempt to make
the connection when the backoff is unset (it is off by default).
As a result, any timing related issues could be the source of
the connection issues will likely result in no connection at all.

This change adds a new configuration option, retry_delay, which
will halt subsequent connection attempts for N seconds where N
is the retry_delay. By default this is set to 5 seconds, mirroring
internal ipalib behavior[1].

[1] - https://github.com/freeipa/freeipa/blob/master/ipalib/install/kinit.py#L29-L30

Change-Id: Iec96e4bd6643c0a657c8db424cc72deb10f170bd
2019-10-21 10:21:51 -04:00
Harry Rybacki b971c7836f Become 1.2.0
Change-Id: I5b26e62b0de1204284b30a0dc972e1dd6534f608
2019-09-12 13:16:39 -04:00
Harry Rybacki 4f1353bb1f Handle add_host and delete_host cases more robustly
Presently novajoin has no way of differentiating between hosts and
hostnames. As a result, it is possible for a host to be inadvertantly
deleted in certain conditions.

This fix aims to resolve this and other join/delete edge cases  by
passing the instance-id (server uuid) from nova along in the
description field that is passed to IdM. We can use this
description and id to ensure we delete only the hosts we meant to.

Overview of changes:
- Persist nova instance-id in IdM's Description field
- Update join logic to handle hosts with old Description field
- Update join logic to cause nova deploy failure when attempting to
  add a host with a hostname that is already enrolled
- Add new DuplicateInstanceError exception type
- Add new DeleteInstanceIdMismatch exception type
- Add inline comments documenting code flow
- IPAClient add_host doc strings for clarity

Change-Id: I676bac162a6ec35366c506bdb660cf3913131afd
2019-09-12 09:26:39 -04:00
Zuul 6be279e35b Merge "Update Fault class to pass error key up" 2019-09-12 06:42:31 +00:00
Zuul 0bcb4ec41b Merge "Fix error message when OTP is missing, add logging" 2019-09-11 20:32:33 +00:00
Zuul 366480da1a Merge "Additional logging in functional tests" 2019-09-11 20:32:32 +00:00
Harry Rybacki 657e75c5e1 Update Fault class to pass error key up
While debugging nova-compute logs it was noted that error messages
were not being populated rather the fault_name was. Updating the
response we hand back to Nova to contain message within the
'error' key of the returned object.

Change-Id: I2e0f415a512e53261b1e366cd75b310dd06eec27
2019-09-11 14:12:02 -04:00
Zuul f32dd28f2e Merge "Fix IPAConnectionError string formatting" 2019-09-09 17:28:45 +00:00
Harry Rybacki 051f8ef9f6 Fix IPAConnectionError string formatting
Exception message had incorrect string format that would result
in a TypeError being raise if/when this exception was caught.

Change-Id: I676631d79394e512371a8367f84b91761e983faa
2019-09-08 11:45:43 -04:00
Harry Rybacki 5b6b8607ec Log statement missing string replacement arg
Include missing arg

Change-Id: Ic494e58fc3b1f74f574e0dd8255ddc36ad2249c9
2019-09-05 15:46:40 -04:00
Grzegorz Grasza 956cc87cc1 Fix error message when OTP is missing, add logging
* Fix cloud-init error message when OTP is missing
* Add a log message in novajoin-server

Change-Id: Ib299269c564744af6a5fcded9195d27be1c14ce7
Related-Bug: 1836529
2019-08-30 14:57:13 +00:00
Grzegorz Grasza 610e03d33b Additional logging in functional tests
Print setup-ipa-client.log in case the enrollment test fails.

Change-Id: I8980da9da9e9edfc95c58345bff7bde722677f81
2019-08-30 14:57:03 +00:00
Ade Lee ade787b90c Add debug messages
We are having a hard time keeping track of which operations
correspond to which request.  This patch adds the ability to track
operations in the notifier with the message_id of the notification
being processed.  This message_id (which is generated by oslo is
a uuid

For the server, we could also set the message_id to the request_id
of the python-requests object received, but this is already
logged as part of the server logs.

Change-Id: Ie8b885a2b5cba6684e92c49eed4a99d24621402e
2019-08-22 07:54:17 +00:00
Ade Lee 9750c363f6 Refactor method names
Debugging is confusing when the same names are used for methods
in two different controllers.  Fixing this to more accurately
reflect whats going on.

Change-Id: I3740cd3ae81776cb1ecf066e617e615d880dc2e8
2019-08-20 11:02:18 -04:00
Ade Lee 6ed30c9476 Fix backoff mechanism
Right now, the backoff mechanism is broken when the backoff is
set to something non-zero.  Basically, you go into this state where
you retry ad infinitum, leading to inconsistent behavior.

This change fixes the mechanism so that you only get a fixed number
of retries.  You can choose (through a new config parameter) to allow
backoff (or not).

To restore some of the old behavior, the default for the connect_retries
parameter has been increased from 2 to 4, and the max backoff time has
been decreased from 1024 to 512 seconds.  Its unlikely that we'd ever
reach that backoff time without a large number of retries, but 1024
seems too long.

And there is a new exception that is thrown when the connection
fails.  This will result in nice 500 errors in the novajoin-server,
and some log messages for the notifier.

Change-Id: I10547fbde8966c8694346ed8c054e627bee2ee51
2019-08-20 11:02:07 -04:00
Grzegorz Grasza 74fd4c4357 Become 1.1.1
Change-Id: Ia5483264808812e8b7550aa44240d05c9b7337de
2019-02-07 19:33:24 +01:00
Zuul b0d81f8c86 Merge "Remove unneeded call to nova API, defer other API calls" 2019-01-31 19:17:44 +00:00
Grzegorz Grasza fe512714e2 Fix for ipalib 4.7.2 (Fedora 29)
This fixes u"unknown command 'b'xxx''" errors.

Change-Id: I155bd37e7007fce4e083f8e5f7c4a3511a44ae4a
2019-01-29 15:12:56 +01:00
Grzegorz Grasza db868ea7c1 Remove unneeded call to nova API, defer other API calls
We get an instance ID directly from nova, which calls our API,
consequently we don't need to call back to nova to double check
if the instance ID realy exists.

Additionally, defer calling keystone and glance APIs to the moment
that the retrieved objects are realy needed.

Change-Id: I64a20c88229490690798aaf75ca0d96d98032467
2019-01-29 15:09:16 +01:00
Juan Antonio Osorio Robles 5633d348e3 Change default policy to check service project and not role
In TripleO and devstack alike, service users are part of the "service"
project; while TripleO doesn't have a "service" role. So lets depend on
the project to enforce policy. This way this will still work out of the
box with TripleO.

Change-Id: I01cf7b38904bb0311658348dcdc0b0efd4f36c0e
Closes-Bug: #1812844
2019-01-22 16:31:59 +02:00
Grzegorz Grasza 462305315c Check policy when handling a HTTP request
* Add default policy for handling the create request.
* Allow it to be accessed only by nova service.
* Remove unused code copied from cinder.

Change-Id: Ieaa407f27c6774d1fd17850a9571de5554360bae
2019-01-18 11:27:09 +01:00
Grzegorz Grasza b3f961e331 Become 1.1.0
Change-Id: I38e1cb161dabec02de72a7d22cb1ace7cda6f142
2019-01-08 13:54:33 +01:00
Grzegorz Grasza ff9ed8461e Fix StringIO import and patch paramiko in Python 3
This fixes ModuleNotFoundError: No module named 'StringIO',
raised in Python 3 functional tests. We also patch paramiko
on Python 3, since we use it in functional tests.

Change-Id: I357dd9c3ec7c0a76d31b7f94ec0e844d9bdcb5c5
2018-12-20 15:55:51 +01:00
Zuul 59b91ceebf Merge "Test compact_services metadata" 2018-12-19 20:50:58 +00:00
Zuul 43cf3a0b43 Merge "Reconnect on httplib.ResponseNotReady" 2018-12-19 19:45:59 +00:00
Zuul 6a1f2e1a87 Merge "Fix errors preventing novajoin to start on Python 3" 2018-12-19 19:45:58 +00:00
Grzegorz Grasza f5aab5544d Test compact_services metadata
This tests new and old formats, as well as instance metadata updates.

Change-Id: Ie7b3bcdbb98bb2786000207b72e7b289d5051b8f
2018-12-19 20:39:53 +01:00
Grzegorz Grasza 62475be1c2 Enhance the basic enrollment test
This additionaly logs into the server instance and
checks the IPA client configuration.

Change-Id: Ic249032e9241f13c843119f798efbe598a62c88e
2018-12-19 16:27:31 +01:00
Ade Lee c75c4c05a1 Become 1.0.22
Change-Id: I2a44e1e52317c1bf05aa76e07c7bd5283521e02e
2018-12-13 00:05:49 -05:00
Douglas Mendizábal 2c0091d23d Handle compact services on multiple lines
This patch adds logic to handle compact service metadata that
has been split into multiple lines to avoid hitting the metadata
size limit.

Co-Authored-By: Grzegorz Grasza <xek@redhat.com>
Change-Id: Ida39f5768c67f982b2fe316f6fae4988a74c8534
2018-12-12 20:56:16 +00:00
Grzegorz Grasza f8036d01a5 Reconnect on httplib.ResponseNotReady
In CI we get a random ResponseNotReady exception,
which is caused by the server closing the keepalive socket.
This will close and retry the connection.
This patch adds this reconnect in a second place that was missed.

Change-Id: I745aea8dcb51598ca7d7a371dce66c7dd6ae8005
2018-12-03 16:38:53 +01:00
Grzegorz Grasza ed1838b7af Fix errors preventing novajoin to start on Python 3
This patch also moves the novajoin-install and novajoin-ipa-setup
scripts to the default python scripts directory. This is because
there is no other way to fixup the #! line for python3, apart from
modifying setup.py, which is managed by the global requirements repo.

Change-Id: I21ccb475905feebdb91aa158ce3845744b2f0a5f
2018-11-26 17:55:15 +01:00
Grzegorz Grasza 609f6e2b2b Support versioned notifications
Support nova versioned notifications. Unversioned notifications
are still supported and the default. The CI is configured to test
versioned notifications, and both implementations use the same methods.
Because of this, testing versioned notifications also covers
unversioned notifications, since the execution path flows through both.

Change-Id: If028afa9e9fbcb344786cd287605e0d9af5d3c01
2018-11-26 10:57:26 +01:00
Grzegorz Grasza 4d997dddc6 Support for associating and disassociating neutron floating IPs
This adds support for creating and removing DNS A records when
floating IPs are associated and disassociated in neutron.
novajoin-install and functional tests are enhanced to test it.

Change-Id: I82c83ad9e8c84ddfd4ecfc4d5c3b31a418af97a7
2018-11-22 15:40:05 +01:00
Grzegorz Grasza 7fa5789e51 Refactor notifications
Make a registry of different types of processed events
instead of an endless if/elif clause.

Change-Id: I34ebdca82810b9abd46a84aca7f1a8febf718be6
2018-11-22 12:28:50 +01:00
Grzegorz Grasza fe72231faa Test OpenStack server instance enrollment
A basic test to check that a spawned instance
will be added to and than deleted from FreeIPA.
This also fixes the novajoin-install script to
work by default on devstack.

Change-Id: Id7e940360ade74d605fef9004c6a5454790c55a4
2018-11-20 20:01:06 +01:00
Grzegorz Grasza e8ced3d13c Reconnect on httplib.ResponseNotReady
In CI we get a random ResponseNotReady exception,
which is caused by the server closing the keepalive socket.
This will close and retry the connection.

Change-Id: I28e51450cbfea8bf7a18e5783355b68f806eb999
2018-11-13 12:33:20 +01:00
Ade Lee fde8eb6867 Become 1.0.21
Change-Id: Ibc015732185781c8b6a213794b828a5a759381a7
2018-11-09 13:46:09 -05:00
Grzegorz Grasza 2ffc08c544 Move test_ipa_integration to functional tests directory
Since novajoin integrates Nova with FreeIPA, functional tests
won't be able to run without FreeIPA. Therefore, we want to run
integration tests together with functional tests.

Change-Id: I93a3ef03b8bf2141710602fd8ba5f01098767fe3
2018-11-06 13:27:36 +01:00
Ade Lee b74cae51e3 Fix novajoin-ipa-setup to set logging correctly
In freeipa f62a0fdb904d2a4bb1961847e240dbb6df3b0b67 the IPA
client library was modified to remove the log_manager.  This patch
fixes the novajoin code for all versions of IPA.

See rhbz# 1644747

Co-Authored-By: Juan Antonio Osorio Robles <jaosorior@redhat.com>
Co-Authored-By: Grzegorz Grasza <xek@redhat.com>
Change-Id: I2da12bedfc8790ebd1005c98f2e05953d127b3b9
2018-11-04 11:39:59 +01:00
Grzegorz Grasza 01be20f981 Run pep8 tox env with python3 interpreter
This changes the pep8 environ to run pyflakes3 and
fixes python3 compatibility errors.

Change-Id: I2a57966cd60fbc54be1f07a2505ff029ab8dda41
2018-10-24 16:16:47 +02:00
Juan Antonio Osorio Robles 0b05c95388 Become 1.0.20
Change-Id: I4107242b32f889e03f42f6eb361b3a4564cbbfec
2018-10-23 09:40:55 +03:00
Harald Jensås 96ab6fd525 Fix - Invalid ipaotp returned if host in cache
Change: Id107000b3a667f5724331e281912560cff6f92f0 implemented
caching in the IPAClient. We need to store the OTP in the cache
and return the cached OTP, not the one generated on the join
request in case there is a cache hit, since we do not update
the OTP in FreeIPA when the host is in the cache.

Closes-Bug: #1796415
Change-Id: Ic19ee7c2228d275397bc4be04432126fd2f228ec
2018-10-06 01:01:32 +02:00
Ade Lee 3d58511664 Become 1.0.19
Change-Id: If4c572071d6e6337146316d31ec95e0c80e4f92b
2018-08-24 13:39:43 -04:00
Juan Antonio Osorio Robles 12552eb4d0 Become 1.0.18
Change-Id: I0614372265510b3f210a9465a4689822e134d768
2018-02-22 15:57:05 +02:00
Juan Antonio Osorio Robles 6ce780fc90 Add basic service and host caches
This adds two caches: one for hosts and another one for services. The
service cache also contains which hosts are managing the service.

This was done in order to reduce the calls to FreeIPA and to try to make
novajoin slightly more efficient.

Note that this was only added to the "add" functions, and the delete
functions merely update the cache. This is because checking for hosts
managing a group would require the cache to be consistent between all
the processes (and novajoin could be ran in several), and for this the
best thing would be to use a distributed cache. Being this the first
attempt, we leave this functionality out of the scope for this patch.

Change-Id: Id107000b3a667f5724331e281912560cff6f92f0
2018-02-09 17:36:28 +02:00
Juan Antonio Osorio Robles e2a15af973 Implement updating services based on update notifications
This implements adding additional services via the metadata interface by
reacting on the compute.instance.update notifications. This effectively
covers updates from already enrolled nodes with some services towards
adding new services.

Note that this still requires folks to remove services manually if
they're no longer used.

Another important thing to note is that this doesn't yet cover updates
from non-enrolled deployments to enrolling them and adding services.

Related-Bug: #1715295
Change-Id: I48ab94a184657f6730281740935a05143abbc499
2018-02-06 13:13:47 +00:00