Commit Graph

25 Commits

Author SHA1 Message Date
Brian Haley 5943685c88 Fix consider-using-in warning
Change test_get_agents() to use 'in' to remove warning,
no change in code.

TrivialFix

Change-Id: I610e34b7d7d3035c8484b06420a2257a5bf2f261
2023-11-30 17:28:18 -05:00
Bence Romsics 6c513217c2 ovs-agent: React to DB down just like to server down
When neutron-server is down, ovs-agent waits for it to become available
during agent startup. When neutron-server is up, but it cannot reach the
DB, it can do nothing pretty much the same way. However ovs-agent
reacted differently to this failure. With this patch it reacts the same
way and delays its startup until neutron-server is up together with its
DB.

Change-Id: Ia55e82540aedc236e9b016bb58047d0b437eeb99
Closes-Bug: #2025341
2023-07-25 12:10:14 +02:00
Bernard Cafarelli 5ce0595803
Set process name for agents
Now that we use setproctitle for neutron-server workers (and
neutron-keepalived-state-change), this has the side effect of changing
the process name for agents, impacting some monitoring systems. More
details in launchpad bug.

This patch fixes it by setting the name with setproctitle to:
agent name (original process name).

Also use the newly introduced name constants to replace existing
hardcoded uses.

Change-Id: I74c3a4d3e9f833752571a75f196560cd45529385
Closes-Bug: #1881297
2020-07-01 12:28:29 +02:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Rodolfo Alonso Hernandez b76321f1d8 Add agent timestamp to "_log_heartbeat" method
When an agent reports the state, the timestamp is sent along with the
agent status. This timestamp now is logged if "log_agent_heartbeats" is
activated.

Change-Id: Ifc88dfb3041aa07b197f395172b69399796ba46a
Related-Bug: #1799555
2019-06-18 06:29:08 +00:00
Rodolfo Alonso Hernandez b71cd851dc Switch to new engine facade for Schedulers
* DhcpAgentSchedulerDbMixin
* L3AgentSchedulerDbMixin
* AutoScheduler
* DhcpFilter
* L3Scheduler

Partially-Implements blueprint: enginefacade-switch

Change-Id: I26a0e651a5c9d30004e2e5a7cfc6b866415cc87b
2019-06-12 19:46:25 +00:00
Lajos Katona 6d99fb19ab Use publish for AGENT AFTER_CREATE/AFTER_UPDATE
This patch switches callbacks over to the payload object style events
for AGENT AFTER_CREATE and AFTER_UPDATE based notifications. To do
so a DBEventPayload object is used with the publish() method to
pass along the API related data.

Change-Id: Ibefa495be41c91957c2e8d797130e569bccc3765
2018-12-19 10:26:05 +01:00
Ihar Hrachyshka f69389004a Revert "Revert "Automatically expire obsolete relationships""
This reverts commit a75014792a.

This is the second attempt to merge the patch after the previous one resulted
in revert due to multiple gate breakages in dependent projects (neutron-lbaas,
vmware-nsx, heat, networking-odl). This second attempt is validated with a set
of depends-on patches for all projects that were affected during the first
failed attempt.

The original commit message for the patch is included below for context.

===

Listen for foreign key changes and expire related relationships.

With this, we can remove OVO code that refreshes / detaches models on
each fetch. The patch also removes a bunch of expunge calls in plugin
code.

writer.using context manager is added to _get_subnets so that segment
plugin's _notify_subnet_updated handler that calls to _get_subnets
doesn't use the facade-less context.session that in specific cases may
cache old models from previous sessions when used in mixed
facade/facade-less environment.

This patch bumps SQLAlchemy minimal requirement to >= 1.2.0 because
pending_to_persistent event didn't exist before this version. It could be >=
1.1.0 if not for the fact that all 1.1.x releases have a bug that results in
breakage of test_update_with_none_and_own_mac_for_duplicate_ip due to obscure
import ordering issue in the library.

(The issue is fixed by https://github.com/zzzeek/sqlalchemy/commit/
63ff0140705207198545e3a0d7868a5ba8486e93)

Partially-Implements: blueprint enginefacade-switch
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db

Co-Authored-By: Michael Bayer <mike_mp@zzzcomputing.com>
Depends-On: If4b28110f460f6ac77ace1bbb02967ea986d4cab
Depends-On: I9f1e76cb24838533572b5fbe269ff96a24ce4af1
Change-Id: I0d65d19204da8ce30addfa5faff68544534b7853
2018-04-26 22:04:07 +00:00
Rabi Mishra a75014792a Revert "Automatically expire obsolete relationships"
This reverts commit 90ede813b0.

Closes-Bug: #1766267
Change-Id: Ia491a2a404bcbd9e108d20b2d9393aff1bb48c8e
2018-04-23 14:30:32 +00:00
Ihar Hrachyshka 90ede813b0 Automatically expire obsolete relationships
Listen for foreign key changes and expire related relationships.

With this, we can remove OVO code that refreshes / detaches models on
each fetch. The patch also removes a bunch of expunge calls in plugin
code.

writer.using context manager is added to _get_subnets so that segment
plugin's _notify_subnet_updated handler that calls to _get_subnets
doesn't use the facade-less context.session that in specific cases may
cache old models from previous sessions when used in mixed
facade/facade-less environment.

This patch bumps SQLAlchemy minimal requirement to >= 1.2.0 because
pending_to_persistent event didn't exist before this version. It could be >=
1.1.0 if not for the fact that all 1.1.x releases have a bug that results in
breakage of test_update_with_none_and_own_mac_for_duplicate_ip due to obscure
import ordering issue in the library.

(The issue is fixed by https://github.com/zzzeek/sqlalchemy/commit/
63ff0140705207198545e3a0d7868a5ba8486e93)

Partially-Implements: blueprint enginefacade-switch
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db

Co-Authored-By: Michael Bayer <mike_mp@zzzcomputing.com>
Change-Id: I18c6794f99d2847c208dfd6e9eb187d53b657a05
2018-04-20 15:33:59 -05:00
Vu Cong Tuan 8b381c7324 Use Agent OVO in agents_db and test_agents_db
Agent object has been merged [1].
This patch uses Agent object in agents_db and test_agents_db.

We also introduce a new function (get_agents_object) and keep
the old function (get_agents_db) for backward compatibility.

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

Co-Authored-By: Nguyen Phuong An <AnNP@vn.fujitsu.com>
Change-Id: I4c4283cb1aa05d52dca00cc249e094ea7d55b1d3
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-11-03 16:46:09 +07:00
Akihiro Motoki f64110f652 Use flake8-import-order plugin
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
It enforces loose checking so it sounds good to use it.
This flake8 plugin is already used in tempest.

Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.

Setup for unit tests of hacking rules is tweaked to disable
flake8-import-order checks. This extension assumes an actual file exists
and causes hacking rule unit tests.

Change-Id: Ib51bd97dc4394ef2b46d4dbb7fb36a9aa9f8fe3d
2017-07-05 03:15:27 +00:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
tonytan4ever e669e7b96b Relocate Agent DB model
This patch set is for breaking the circular dependency between
Agent/AgentVersionedObject.
See:https://review.openstack.org/#/c/297887/ for details.

Change-Id: I7be4ce2513e49e6da46a7bdffb8538613f0be7c7
Partial-Bug: #1597913
Co-Authored-By: Victor Morales <victor.morales@intel.com>
Co-Authored-By: Sindhu Devale <sindhu.devale@intel.com>
2016-10-07 14:18:19 -04:00
Miguel Angel Ajo 1d43dd217a Refactor the rpc callback version discovery mechanism
The previous version depended on the AgentDbMixin to be loaded by
any plugin, and also introduced an __init__ on the mixin which
was problematic: mixins are expected to be classes which add methods
to another class, but to implement no constructor. One of the plugins
had one of the elements of MRO not calling to super().__init__ and
hence not triggering this __init__ method.

This change requires the plugins using the rpc callback mechanism
to provide the AgentDbMixin which is used to refresh cache of known
resource consumers (agents) and versions on demand, this way
we make it more clear that the rpc_callback api is currently designed
to be used with agents only, despite of its extensibility to other
areas.

Change-Id: Ie96b52dbe3a1f32cd4c11de8d8a5eff663fbf7f6
Related-Bug: #1584204
2016-06-09 07:33:03 +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
Henry Gessau ae5bad49cc Use exceptions from neutron-lib
Related-Blueprint: neutron-lib

Change-Id: Ia014468bd621c4ee6aea95bf19328c61070174c4
2016-04-21 21:29:44 -04:00
Miguel Angel Ajo b64b0c762b Don't log warning for missing resource_versions
Since mitaka, agents can send a new report about the resource versions
they know about, and subscribe via rpc callback push mechanisms.
Some agents don't depend on versioned objects via push, and therefore
don't need to update neutron-server about such details, anyway server
side was complaining when that dictionary was missing on the state
report.

This patch avoids the warning log for missing 'resource_versions'
field in the agent status report.

Change-Id: Ief5186871515a5700afb56ac5e3fe493b4a05e8e
Closes-Bug: 1571544
2016-04-19 10:03:10 +02:00
Oleg Bondarev e532ee3fcc Notify resource_versions from agents only when needed
resource_versions were included into agent state reports recently to
support rolling upgrades (commit 97a272a892)
The downside is that it brought additional processing when handling state
reports on server side: update of local resources versions cache and
more seriously rpc casts to all other servers to do the same.
All this led to a visible performance degradation at scale with hundreds
of agents constantly sending reports. Under load (rally test) agents
may start "blinking" which makes cluster very unstable.

In fact there is no need to send and update resource_versions in each state
report. I see two cases when it should be done:
 1) agent was restarted (after it was upgraded);
 2) agent revived - which means that server was not receiving or being able
    to process state reports for some time (agent_down_time). During that
    time agent might be upgraded and restarted.

So this patch makes agents include resource_versions info only on startup.
After agent revival server itself will update version_manager with
resource_versions taken from agent DB record - this is to avoid
version_manager being outdated.

Closes-Bug: #1567497
Change-Id: I47a9869801f4e8f8af2a656749166b6fb49bcd3b
2016-04-12 05:18:35 +00:00
LiuNanke 83ef6b5677 Using LOG.warning replace LOG.warn
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning
so we prefer to use warning to avoid DeprecationWarning.

Closes-Bugs: #1529913

Change-Id: Icc01ce5fbd10880440cf75a2e0833394783464a0
Co-Authored-By: Gary Kotton <gkotton@vmware.com>
2016-03-10 11:02:45 -08:00
Miguel Angel Ajo 97a272a892 RPC Callback rolling upgrades reporting, and integration
This is the second patch to allow upgrades on RPC versioned
objects callbacks.

This enables resource version notifications from agents to all
neutron servers via fanout for updating the version sets in
memory, and via agent status updates for DB storage, so any
neutron server can retrieve such information at boot.

Closes-Bug: #1535247

Change-Id: I67c1323267aaf7e49f4a359ff50b94e52dba4380
2016-03-01 11:20:48 +01:00
Eugene Nikanorov 8ee51f253c Add periodic agents health check.
In addition to periodic checks of L3 and DHCP agents
add periodic checks of overall health of registered agents.
Log total count of agents at debug level so it can be
seen in logs of neutron-server.
In case some agents found dead - log detailed info about them:
Type of agent, last heartbeat, host.

Change-Id: I5db81dad4e9e8325ad3fa3a3e6d5d2d0deb297dd
Closes-Bug: #1453320
2015-10-01 09:21:54 +00:00
Hirofumi Ichihara a6c8d60e5e Add enable_new_agents to neutron server
Neutron doesn't have a way to test a newly added network node
by deploying test resource before any customer resource on the node
is deployed. Nova and Cinder has the setting of “enable_new_services”
in each conf to disable the initial service status to achieve this.
This proposal adds enable_new_agents config.

DocImpact

Change-Id: Ie0d0b2dd4d95de95f3839d1c35f24b708e893801
Implements: blueprint enable-new-agents
Related-Bug: 1472076
2015-08-28 14:41:59 +09:00
Eugene Nikanorov e50e1a2369 Add logging of agent heartbeats
When troubleshooting problems with cluster it would be
very convenient to have information about agent heartbeats
logged with some searchable identifier which could create
1-to-1 mapping between events in agent's logs and server's logs.

Currently agent's heartbeats are not logged at all on server side.
Since on a large cluster that could create too much logging
(even for troubleshooting cases), it might make sense to make
this configurable both on neutron-server side and on agent-side.

DocImpact

Change-Id: I0a127ef274a84bba5de47395d47b62f48bd4be16
Closes-Bug: #1452582
2015-06-29 05:40:26 +04:00
Maru Newby 1105782e39 Reorganize unit test tree
This change ensures that the structure of the unit test tree matches
that of the code tree to make it obvious where to find tests for a
given module.  A check is added to the pep8 job to protect against
regressions.

The plugin test paths are relocated to neutron/tests/unit/plugins
but are otherwise ignored for now.

Change-Id: If307593259139171be21a71c58e3a34bf148cc7f
Partial-Bug: #1440834
2015-04-06 23:28:31 +00:00