Cedric Brandily [Tue, 26 May 2015 12:29:15 +0000 (14:29 +0200)]
Enable random hash seeds
Neutron tests have been updated in order to support random hash seed. It
allows to remove PYTHONHASHSEED=0 in tox.ini and remove hashtest tox
environment.
Joe Gordon [Fri, 29 May 2015 21:28:34 +0000 (14:28 -0700)]
Fix formatting of core-reviewers doc
Fix some RST formatting issues with the core-reviewers policy document.
When reading the RST rendered version of that document at
http://docs.openstack.org/developer/neutron/policies/core-reviewers.html
I noticed a few rendering issues where were bothering me, so I fixed
them.
Adrien Vergé [Fri, 29 May 2015 20:54:33 +0000 (22:54 +0200)]
Get completely rid of contextlib.nested
`contextlib.nested` is deprecated since Python 2.7 and incompatible with
Python 3. This patch removes all its occurences by using the helper
script at [1].
This is a necessary step to allow us running all unit tests with
Python 3 (not just a small subset as it is done now).
Adrien Vergé [Mon, 25 May 2015 16:46:03 +0000 (18:46 +0200)]
Fix indentation errors in tests
They are some missing/extra indentations in tests source code. This
results in variables used out their scope (which remains unnoticed as
long as `with` contexts do not fail), and prevent refactoring scripts
(such as the one for getting rid of `contextlib.nested` [1]) from
performing well.
This simple patch fixes these indentation errors.
[1]: See change I8d1de09ff38ed0af9fb56f423a2c43476408e0fb
Cedric Brandily [Wed, 27 May 2015 06:53:00 +0000 (08:53 +0200)]
Improve test_set_members_deleting_less_than_5
In test_set_members_deleting_less_than_5[1], 3 ips are deleted from
ipset but test_set_members_deleting_less_than_5 checked that the
first one was deleted because the call ordering was non-trivial.
The test was successful because
assert_has_calls(expected_calls, any_order=False) allows extra calls
before and after expected_calls.
A parent change[2] forces the call ordering, this allows to check that
the 3 ips are deleted.
Cedric Brandily [Tue, 26 May 2015 14:38:26 +0000 (14:38 +0000)]
Sort _get_new/deleted_set_ips responses in unittests
This fixes the test_set_members_adding/deleting_less_than_5 unit test
that breaks with a randomized PYTHONHASHSEED (see the bug report).
The test assumed that the _get_new/deleted_set_ips from
neutron.agent.linux.ipset_manager return elements in a particular order.
Found with PYTHONHASHSEED=1.
The fix refactors the test case to force sorted responses from
_get_new/deleted_set_ips during unittests.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Oleg Bondarev [Thu, 14 May 2015 12:09:24 +0000 (15:09 +0300)]
Cleanup stale metadata processes on l3 agent sync
Currently l3 agent only cleans up stale namespaces.
The fix adds checking and deleting stale metadata processes
to NamespaceManager class responsible for clearing stale
namespaces
shihanzhang [Tue, 26 May 2015 01:29:58 +0000 (09:29 +0800)]
Fix ovs agent restore local_vlan_map failed
when ovs agent restart, it will restore the local_vlan_map, but in
some condition, if a device does not be set tag in ovsdb, the function
'db_get_val("Port", port.port_name, "tag")' will return a empty list,
it does not need 'provision_local_vlan' for this device.
Kevin Benton [Thu, 28 May 2015 23:48:04 +0000 (16:48 -0700)]
Use correct time delta function
The .seconds attribute of a timedetla object cannot be taken in
isolation because it can overflow into days. For example, a -1 second
difference will become -1 day and 86399 seconds.
This became a problem when the agent clock was slightly ahead of
the server clock. When calling (server_time - agent_time).seconds
in this scenario, it would go below 0 in the daily seconds and
wraparound to 86399 seconds and -1 day.
This patch corrects the issue by using a method in timeutils that
ends up calling total_seconds(), which was designed for this usecase.
It also restores the formatting that was removed in patch:
Ibfc30444b7a167fb18ae9051a775266236d4ecce
Cedric Brandily [Wed, 27 May 2015 18:30:28 +0000 (20:30 +0200)]
Do not assume order of security group rules
This fixes the unit tests[1] that breaks with a randomized
PYTHONHASHSEED (see the bug report).
The test assumed that the security_group_rules_for_devices method from
neutron.agent.securitygroups_rpc returned security group rules in a
particular order. Found with PYTHONHASHSEED=2.
The fix refactors the test case to handle unsorted security group rules.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Ihar Hrachyshka [Thu, 28 May 2015 12:40:25 +0000 (14:40 +0200)]
py34: don't run any tests except unit tests
py34 job was intended for unit tests only. It's important to distinguish
between different types of tests, because they all have different
requirements to execution environment. E.g. functional tests are not
expected to run in a restricted env designed for unit tests, and that's
even more valid for fullstack tests.
Otherwise, the job may fail or apply irrecoverable changes to test
runner system, breaking the system.
If we ever want to support py3 for other types of tests, we should add
separate jobs just for that.
Note that the neutron-python3 blueprint was not intended to introduce
changes to support anything but unit test execution with the new Python
version, so strictly speaking, any effort to make other test types work
is out of scope.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Gal Sagie [Thu, 28 May 2015 06:17:15 +0000 (09:17 +0300)]
Addressing follow up comments for OVS_LIB fail_mode setting API
Review https://review.openstack.org/#/c/185659/ got merged before i could
see and address the last comment.
This is a follow up patch to address that change
Kevin Benton [Sat, 16 May 2015 00:10:15 +0000 (17:10 -0700)]
Switch to dictionary for iptables find
The code to find the matching entry was scanning through a
list of all rules for every rule. This became extremely slow
as the number of rules became large, leading to long delays
waiting for firewall rules to be applied.
This patch switches to the use of a dictionary so the cost
becomes a hash lookup instead of a list scan.
Kevin Benton [Thu, 28 May 2015 00:38:32 +0000 (17:38 -0700)]
Process port IP requests before subnet requests
When a port requests multiple fixed IPs, process the requests
for specific IP addresses before the ones asking for a subnet.
This prevents an error where the IP that was requested happens
to be the next up for allocation so the subnet request takes it
and causes a DBDuplicateEntry.
Kevin Benton [Wed, 27 May 2015 21:52:06 +0000 (14:52 -0700)]
Remove time formatting in agent clock error
This removes time formatting that may be hiding timezone
issues that are leading to a delta being calculated between
the agent and the server even when it shows none. It also
adds logging of the difference so we can see how far off it
thinks they are.
Example message:
during the registration of Open vSwitch agent has a timestamp:
2015-05-19T18:15:27Z. This differs from the current server
timestamp: 2015-05-19T18:15:27Z by more than the threshold agent
downtime: 75.
Note that the timestamps are exactly the same after formatting.
Kevin Benton [Tue, 26 May 2015 01:55:44 +0000 (18:55 -0700)]
Persist DHCP leases to a local database
Due to issues caused by dnsmasq restarts sending DHCPNAKs,
change Ieff0236670c1403b5d79ad8e50d7574c1b694e34 passed the
'dhcp-authoritative' option to dnsmasq. While this solved the
restart issue, it broke the multi-DHCP server scenario because
the dnsmasq instances will NAK requests to a server ID that
isn't their own.
Problem DHCP Request Lifecycle:
Client: DHCPDISCOVER(broadcast)
Server1: DHCPOFFER
Server2: DHCPOFFER
Client: DHCPREQUEST(broadcast with Server-ID=Server1)
Server1: DHCPACK
Server2: DHCPNAK(in response to observed DHCPREQUEST with other Server-ID)
^---Causes issues
This change removes the authoritative option so NAKs are not
send in response to DHCPREQUEST's to other servers. To handle
the original issue that Ieff0236670c1403b5d79ad8e50d7574c1b694e34
was inteded to address, this patch also allows changes to be persisted
to a local lease file.
In order to handle the issue where a DHCP server may be scheduled
to another agent, a fake lease file is generated for dnsmasq to start
with. The contents are populated based on all of the known ports for
a network. This should prevent dnsmasq from NAKing clients renewing
leases issued before it was restarted/rescheduled.
Kyle Mestery [Wed, 27 May 2015 17:26:00 +0000 (17:26 +0000)]
Flesh out the new RFE process and set deadlines for it's use
The new RFE process is great in concept, but as was discovered in the
first neutron-drivers meeting where we discussed these, there exist
some rough edges. Specifically around deadlines and the conversion to
using RFEs, the gray area was very obvious. This patch attempts to put
a stake in the ground for when we transition fully to this new model,
including distinct timelines.
Given that we will need to work with people during the transition,
what is proposed is a way to let us do that while not blocking existing
specs and work.
Cedric Brandily [Wed, 27 May 2015 17:57:04 +0000 (19:57 +0200)]
Do not assume order of dictionary elements in init_l3
This fixes the test_interface unit tests[1] that breaks with a
randomized PYTHONHASHSEED (see the bug report).
The test assumed that the init_l3 method from
neutron.agent.linux.interface had dictionary elements in a particular
order. Found with PYTHONHASHSEED=2.
The fix refactors the test case to handle unsorted dictionaries in
init_l3.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
As Neutron has grown, the need to continually evolve the way we land
code has changed. As the project has grown, it's become obvious we
need to subdivide responsibilites and merge rights across the
repository. The advanced services split [1] was one way in which we did
this, and it's proven effective. Plugin decomposition was another [2].
As a next step to evolve things, this changes the core reviewer
paradigm into a system of Lieutenants, all reporting to the PTL in the
project. The Lieutenants will be able to maintain their own core
review team. The idea of "super cores" will fade away. And we begin to
see the benefits of a layered, structured approach to managing
Neutron.
This proposal makes an attempt to comment on existing core reviewers.
While the idea of existing core reviewers being labeled as "supercores"
has been floated, the reality is a bit more nuanced than that, and I've
taken steps to address that with this patch. It should be noted that like
all things in Neutron governance, the system is based on a mutual trust.
Carl Baldwin [Tue, 26 May 2015 20:33:56 +0000 (20:33 +0000)]
Isolate use of fixed_ips[0] to avoid confusion
I was looking at the assumption around using fixed_ips[0] in a recent
patch [1]. I thought at the least, the usage of fixed_ips[0] should
be isolated with the comment explaining why it is okay.
I thought that we could also use this patch as an opportunity to vet
the validity of the claim made in the comment.
Cedric Brandily [Wed, 27 May 2015 12:54:35 +0000 (14:54 +0200)]
Do not assume order of convert_kvp_list_to_dict method responses
This fixes the test_attributes unit tests[1] that breaks with a
randomized PYTHONHASHSEED (see the bug report).
The test assumed that the convert_kvp_list_to_dict method from
neutron.api.v2.attributes returned elements in a particular
order. Found with PYTHONHASHSEED=1.
The fix refactors the test case to handle unsorted responses from
convert_kvp_list_to_dict.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Cedric Brandily [Tue, 26 May 2015 17:54:22 +0000 (19:54 +0200)]
Do not assume order of iptables_firewall method responses
This fixes the iptables_firewall group unit tests[1] that breaks with
a randomized PYTHONHASHSEED (see the bug report).
The test assumed that the _get_remote_sg_ids and
_determine_remote_sgs_to_remove methods from
neutron.agent.linux.iptables_firewall returned elements in a particular
order. Found with PYTHONHASHSEED=1.
The fix refactors the test case to handle unsorted responses from
_get_remote_sg_ids and _determine_remote_sgs_to_remove.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Cedric Brandily [Tue, 26 May 2015 22:23:09 +0000 (00:23 +0200)]
Do not assume order of get_sync_data_metering response elements
This fixes the test_add_metering_label_rpc_call[1] unit tests that breaks
with a randomized PYTHONHASHSEED (see the bug report).
The test assumed that the get_sync_data_metering[2] had response
elements in a particular order. Found with PYTHONHASHSEED=1.
The fix refactors the test_add_metering_label_rpc_call test case to handle
an unsorted get_sync_data_metering response. The fix defines the class
UnorderedList[3] which is equal to any permutation of itself.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Cedric Brandily [Tue, 26 May 2015 13:14:11 +0000 (13:14 +0000)]
Force order of dhcp.needs_resync_reasons dictionary elements
This fixes the test_periodoc_resync_helper unit test that breaks with
a randomized PYTHONHASHSEED (see the bug report).
The test assumed that the dhcp.needs_resync_reasons dictionary from
neutron.agent.dhcp.agent had elements in a particular order. Found with
PYTHONHASHSEED=2.
The fix refactors the test case to force a sorted dhcp.needs_resync_reasons
dictionary.
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
ankitagrawal [Thu, 14 May 2015 12:19:44 +0000 (05:19 -0700)]
Remove use of contextlib.nested (api-tests)
Removed use of contextlib.nested call from codebase, as it has been
deprecated since Python 2.7.
There are also known issues with contextlib.nested that were addressed
by the native support for multiple "with" variables. For instance, if
the first object is created but the second one throws an exception,
the first object's __exit__ is never called. For more information see
https://docs.python.org/2/library/contextlib.html#contextlib.nested
contextlib.nested is also not compatible with Python 3.
Multi-patch set for easier chunks. This one addresses the tests from
neutron/tests/unit/api directory.
Line continuation markers (e.g. '\') had to be used or syntax
errors were thrown. While using parentheses is the preferred way
for multiple line statements, but in case of long with statements
backslashes are acceptable.
Angus Lees [Fri, 15 May 2015 07:54:18 +0000 (17:54 +1000)]
Use os._exit after forking
As the docs point out(*), _exit should be used after a fork() to avoid
both processes flushing filehandles, calling destructors with side
effects, etc. This change does just that.
Henry Gessau [Mon, 25 May 2015 22:00:58 +0000 (18:00 -0400)]
Skip external tables for neutron-db-manage --autogenerate
DB tables that do not have models in the neutron tree cause
neutron-db-manage --autogenerate to create commands to drop the
tables. This fix hooks into alembic's environment with a include_object
callback that ignores external tables.
We already had a list of external tables for use by the migration tests,
so re-use them for --autogenerate.
John Schwarz [Thu, 16 Apr 2015 09:01:26 +0000 (12:01 +0300)]
Add callback prior to deleting a subnet
When using LBaaS and trying to delete a subnet, neutron has no way of
knowing if the subnet is associated to some pool. As a result, the
subnet is deleted but the pool remains associated to the (now
nonexistent) subnet_id. This patch lays the ground-work for adding a
check in LBaaS' side to prevent such cases.
OVS-agent: Separate ovs-ofctl using code as a driver
This is a preparation to introduce another Ryu-based implementation.
The aim is to replace this with the new Ryu-based implementation
eventually.
Add a config option for OVS-agent which selects the implementation.
Currently, the only available choice is 'ovs-ofctl'.
Also, this commit simplifies DVR logics by reducing duplications
and makes some of DVR UTs actually check the flows rather than just
"add_flow is called".
Anand Shanmugam [Sat, 23 May 2015 08:22:23 +0000 (01:22 -0700)]
Ensure mac address added to iptables is always in unix format
When a allowed address pair entry is added with a mac format
other than unix format the ovs-vs agent keeps on restarting as
it is not able to save the proper iptables due to the error
"Error while processing VIF ports". This fix makes sure
that the mac address sent to the iptables firewall is always
in the unix format