Commit Graph

133 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez 14d0ff0317 Add ``devlink.get_port`` method for devlink ports
Added ``devlink.get_port`` method that provides information about
a devlink port [1]. It is used to retrieve information about a port
representor connected to a local OVS instance (aka: hardware offloaded
ports). This method reports the PF PCI address, the PF index, the VF
index and the PF name; the PF name will be used to enforce the QoS
policies on the SR-IOV parent device (similar to what is done in the
ML2/SRIOV agent).

[1]https://www.kernel.org/doc/html/latest/networking/devlink/devlink-port.html

Related-Bug: #1998608
Change-Id: I34daf554cabcf17cb6371d510d5827457012516d
2022-12-12 20:08:06 +01:00
Brian Haley 81330921d8 Fix some pylint indentation warnings
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/agent and neutron/privileged/agent.

Trivialfix

Change-Id: Ib94257481e62b99b3d7648ae5137af5411b4867a
2022-12-01 16:22:24 +00:00
Rodolfo Alonso 19eb12bd29 Revert "Implement "kill" method using os.kill()"
This reverts commit 4b21111eb1.

Reason for revert: This method is unstable and prone to timeouts

Change-Id: I6064d60e4d63b085046aace7683d766a79dd22da
2021-03-25 22:05:58 +00:00
Rodolfo Alonso Hernandez 4b21111eb1 Implement "kill" method using os.kill()
Implement the "kill" method (send a signal to a process) using the
Python native library "os".

In functional tests, "RootHelperProcess.kill" method should not fail if
the process does not exist.

Closes-Bug: #1843446
Closes-Bug: #1843418

Change-Id: Iee97a83779dd3e20eb3a223fb8557a94b8f15dc0
2021-03-22 08:58:20 +00:00
Rodolfo Alonso Hernandez ee00bddce7 Remove rootwrap execution (6)
Replace rootwrap execution with privsep context execution.
This series of patches will progressively replace any
rootwrap call.

This patch migrates the "kill_process" method to privsep and
removes the unneeded rootwrap filters.

Change-Id: I48461be8b08cbc21c8af371f551b944343ba37bf
Story: #2007686
Task: #41558
2021-03-05 10:03:22 +00:00
Rodolfo Alonso Hernandez c89c1f53db Remove rootwrap execution (1)
Replace rootwrap execution with privsep context execution.
This series of patches will progressively replace any
rootwrap call.

This patch replaces some "IpNetnsCommand" command execution
methods.

Change-Id: Ic5fdf221a2a2cd0951539b0e040d2a941feee287
Story: #2007686
Task: #41558
2021-02-06 16:22:43 +00:00
Akihiro Motoki 257a51769b Drop meaningless translation marker
The translation marker _(..) wrapping a variable is meaningless
as no string is extracted and there is no way to translate them.
Only rare exception is the same string is defined in somewhere else
but I've never seen such situations so far.

In addition, we now only support translations in user-visible messages
used in API, so we can safely drop translation markers in exceptions
in the agent side.

Change-Id: Ie1d837d17bf50a4675bec4fe48ab13dde22ebdc2
Related-Bug: #1600788
2021-02-05 10:14:41 +00:00
Mitya_Eremeev c156c7d883 Proper log translation
The main idea of the commit is to fix code
according with the latest oslo.i18n requirements
https://docs.openstack.org/oslo.i18n/latest/

1. removed log translation if log is not seen by users
   in raised exception or api call response.
2. keep translated log if it's used in raised exception.
3. removed log message 'Error while reading %s'
   which was "dead" (unused) code in the function
   "_get_value_from_conf_file"
   of module "agent/linux/dhcp.py".

Partial-Bug: 1600788
Change-Id: Ifb5455336b06c2c87a930b816c90b4a766856b1e
2021-01-21 19:07:04 +03:00
Zuul 2d4b3aa119 Merge "Delete HA metadata proxy PID and config with elevated privileges" 2020-12-14 08:32:38 +00:00
Rodolfo Alonso Hernandez 0a0f647ea0 Delete HA metadata proxy PID and config with elevated privileges
Both files cannot be deleted with the default permissions because
those files are created by the "root" user.

Change-Id: I73dd37b3104fac8d3172f520f71cffd85d040c4b
Closes-Bug: #1907695
2020-12-13 21:50:31 +00:00
Rodolfo Alonso Hernandez a6dbf97242 Deprecate XenAPI support
The configuration options are now marked as deprecated for
removal in X release.

Any related code is deleted. Neutron does not support XenAPI,
same as Nova [1][2].

[1]https://review.opendev.org/#/c/749304/
[2]https://review.opendev.org/#/c/749309/

Change-Id: Ifdb2200a5dac3508fdf8907bdd1f4547dff35341
Story: #2007686
Task: #41269
2020-12-09 20:15:39 +00:00
Zuul 2fba36a88e Merge "Implement "find_child_pids" natively" 2020-11-20 02:27:57 +00:00
Zuul 40c501dcb1 Merge "Add process name to AsyncProcess" 2020-11-16 14:56:58 +00:00
Rodolfo Alonso Hernandez b5eadca521 Implement "find_child_pids" natively
Use Python native libraries instead of shell calls.

Closes-Bug: #1900270

Change-Id: I3602cbe33183a8476eb332c85fcf399b211dda07
2020-11-14 17:17:52 +00:00
Rodolfo Alonso Hernandez ad0605f9c3 Add process name to AsyncProcess
Since [1], Neutron sets the name of some processes (Neutron agents).
The "ps" output is modified consequently according to the defined
string:
  "<process name> (<process command>)"

"AsyncProcess" class should use the process name to parse the "ps"
output correctly.

Closes-Bug: #1902678

[1]https://review.opendev.org/#/c/735125/

Change-Id: If33c49c0f3e1e6696f5d2aa4008b287dc3f76c61
2020-11-06 09:17:52 +00:00
Rodolfo Alonso Hernandez aa2f058701 Implement "get_process_count_by_name" natively
Use Python native libraries instead of shell calls.

Closes-Bug: #1900269

Change-Id: If6eafb7f5f26ab127ab5432ce85096d052a20b0c
2020-10-19 10:21:54 +00:00
Rodolfo Alonso Hernandez b4211c8c54 Implement "find_parent_pid" natively
Use Python native libraries instead of shell calls.

Closes-Bug: #1900268

Change-Id: Iaad9e2b3374b5c81f83c780d306685773af719ed
2020-10-19 10:20:15 +00:00
boluanace 7f494fa3ae Show cmd detail when execute linux command failed
For neutron-l3-agent, after the execution of the linux command fails,
display which command failed to execute

Change-Id: Ia237e1b18e02c9da3ae9ee94e4244828e5c207b2
Closes-Bug: #1893627
2020-09-02 19:37:52 -07:00
Rodolfo Alonso Hernandez ddd5832323 Remove "six" library
Last step to remove "six" library usage in Neutron.

Change-Id: Idd42e0c51c8c3bd598c9cf91602596be238bccae
2020-07-28 16:55:52 +00:00
Slawek Kaplonski b59fdaa9aa Log exact error during getting value from file
Before this patch function get_value_from_file() was only
logging something like "Unable to access {filename}" but it
would be useful sometimes to check what was exact reason of
IOError so lets log this info also.

TrivialFix

Related-bug: #1853652

Change-Id: I28b1753a8d5767babbb6f06a581ffe1fc4ad75d3
2019-12-03 10:10:27 +01:00
Jens Harbott 3330bc01cb Fix race condition when getting cmdline
Even though we check for the existence of the process before, it may
still terminate before we get to read its command line, so catch the
error that can occur here.

Change-Id: I3e89aca8bedfd2912effe2490718223f7d03133e
Closes-Bug: 1844500
2019-09-18 21:32:33 -04:00
Brian Haley b79842f289 Start enforcing E125 flake8 directive
Removed E125 (continuation line does not distinguish itself
from next logical line) from the ignore list and fixed all
the indentation issues.  Didn't think it was going to be
close to 100 files when I started.

Change-Id: I0a6f5efec4b7d8d3632dd9dbb43e0ab58af9dff3
2019-07-19 23:39:41 -04:00
Slawek Kaplonski dcc3d3c754 Add extra unit test for get_cmdline_from_pid function
In patch [1] get_cmdline_from_pid function was modified to be able
to parse process' cmdline files with arguments separated by space
instead of '\0' char.
This patch adds one extra UT and small refactor which was pointed
in comments to [1] but which I was not able to change there.

[1] https://review.openstack.org/#/c/647605/

Change-Id: Ibd91d0472a686eca79a1126154d9cdf4587c1a19
Related-Bug: #1820870
2019-03-28 14:45:40 +00:00
Slawek Kaplonski cf13b2f0cc Check if process' cmdline is "space separarated"
According to proc man page process arguments in /proc/{pid}/cmdline
should be separated with '\0' char and that char was used in
neutron.agent.linux.utils.get_cmdline_from_pid function.

Recently in fullstack tests it was noticed that sometimes it may
happend that those arguments are separated with space char and this
caused failed test because async_process.AsyncProcess() was not able
to check that process is really active.

This patch adds attempt to split cmdline arguments with space in case
when split with '\0' returns only 1 element.

Change-Id: I35d4c0e2cf56fc3ff15cf307aaf11a8ad8489e1f
Closes-Bug: #1820870
2019-03-25 21:54:52 +01:00
LIU Yulong 5b7d444b31 Not set the HA port down at regular l3-agent restart
If l3-agent was restarted by a regular action, such as config change,
package upgrade, manually service restart etc. We should not set the
HA port down during such scenarios. Unless the physical host was
rebooted, aka the VRRP processes were all terminated.

This patch adds a new RPC call during l3 agent init, it will try to
retrieve the HA router count first. And then compare the VRRP process
(keepalived) count and 'neutron-keepalived-state-change' count
with the hosting router count. If the count matches, then that
set HA port to 'DOWN' state action will not be triggered anymore.

Closes-Bug: #1798475
Change-Id: I5e2bb64df0aaab11a640a798963372c8d91a06a8
2019-02-14 16:58:22 +08:00
Boden R 68fd13af40 remove neutron.common.exceptions
Today the neutron common exceptions already live in neutron-lib and are
shimmed from neutron. This patch removes the neutron.common.exceptions
module and changes neutron's imports over to use their respective
neutron-lib exception module instead.

NeutronLibImpact

Change-Id: I9704f20eb21da85d2cf024d83338b3d94593671e
2019-02-01 14:35:00 -07:00
Brian Haley 2b57f08576 Fix flake8 H404 errors
Fix H404 error and start enforcing it.

Trivialfix

Change-Id: Iaa6fb4f1f07dee32a944259ab65204360d9db7ea
2018-10-05 21:48:41 +00:00
Brian Haley db7e19d2ba Fix pylint warning with eventlet > 0.22.0
When eventlet was bumped up to 0.24.1 in upper-constraints [1]
it started generating a pylint warning, since neutron has
support for older versions such as 0.22.0 that take a different
number of arguments. Just silence the warning.

Also, in order to get this through the gate, the
neutron-grenade-dvr-multinode check job is being temporarily
set to non-voting and removed from the gate.  That change
should be reverted as soon as we fix bug 1791989.

[1] https://review.openstack.org/#/c/589382/

Change-Id: I169ecb6f33b670c5469919214a32645cd9eda206
Closes-Bug: #1791178
Related-Bug: #1791989
2018-09-14 11:36:05 -06:00
Claudiu Belu fee630efaa Fix neutron-openvswitch-agent Windows support
Currently, the neutron-openvswitch-agent does not start on Windows
due to Linux specific imports. This patch addresses this issue.

Also, we're wrapping the object returned by subprocess.Popen using
tpool.Proxy in order to prevent IO operations on the stream
handles from blocking other threads. Currently, the ovs db monitor
blocks the whole process.

Closes-Bug: #1775382

Co-Authored-By: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Change-Id: I8bbc9d1f8332e5644a6071f599a7c6a66bef7928
2018-07-18 14:41:21 +03:00
Brian Haley d1efeeb433 Fix UnixDomainHttpProtocol class to support all eventlet versions
It was recently decided to uncap eventlet:
http://lists.openstack.org/pipermail/openstack-dev/2018-April/129096.html
So eventlet is now capped at 0.20 not by global requirements,
it is capped in upper-constraints, because currently not every
openstack project is able to work with a newer eventlet version,
mostly because of the caps in projects requirements.txt.
According to global-requirements, last allowed version of
eventlet is 0.22.1:
https://git.openstack.org/cgit/openstack/requirements/tree/global-requirements.txt

In an effort to support both eventlet<0.22 and eventlet>=0.22,
change the code to try and determine the correct number of
arguments to use in the call to initialize the parent class.

Change-Id: Ibe3dc8af6cf9f8bb4f8eababb7f4276e4db3f1f9
Closes-bug: #1777640
2018-07-10 15:20:11 -04:00
Brian Haley c3b83a9ca6 Fix all pep8 E265 errors
Fixed all pep8 E265 errors and changed tox.ini to no longer
ignore them.  Also removed an N536 comment missed from a
previous change.

Change-Id: Ie6db8406c3b884c95b2a54a7598ea83476b8dba1
2018-04-30 16:35:52 -04:00
Isaku Yamahata 2c31f7f351 eventlet v0.22 changed HttpProtocol.__init__
From eventlet v0.22, HttpProtocol.__init__ signature was changed
to take 4 argument to 3 argument.
The changeset of eventlet, 7f53465578543156e7251e243c0636e087a8445f,
https://github.com/eventlet/eventlet/issues/188
changed it.
So try the new signature for HttpProtocol.__init__ first, and then
fallback to the old signature for compatibility.

Change-Id: I2e024f04ceab10afb20b5a402f8ba8dfd50e753d
2018-04-19 15:53:29 +00: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
Kevin Benton ce8dbcff83 Don't log 'Exit code: 0'
A regular gate run shows this was logged ~2500 times.
It doesn't provide any useful information since the
command executed successfully and we can see the
issued command in the debug statement before it.

Partial-Bug: #1707307
Change-Id: I431d6a59ce36deb9a5fb9deef39655d28d71f24d
2017-07-31 15:46:57 -07:00
Jenkins 19a069d99f Merge "Pass parameters when create eventlet.wsgi server" 2017-04-17 05:35:54 +00:00
Jenkins 598428fb2e Merge "execute: don't call greenthread.sleep directly" 2017-04-13 02:07:15 +00:00
Ihar Hrachyshka 757476983c execute: don't call greenthread.sleep directly
The module may be used in scope that is not using eventlet (f.e. from
inside neutron-keepalived-state-change), in which case a call to
greenthread.sleep from the main thread will result in AssertionError.

Instead of that, call time.sleep that will redirect to greenthread.sleep
in eventlet environment.

This reflects what we do in oslo.concurrency execute implementation.

Change-Id: Id73c0e5015feca2c559da4a68a70aeaaf5cec2a7
Closes-Bug: #1680183
2017-04-06 21:51:33 +00:00
Brian Haley 0476ad641d Print useful error on rootwrap daemon failure
If the rootwrap daemon fails to execute a command, it
generates a cryptic message:

Unserializable message: ('#ERROR', ValueError('I/O operation on closed file',))

We should at least log the command that we were trying
to run, which will help users figure out why it failed.

Change-Id: I2c94e5a226630432028351f8287868f4fe5d2fa1
Closes-bug: #1677742
2017-04-04 16:59:52 -04:00
Duan Jiong 5fd6b4c768 Pass parameters when create eventlet.wsgi server
Otherwise, config option wsgi_log_format in neutron.conf
will not work

Closes-Bug: #1672615
Change-Id: I43a3b6d99f940b5276aabaccad15d1050023baa2
2017-03-17 14:14:25 +08: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 320b789401 Remove dependency on strings for kill_process
utils.kill_process() parsed the error string after the kill command
which can lead to internationalization issues. We shouldn't relay upon
different translations so this follow-up patch removes this dependency
by checking if the process is still running after the kill when a
ProcessExecutionError exception occurs.

Before, this was achieved by comparing against "No such process" string

Change-Id: I22bd63992d1029f99fea401f07167383f8ff7dd0
2017-03-15 04:28:01 +00:00
Anindita Das 13080f0237 Remove deprecated method get_interface_mac
Removing the deprecated method get_interface_mac and from
neutron/agent/linux/utils.py and the associated test in
neutron/tests/unit/agent/linux/test_utils.py. This is scheduled
for removal in Pike.
This was deprecated in I1695d7e46efe5245eb581bd40d5420250a3bad89.

Change-Id: I6b84563c2631a3e47826320f03fa1fdfe44cf2a9
2017-03-13 05:55:07 +00:00
Dirk Mueller 261852f756 Revert "Don't disable Nagle algorithm in HttpProtocol"
We depend on eventlet 0.19.0 or newer at least, the workaround
is not needed anymore

This reverts commit 21d139d441.

Change-Id: Ib5a8ca113e5a25109b4829db4915e550db86f6e9
2017-02-01 22:37:24 +01:00
Jenkins 86d47bad2d Merge "XenAPI: Support daemon mode for rootwrap" 2017-01-21 02:18:20 +00:00
Oleg Bondarev 7953e9886d Fix empty string check for python 3
It's '' in py2 and b'' in py3.
See bug for traceback.

Closes-Bug: #1657476
Change-Id: Ic2c32669bf238b702e13e81e15dd079d538a6abc
2017-01-20 10:03:20 +04:00
Jianghua Wang 8047da17db XenAPI: Support daemon mode for rootwrap
For Neutron's compute agent in a XenServer's compute node, the commands
actually need run in Dom0. Currently XenServer only supports rootwrap
for that purpose by invoking a script which invokes XenAPI to execute
commands in dom0. There are much performance overhead due to it requires
parsing on the script and the configuration file every time running
commands.

This change is to support daemon mode with which each agent service will
call XenAPI directly to execute commands in dom0. And it will keep the
single XenAPI session.

DocImpact: Need update the following configuration.

file: /etc/neutron/plugins/ml2/openvswitch_agent.ini
[agent]
root_helper_daemon = xenapi_root_helper
[xenapi]
connection_url = http://169.254.0.1
connection_username = root
connection_password = xenroot

Closes-Bug: #1585510
Change-Id: I684034359fe0571bc92dbcf342a9821553b1da35
2017-01-19 07:33:43 +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
Gary Kotton 7c0b219e66 neutron-lib: complete usage of helpers
Add support for:
    - get_random_string
    - camelize
    - round_val
    - safe_decode_utf8

Change-Id: I3b5ccbbcfa18aa488b1772f4ae9a591eb494de59
2016-11-10 05:40:15 -08:00
Dariusz Smigiel e43eb80ac2 Removed deprecation warning for waiting_until_true
wait_until_true is moved to neutron.common.utils
It was marked for removal in Ib8b0e51dbd9edaa58391774d428a737836dfdf77

Change-Id: I9efbbc237acbcebbb36ff239ec234b25abacccae
2016-11-08 03:49:21 +00:00
Gary Kotton dbbbe595f4 Use ensure_tree from oslo_utils.fileutils
Make use of the common oslo method to implement ensure_dir.

TrivialFix

Change-Id: Ia9e4c581664235476f290a4b651c5a24017ce357
2016-11-05 00:00:31 -07:00