Commit Graph

46 Commits

Author SHA1 Message Date
Jakub Libosvar 4d3a274765 Don't register config options on imports
Importing some modules lead to registering config options that may
collide with config options from a project that calls the import. This
patch wraps the side effect that registers config options into a
function that needs to be called in case the caller wants to register
the options.

This solution is also not perfect as it guards the common options to be
registered only once even if the function is called multiple times. This
is to solve problems in unittests, ideally we should always call the
function just once even in our testing suites.

Resolves-Bug: #1968606
Change-Id: Ic1532eb8de887ff1b1085206df11f53e22f7f524
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
2022-04-13 05:49:15 +00:00
Rodolfo Alonso Hernandez 0c1818fbb0 Migrate "netstat" to oslo.privsep
Change-Id: If9e4c1513553c4bd10fd3b91c28c4d3f806ed816
Story: #2007686
Task: #40047
2020-06-19 14:59:11 +00:00
Michael Johnson d1d0a04c37 Remove Neutron LBaaS
Neutron-LBaaS has now been retired and there will be no Train
release[1]. This patch removes neutron-lbaas references from
neutron.

[1] https://review.opendev.org/658494

Closes-Bug: #1833125
Change-Id: I0fe3fbaf4adf7fb104632fd94cd093e701e12289
2019-09-20 07:46:06 +00:00
Daniel Alvarez f30fc92adf netns_cleanup: Remove unused parameter from unplug_devices()
A conf object was passed in to the unplug_devices method
which was not used. This patch is removing it and adapting the
tests to the new prototype.

Also, there's apparently no callers outside neutron that could
get broken as per codesearch.openstack.org.

Change-Id: Ie19b8e4056b1f27be3cae51e74759ebfed41074e
Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
2018-10-10 11:15:59 +02:00
Miguel Angel Ajo 5106dfe521 Configure privsep helper in neutron-netns-cleanup
This closes a bug that makes netns-cleanup crash when
trying to invoke privsep helper, because the rootwrap
config isn't correctly passed down to the privsep helper
library.

Closes-Bug: #1776468

Change-Id: I8258a44a9e2542ec222ebac72c4b889858ab2fc2
2018-06-12 15:07:07 +02:00
Brian Haley 4f627b4e8d Change ip_lib network namespace code to use pyroute2
Change network namespace add/delete/list code to use
pyroute2 library instead of calling /sbin/ip.

Also changed all in-tree callers to use the new calls.

Closes-bug: #1717582
Related-bug: #1492714

Change-Id: Id802e77543177fbb95ff15c2c7361172e8824633
2017-10-04 21:09:28 +00:00
sindhu devale 51ca683797 Refactoring agent linux&ovsdb config
Refactoring neutron agent linux and ovsdb config opts
to be in neutron/conf/agent so that all the config options
reside in a centralized location. This simplifies the
process of looking up the config opts and provides an easy
way to import.

NeutronLibImpact

Change-Id: Ib1e0e63dec2985c417412d1ecc68e2a74ef87182
Partial-Bug: #1563069
2017-08-25 10:41:39 -04:00
Inessa Vasilevskaya 7322bd6efb Make code follow log translation guideline
Since Pike log messages should not be translated.
This patch removes calls to i18n _LC, _LI, _LE, _LW from
logging logic throughout the code. Translators definition
from neutron._i18n is removed as well.
This patch also removes log translation verification from
ignore directive in tox.ini.

Change-Id: If9aa76fcf121c0e61a7c08088006c5873faee56e
2017-08-14 02:01:48 +00:00
Ihar Hrachyshka 1ae91ce9be ip_lib: ignore gre and lo devices in get_devices by default
This is the most common use pattern for the method, so it makes sense to
make it default.

(Actually, it may be that there are no usage for the arguments
whatsoever, but better safe than sorry.)

NeutronLibImpact this change potentially breaks callers of get_devices
that may want to get the automatic devices by default. Those imaginary
callers may need to set exclude_gre_devices and/or exclude_loopback to
True from now on.

Change-Id: Ic32b8abc7f8502b8907ae21c996e13cb8fd5401d
Related-Bug: #1604115
2017-04-13 15:03:06 -07:00
Ihar Hrachyshka 91c15edf54 Ignore gre devices in namespaces when cleaning up devices
Agents and netns_cleanup tool attempt to clean up devices from
namespaces before destroying namespaces, but they should skip doing it
for gre devices that are automatic and show up depending on kernel
modules loaded.

Change-Id: Ie95890ed92ac73ec8e2d118a9727b9e1624a5178
Related-Bug: #1604115
2017-04-13 15:02:35 -07:00
John Perkins 7f23ccce23 Agent common config
Refactoring Neutron configuration options for agent common config to be
in neutron/conf/agent/common. This will allow centralization of all
configuration options and provide an easy way to import.

Partial-Bug: #1563069
Change-Id: Iebac0cdd3bcfd0135349128921b7ad7a1a939ab8
Needed-By: Ib676003bbe909b5a9013a3178b12dbe291d936af
2017-03-15 09:52:18 -06:00
Daniel Alvarez 3f9f740d81 Fix netns_cleanup interrupted on rwd I/O
Functional tests for netns_cleanup have been failing a few times
in the gate lately. After thorough tests we've seen that the issue was
related to using rootwrap-daemon inside a wait_until_true loop. When
timeout fired while utils.execute() was reading from rootwrap-daemon,
it got interrupted and the output of the last command was not read.
Therefore, next calls to utils.execute() would read the output of
their previous command rather than their own, leading to unexpected
results.

This fix will poll existing processes in the namespace without making
use of the wait_until_true loop. Instead, it will check elapsed time
and raise the exception if timeout is exceeded.

Also, i'm removing debug traces introduced in
327f7fc4d5 which helped finding the root
cause of this bug.

Change-Id: Ie233261e4be36eecaf6ec6d0532f0f5e2e996cd2
Closes-Bug: #1654287
2017-01-12 03:52:30 +00:00
Daniel Alvarez 1d38f30555 Kill processes when cleaning up namespaces
This patch will kill processes that are listening on any port/UNIX
socket within the namespace to be cleaned up. To kill them it will
issue a SIGTERM to them (or to their parents if they were forked) and,
if they don't die after a few seconds, a SIGKILL to them and all their
children.

This is intended for those cases when there's no specific cleanup and
serves as a fallback method.

Change-Id: I4195f633ef4a1788496d1293846f19eef89416aa
Partial-Bug: #1403455
2016-12-20 10:52:41 +00:00
Brian Haley 3fec181772 Clean-up L3 constant TODOs
Since the refactor is complete, let's clean these up and
use neutron-lib constants instead.

Trivialfix

Change-Id: Ic69d59d53ee78a4c6eb0104583755c4145fb8e46
2016-12-14 11:54:12 -05:00
Aradhana Singh 7f9610c591 Refactoring config options for cmd
Refactoring neutron configuration options for cmd to be in
neutron/conf. This would allow centralization of all configuration
options and provide an easy way to import.

Change-Id: I0bb7c88050aa5e931a53406d29b5b10c69c518bb
Partial-Bug: #1563069
2016-07-31 04:37:29 +00:00
Aradhana Singh 607957ef35 Refactoring config options for dhcp agent
Refactoring neutron configuration options for dhcp agent to be in
neutron/conf/agent. This would allow centralization of all configuration
options and provide an easy way to import.

Change-Id: Ia17d2d7223dd598e2d36a8320942fb03b61dffaf
Partial-Bug: #1563069
2016-07-06 17:24:23 +00:00
Henry Gessau 4148a347b3 Use constants from neutron-lib
With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
2016-04-23 21:23:56 -04:00
Ilya Shakhat ada05d657c Make netns_cleanup to purge resources of selected agent only
A new option --agent-type is introduced into netns_cleanup. When it is set
the utility processes namespaces for selected agent only. Possible values
are 'dhcp', 'l3', 'lbaas'. When the option is not set the behaviour stays
unchanged - all namespaces are processed.

Change-Id: Idaaffce767654bf21701a5329742f10a241b2cbf
2016-02-11 12:19:26 +03:00
Assaf Muller cfc9578148 Don't emit confusing error in netns-cleanup
If we're trying to delete a dhcp/qrouter device with use_veth
= False (Which is the default for some time), we'll first
try to 'ip link del %s', which will fail and emit a confusing
error, then try 'ovs-vsctl del-port'. There's no need to
log an error in such a case.

The patch attempts to future proof by setting the
set_log_fail_as_error(False) to be as tight as possible, so we
do log errors in case the device is somehow used in the future.

Change-Id: I1954bde3ee9a2e43d7615717134b61c5fa7cfbb1
Closes-Bug: #1463800
2015-12-07 20:17:49 -05:00
Akihiro Motoki 2d8632e412 Use _ from neutron._i18n
Partial-Bug: #1520094
Change-Id: I874a4aa1d71d1f7034a1ff0b7450b419ef5c6864
2015-12-06 19:39:04 +09:00
Doug Wiegley dd726ed494 Move i18n to _i18n, as per oslo_i18n guidelines
- This does NOT break other projects that rely on neutron.i18n,
  as this change includes a debtcollector shim to maintain those
  older entry points, until they can migrate.
- Also updates _i18n.py to the latest pattern defined by oslo_i18n
- Guidance and template are from the reference:
  http://docs.openstack.org/developer/oslo.i18n/usage.html

Partially-Closes-Bug: #1519493
Change-Id: I1aa3a5fd837d9156da4643a367013c869ed8bf9d
2015-12-01 19:29:10 -07:00
Cedric Brandily 23b907bc6e Remove deprecated use_namespaces option
The use_namespaces option has been defined as a workaround to kernels
not properly supporting namespaces. This limitation is behind us, it's
time to remove use_namespaces after its deprecation in Kilo in order to
simplify code and remove a poorly tested case (use_namespaces=False).

This change prepares for removal pullup_route method[1] which was only
used when use_namespaces=False.

[1] neutron.agent.linux.ip_lib

DocImpact
UpgradeImpact
Closes-Bug: #1508188
Related-Bug: #1435382
Depends-On: I303038eec560a6d99421140c2822aed8b518470b
Depends-On: I4feb2a15c7e1e4bfdbed2531b18b8e7d798ab3cc
Change-Id: I2fbf65df1250d9f9f1656b3964ee3b6de1ef1118
2015-11-18 19:17:29 +01:00
Itzik Brown 4eafec58f2 Adding a cleanup for 'qlbaas-' namespaces in netns_cleanup
Change-Id: I2f8c2c037419953d6f6a9416472f4e5fb73d53db
Closes-Bug: 1456151
2015-07-21 13:52:57 +03:00
Adelina Tuvenie 1a089e6059 Moves ovs_lib to agent/common
This patch moves ovs_lib from agent/linux to agent/common
since it will be used by ovs_neutron_agent on both Linux
and Windows platforms. To provide compatibility with out of
tree code, a placeholder has been left in agent/linux.

Unit tests are updated accordingly.

Partially implements blueprint: hyper-v-ovs-agent

Change-Id: I009f7f5e3b014633541ed5a45628aa1b2287e22b
2015-03-25 13:48:33 -07:00
Jenkins 81ce60ea7b Merge "Adding a cleanup for 'fip-' and 'snat-' namespaces in netns_cleanup" 2015-03-20 01:44:05 +00:00
Jenkins d0589051ad Merge "Add a netns-cleanup functional test" 2015-03-19 11:37:17 +00:00
Jenkins 4afa8fa0c5 Merge "Fix netns-cleanup broken by ProcessMonitor refactor" 2015-03-17 10:03:20 +00:00
Itzik Brown 2aa5178087 Adding a cleanup for 'fip-' and 'snat-' namespaces in netns_cleanup
Closes-Bug: 1430253
Change-Id: Ib58fd82f1d92d3e8b18118f344d63790bfd48c62
2015-03-15 09:33:19 +02:00
Miguel Angel Ajo 042aae6dd9 Add a netns-cleanup functional test
We have lots of regressions on netns, because unit test
is not enough. This commit adds basic functional testing
to the netns_cleanup.

This work should be extended when we have functional testing
for the dhcp agent, spawning dhcp services, and then
making sure they're fully cleaned up.

Change-Id: I0b5125dfa24a3dbcd44593ae2aee4dbbd47def67
2015-03-13 17:14:37 +00:00
Miguel Angel Ajo 59137d0ede Fix netns-cleanup broken by ProcessMonitor refactor
Change I0da6071037f9728cc20403324e36c32116bcf00d broke the
netns-cleanup script. As the process_monitor parameter
is now mandatory for the dhcp driver.

Change-Id: I69617c67815b71a05a25936c5e7acc7c116c0dd6
Closes-bug: #1430762
2015-03-13 10:35:40 +00:00
Ihar Hrachyshka 22328baf1f Migrate to oslo.log
It's mostly a matter of changing imports to a new location.

Non-obvious changes needed:
* pass overwrite= argument to oslo_context since oslo.log reads context
  from its thread local store and not local.store from incubator
* don't store context at local.store now that there is no code that
  would consume it
* LOG.deprecated() -> versionutils.report_deprecated_feature()
* dropped LOG.audit check from hacking rule since now the method does
  not exist
* WritableLogger is now located in oslo_log.loggers

Dropped log module from the tree. Also dropped local module that is now
of no use (and obsolete, as per oslo team).

Added versionutils back to openstack-common.conf since now we use the
module directly from neutron code and not just as a dependency of some
other oslo-incubator module.

Note: tempest tests are expected to be broken now, so instead of fixing
all the oslo.log related issues for the subtree in this patch, I only
added TODOs with directions for later fix.

Closes-Bug: #1425013
Change-Id: I310e059a815377579de6bb2aa204de168e72571e
2015-03-12 11:22:56 +01:00
Miguel Angel Ajo 8540cfea3e Refactor the ProcessMonitor API
Refactor the ProcessMonitor API to reduce coupling to
ProcessManager, and stop replicating the whole API and
behavior of ProcessManager.

We introduced an abstract MonitoredProcess class to reduce
coupling, and allow other kinds of external processes
to be monitored too.

Partially Implements: blueprint agent-child-processes-status
Co-Authored-By: Mike Kolesnik <mkolesni@redhat.com>

Change-Id: I0da6071037f9728cc20403324e36c32116bcf00d
2015-03-06 11:09:21 +00:00
Terry Wilson 326e25f932 Remove remaining uses of passing root_helper
This should remove the last bits of passing root_helper around
for execute(). Some tests store and pass the root_helper argument
outside of this, and have been left alone.

Depends-On: I1e3b64e5a1d6cff2aebc638710487bbdbdba61d4
Depends-On: I5d51fa5edc7f427d84d7ae49d3a4c972dca8ac37
Depends-On: I21c6e7795c8b2e8f87bbd2b00a8eb7cb215ece74
Depends-On: I6566e17a1ce07a3bebf2a1a3653ad7e7f397f0b9
Change-Id: I38c901c65fb0c8598589ec56d5afd50d2f882f4f
Partially-Implements: blueprint rootwrap-daemon-mode
2015-02-20 03:24:38 +00:00
Jenkins 5a86ce2146 Merge "Remove root_helper arg from DHCP agent" 2015-02-19 01:35:39 +00:00
Jenkins 9ebb329ef6 Merge "Don't monkey patch netns_cleanup" 2015-02-18 17:25:26 +00:00
Terry Wilson 9310a3b76a Remove root_helper arg from DHCP agent
Partially-Implements: blueprint rootwrap-daemon-mode
Change-Id: I394fc2bf8b9579203fc0a878047a57cf6e09927e
2015-02-18 14:22:10 +00:00
Ihar Hrachyshka 81ea614570 Don't monkey patch netns_cleanup
There is no reason to monkey patch the tool (it does not rely on any
special kind of model of concurrency). It's better to avoid eventlet
wherever possible, and there are discussions on whether we want to start
dropping eventlet usage agent by agent, so it's worth keeping as much of
code out of monkey business.

Related-Bug: #1418541
Change-Id: I1c1bb5a23e191da660efe9d4179ffaf5fec647f9
2015-02-18 13:33:57 +01:00
Terry Wilson 04d2e9b412 Remove root_helper arg from external_process
Partially-Implements: blueprint rootwrap-daemon-mode
Change-Id: Icdfc3ac4812154bcd628f9a224ef516d55b41cfd
2015-02-18 11:36:33 +00:00
Terry Wilson d336623d55 Remove root_helper arg for ovs_lib
Stop passing root_helper in ovs_lib classes and instead rely on
execute() looking up the root_helper from the config.

Partially-Implements: blueprint rootwrap-daemon-mode
Change-Id: I24c29a1964582dabaa04358e05be903c8cb49229
2015-02-12 15:33:31 -06:00
Ihar Hrachyshka 7a2a85623d oslo: migrate to namespace-less import paths
Oslo project decided to move away from using oslo.* namespace for all their
libraries [1], so we should migrate to new import path.

This patch applies new paths for:
- oslo.config
- oslo.db
- oslo.i18n
- oslo.messaging
- oslo.middleware
- oslo.rootwrap
- oslo.serialization
- oslo.utils

Added hacking check to enforce new import paths for all oslo libraries.

Updated setup.cfg entry points.

We'll cleanup old imports from oslo-incubator modules on demand or
if/when oslo officially deprecates old namespace in one of the next
cycles.

[1]: https://blueprints.launchpad.net/oslo-incubator/+spec/drop-namespace-packages

Depends-On: https://review.openstack.org/#/c/147248/
Depends-On: https://review.openstack.org/#/c/152292/
Depends-On: https://review.openstack.org/#/c/147240/

Closes-Bug: #1409733
Change-Id: If0dce29a0980206ace9866112be529436194d47e
2015-02-05 15:09:32 +01:00
Miguel Angel Ajo 2e5bf64a51 Refactor the ProcessMonitor _exit_handler to ProcessMonitor
We allowed to provide an specific _exit_handler, but in
the end all the implementations are providing the same
one. So, now it's refactored back to the monitor, and
removed any YAGNI code.

Partially implements: bp/agent-child-processes-status

Change-Id: I916feb631885324bc98da1b1350915e14b6fcadc
2015-01-27 11:52:30 +00:00
Miguel Angel Ajo fc4e60ed4b Implements ProcessMonitor in the dhcp_agent
The ProcessMonitor class will watch over spawned external processes,
taking the administrator configured action in the case of any
of the external processes die unexpectedly.

It covers both the neutron-ns-metadata-proxy for isolated metadata
and dnsmasq in the dnsmasq driver.

ProcessMonitor has been extended to allow specific pid files
for backwards-compatible dnsmasq pid file location.

Implements: blueprint agent-child-processes-status
Change-Id: I0a4a509b65aadf825799c98dfa48a655b123b403
2015-01-23 11:55:44 +00:00
Jenkins 39c2efef3a Merge "DHCP agent restructuring" 2015-01-22 05:59:29 +00:00
armando-migliaccio b35c004204 DHCP agent restructuring
Wrap dhcp agent into its own module and break out configurations and
entry point for better seperation. This lead to some test cleanup
that revealed that options were registered unnecessarily.

When/if the dhcp agent goes through a restructuring along the same
lines of the L3 agent's, this would be the step to start from.

Related-blueprint: restructure-l3-agent
Related-blueprint: core-vendor-decomposition

Change-Id: I87d9f1079ed4e71c731984ec00e2f785024fd5f8
2015-01-17 01:03:09 -08:00
armando-migliaccio d05b9790e8 Move agent cleanup scripts to cmd module
Ensure naming consistency across the various entry points.

This patch better separates active elements of Neutron agents from
operator's utilities.

Along with [1,2,3], this is done to better delineate what the agent
module inner boundaries are about. More to follow to finish off the
cleanup.

[1] https://review.openstack.org/#/c/146024/
[2] https://review.openstack.org/#/c/145979/
[3] https://review.openstack.org/#/c/146239/

Change-Id: I1d2d2938aa7fa1c60e0f0dc70997778a1930efef
2015-01-14 10:01:44 -08:00
Terry Wilson 589205a6c2 Move non-bridge-related OVSBridge methods to BaseOVS
This patch moves several methods in OVSBridge that don't really have
anything to do with OVS bridges to BaseOVS where they are a much
better fit. Since OVSBridge inherits from BaseOVS, no modules using
ovs_lib will have to change to support this move.

Also, several module-level functions that essentially re-implement
BaseOVS.run_vsctl() are moved to BaseOVS and converted to use
run_vsctl. In order to avoid changing the API, the module-level
functions are then reimplemented by creating a BaseOVS instance and
calling the associated method.

Partially-implements: blueprint vsctl-to-ovsdb
Change-Id: I94aaa0bef68e407649b421db53bb59d007335f5c
2015-01-10 06:46:35 -06:00