31 Commits

Author SHA1 Message Date
Ian Wells
c8d15c9bcc Remove six
Six is Python 2 and 3 compatibility.  It is no longer needed now that
we're purely py3.

Change-Id: I28a6f8539b3b3ce35221728ec631380a18c921b3
2020-07-27 23:15:31 +00:00
Ian Wells
ef2b77f99b Bring hacking up to spec
Our version of hacking was ancient, and it loads a pep8 check that
is both very inconsistent in reporting errors and has weaker
constraints.  Fix the pep8 errors revealed and disable some of the
irrelevant tests in tox.ini.

Change-Id: I4ca71aa88456e4ac2baf0cfb3ac058b0a19e3b6b
2020-07-24 10:44:11 -07:00
Ian Wells
d1c078ca2d Add mypy typing information
Some minor updates to certain functions to allow mypy to work, but
largely a matter of adding formatted typing comments that mypy can do
static typing against.

Change-Id: I65e88ba493599091fa657181f3f3ad5595dacbe1
2019-03-28 17:54:24 -07:00
Yichen Wang
92c949db78 Mask password for accessing etcd in oslo logging
Change-Id: Idb4f240015eb70f965e3c7f8dfdaa60f95a585ae
2018-07-22 18:39:26 -07:00
Ian Wells
f66542c203 Remove anti-pattern from etcd signing code
The 'SignedEtcdJSONWriter' is, depending on config, a 'signed etcd json
writer' or 'a proxy to the unsigned etcd json writer'.  The two classes
should be instances of the same base type and the correct one
instantiated based on circumstances.

This change converts users of the JSON writers to use a function that
instantiates the right JSON writer based on circumstances.

Change-Id: If01c68d93d06c62bea8e55568d5049a3aa8c2c97
2018-06-07 10:31:28 +00:00
Naveen Joy
afca4cacba Update the GPE etcd key format to handle vpp-agent restarts correctly
Correctly handle mac-address changes during vpp-agent restarts
by removing the mac-address of a port from the etcd key.
The port mac-address could be computed dynamically by the vpp-agent
and could change after an agent restart. If the mac-address is
present in the etcd key, it results in duplicate GPE keys and GPE
stops working. This patch resolves this issue by removing the
mac-address from the key and storing it in the value.

Closes-Bug: #1761023

Change-Id: I3f1f4168f0c77080edc076bbb660021b81fb62dc
2018-05-01 11:47:39 -07:00
Zuul
b5b09e4e71 Merge "Enable Oslo config generator by adding entry point" 2018-03-23 17:39:35 +00:00
Ian Wells
bb5ef55078 Fix problems with etcdutils
A problem with the 'get_subtree' method resulted in use of .children
returning native EtcdResult types with no augmented parsing of data.

There are a number of attributes that ParsedEtcdResult didn't expose but
there's no reason they shouldn't be exposed.  These have been added, in
case future code depends on them.

Change-Id: Ia879d4e97d8bdbef835202507a9a2d662611c163
2018-02-06 20:18:09 +00:00
Ian Wells
f2235d041b Enable Oslo config generator by adding entry point
Change-Id: Ic5c484cfd102db594703748e2552c34c0b51e961
2017-12-12 15:29:53 +11:00
Ian Wells
426ee0540f Add compatibility for ml2 config module
This recently (Pike-Queens) moved from neutron.plugins.ml2.config to
neutron.conf.plugins.ml2.config and this patch adds a layer in compat.py
to insulate us from that, and also rejigs ml2_vpp config so that the
options for etcd live nearer the code that uses them and in general all
option registering works in a similar fashion.

Addresses-the config problems that were band-aided over in change
Idbf622591e8d92d8e29e3a92799d0e7ff460354a.

Change-Id: I18767336f05a0fdcebfe16ddd46c2a5325d4e661
2017-10-11 08:26:40 +11:00
jb
01d09e80d7 ETCD message signatures
The etcd messages are (optionally) stored as JWT (JSON Web tokens) with
RSA signature and X509 certificate.  It guarantees the authenticity of
the etcd messages.

Change-Id: Iaa1a70a7e87b935b6ff48e2b1f27784ed27ecc97
2017-10-11 07:35:33 +11:00
Naveen Joy
5b0b6648c1 Remove empty GPE directories in etcd after port unbind
This patch fixes the bug in which GPE key_space directories were
left behind in etcd after a port was unbound. It removes the empty
etcd directories and cleans up etcd.

Closes-Bug: 1710737

Change-Id: Ie146dcbee18da1e236e004dd7e2ab6719d6aca0e
2017-08-15 15:40:12 -07:00
Ian Wells
dab6fee851 Force init_resync_start's return value to a set()
This stops a resync crash on startup.

Change-Id: I4f765265bc16c8cb329beae3ba4632660d6f3a43
2017-07-31 15:42:53 -07:00
Ian Wells
5809568527 Fix default resync code to actually resync
Previously the code skipped resync due to an indentation error.

Change-Id: I715835b324b9b89ee4d1d173cc17d469aa8d2b9c
2017-07-29 17:47:54 -07:00
Hareesh Puthalath
43174e8005 Forward worker election refactoring
Ensure that we grab the election for a certain time before proceeding
with jobs that can take extended periods.  This ensures that the election
does not expire (which would let another thread become master).

Adding a configurable values for various timeouts and general refactoring.

Change-Id: I480a4ec44b571c24fcf42520220de0439743ef81
Closes-bug:#1694723
2017-07-21 12:34:15 -07:00
Ian Wells
3d690a55de Remove the agent's 'utils' and 'exceptions' modules
The utils module contained a number of originally general purpose
functions, but they ultimately ended up being all about etcd.  The
exceptions were also exclusively about etcd and its config.  The
two modules have been combined with etcdhelper and networking_vpp's
own exceptions module.

Change-Id: Ieaa574cf7b335c43062419845e9ebd96a38b4bdb
2017-04-26 04:07:22 +10:00
Ian Wells
29c817eb70 Align with neutron_lib standards
This is imperfect, because our compatibility layer that allows
us to work with older versions doesn't cover all the necessary
Neutron inclusions, but excluding N530 we have a pass.

Changes fit into categories:
- LOG.warn -> LOG.warning
- log messages now have kwargs if more than one argument
  (not essential, but used to be for translation and seems
  to be a good practice anyway)
- exception messages must be translated
- translated messages must have named positional arguments
- oslo_serialization.jsonutils must be used, not json
- [] can't be a default argument
- compat is marked with N530 as, there, neutron imports are
  expected.  In other places the mark has been left off, and
  the tox check has been disabled (for later enablement via an
  RFE)

This should not include changes outside of that set.

Change-Id: I1dc050f83a5199bf40117eac6c9adae221ae6857
2017-04-25 18:37:09 +10:00
Ian Wells
ada0826bba Tidyups in loop wait
Change-Id: Icf1382b390c24b4aaf4db4fdbde8094ea34d173e
2017-04-25 17:46:01 +10:00
Ian Wells
b4eb7581a3 Automate some of the resync behaviour
This still doesn't break backward compatibility, but
makes the resync_end default behaviour sane - a removal of
keys that we know are known by the controlled element but are
no longer in etcd.

Change-Id: If9c6c2a1445a301ba7fd101c3b171e7955d17568
2017-04-20 03:55:18 +10:00
Ian Wells
dd2d0a863e Comment fix
Change-Id: I5b2efe7ce1b8a7caf4e287689cc4b973f3924a31
2017-04-12 06:47:59 +10:00
Ian Wells
f7265f48b3 Add functionality to etcd watchers for initial resync extra code
This enables resync on restart.

Change-Id: I319d6ef8b9987bf4379756bb4afdbe377e700c8f
2017-03-29 21:02:51 +11:00
Ian Wells
ed85ddb18a Change EtcdChangeWatcher to have a nicer API
Change-Id: Ifc1c6dfa6732a92ded838d5fd48f2fafce64d4d1
2017-03-29 21:02:47 +11:00
Kahou Lei
5380c31a28 Predefine rv to avoid unknown variable exception
If etcd client has connect timeout, rv is never defined and vpp-agent will
throw exception afterward. This patchset is to predefine rv to avoid
unknown variable exception.

Change-Id: I8cc6ddd86ed3579da06d623d847b262bbd186be4
2017-03-18 05:04:00 +00:00
Ian Wells
e030e21c35 Add new etcd watcher model
This addes a new subclass to EtcdWatcher that attempts to analyse
changes in etcd itself, regardless of whether a watch or resync
happened, and will then pass on the calls to its listening function
according to what is different.

This has the advantage that resyncs because of history problems,
syncs because of initial setup and watches are all reduced to the same
problem.

This makes the system more susceptible to port-bind-before-secgroup
problems.

Change-Id: Ib49a5efde84171a387d2ba468bb16999a42db56f
2017-02-24 00:48:32 +00:00
Ian Wells
73dab83797 Election fixes
- Remove wait_until_elected argument to EtcdElection creation

  This argument was removed in a previous patch but not from one
  specific call - remove it there so that the election works.

  The default and now only behaviour is wait_until_elected, so we will
  get the same behaviour here as we did before when passing =True.

- Separate election and watcher types

  Watcher is-not-an election; watcher uses-an election

- Change the recovery and the job time

  Watches are timing out because we spend more time in the work than
  the expiry time of the key

- Stop clearing the key space on mechdriver restart

  Multiple Neutron processes on one or multiple hosts may be running,
  so previous elections should be respected.  We can't assume that the
  reset of this neutron process has removed an elected thread.

- Add debug to the election process

- Move thread_id into the EtcdElection

- Make the journal draining thread kick work across hosts and processes

Change-Id: I84a2c543aceea3ceb096b4ef5ed1aa46a47ca3c8
Closes-Bug: 1666308
2017-02-23 09:02:30 -08:00
Naveen Joy
5b98a1a42a Resolve too many threads running on the etcd and DB journal
Closes-bug: #1644371

Implement an election algorithm to elect two threads
as masters for doing work - one for DB journal (forward workers)
and the other for etcd (reverse workers). The threads that are
not elected as master go to sleep and check if the master is
alive periodically. If they cannot detect a master, a new master
is elected to do the work.

Change-Id: I13a4dbe4e58c8156231acf7fab2ca293f7b4e4cb
2017-02-10 20:50:49 +00:00
Christophe Fontaine
f8143539f2 Use embedded etcd client timeout
Change-Id: Iceb9dadf7b80538cb2215947f9480fb78905d0ac
Closes-bug: #1657345
Signed-off-by: Christophe Fontaine <christophe.fontaine@qosmos.com>
2017-01-20 20:01:54 +01:00
Ian Wells
55b48c7a3d Fix bug with debug log message formatting
Tuple in place from move from % to , on the log call, and this means
we're an arg short.  Simple typo.

Change-Id: Ie4f1beaa758cce2e4fc190eec4d57f377d71fde4
2016-12-01 20:51:11 -08:00
Ian Wells
359171ca5e More removal of '%' operator from log messages
LOG.xxx will do the substitution for us, and this is preferred.

Change-Id: I38b5b6f9399ca3e99fe96361708c8d1bfc58d523
2016-12-01 18:54:00 -08:00
melissaml
38f3ea8a98 Modify variable's using method in Log Messages
String interpolation should be delayed to be handled by the logging code,
rather than being done at the point of the logging call.
Ref:http://docs.openstack.org/developer/oslo.i18n/guidelines.html#log-translation
For example:
LOG.info(_LI('some message: variable=%s') % variable)
LOG.info(_LI('some message: variable=%s'), variable)

Change-Id: I1cdd1eb10aa6ea59461436b91cc966606f7358c2
2016-12-01 18:39:37 +08:00
Ian Wells
5ae4ef6b41 Reformulate the etcd read/watch loop as common code
We've already found several interesting ways to add race conditions
to the watch loop, and additionally resyncs are a little hard to
grasp; pull the code out to a common location so that fixes benefit
all watchers and new users don't make all the rookie mistakes.

This includes fixes to address the race window between startup reads
and the first watch.

Change-Id: I55846b346644bb33179ed77979409d38c93fd6a5
2016-11-28 18:18:36 -08:00