Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pymongo raises exception when no flows are provided - pymongo.errors.InvalidOperation: No operations to execute #104

Closed
italovalcy opened this issue Aug 10, 2022 · 1 comment · Fixed by #194
Labels
bug Something isn't working

Comments

@italovalcy
Copy link

Hi,

Accidently I send a KytosEvent to install flows to FlowManager with an empty list of flows, and the following error was raised:

2022-08-10 12:34:29,990 - INFO [kytos.napps.kytos/flow_manager] [main.py:487:handle_flows_install_delete] (thread_pool_app_337) Send FlowMod from KytosEvent dpid: 00:00:00:00:00:00:00:16, command: add, force: False, flows_dict: {'flows': []}
2022-08-10 12:34:29,991 - INFO [kytos.napps.kytos/flow_manager] [main.py:487:handle_flows_install_delete] (thread_pool_app_37) Send FlowMod from KytosEvent dpid: 00:00:00:00:00:00:00:21, command: add, force: False, flows_dict: {'flows': []}
2022-08-10 12:34:30,017 - ERROR [kytos.core.helpers] [helpers.py:151:handler_context_apm] (thread_pool_app_37) listen_to handler: <function Main.on_flows_install_delete at 0x7fad60304b80>, args: (<Main(flow_manager, stopped 140380066543360)>, KytosEvent('kytos.flow_manager.flows.install', {'dpid': '00:00:00:00:00:00:00:21', 'flow_dict': {'flows': []}, 'log_info': 'mef_eline.handle_link_down'}, 0)) traceback: Traceback (most recent call last):,   File "/usr/local/lib/python3.9/dist-packages/kytos/core/helpers.py", line 146, in handler_context_apm,     result = handler(*args),   File "//var/lib/kytos/napps/kytos/flow_manager/main.py", line 466, in on_flows_install_delete,     self.handle_flows_install_delete(event),   File "//var/lib/kytos/napps/kytos/flow_manager/main.py", line 492, in handle_flows_install_delete,     self._install_flows(command, flow_dict, [switch], reraise_conn=not force),   File "//var/lib/kytos/napps/kytos/flow_manager/main.py", line 608, in _install_flows,     self.flow_controller.upsert_flows(,   File "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 324, in wrapped_f,     return self(f, *args, **kw),   File "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 404, in __call__,     do = self.iter(retry_state=retry_state),   File "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 349, in iter,     return fut.result(),   File "/usr/lib/python3.9/concurrent/futures/_base.py", line 433, in result,     return self.__get_result(),   File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result,     raise self._exception,   File "/usr/local/lib/python3.9/dist-packages/tenacity/__init__.py", line 407, in __call__,     result = fn(*args, **kwargs),   File "/usr/local/lib/python3.9/dist-packages/kytos/core/retry.py", line 25, in decorated,     return func(*args, **kwargs),   File "//var/lib/kytos/napps/../napps/kytos/flow_manager/controllers/__init__.py", line 93, in upsert_flows,     return self.db.flows.bulk_write(ops).upserted_ids,   File "/usr/local/lib/python3.9/dist-packages/elasticapm/instrumentation/packages/base.py", line 210, in call_if_sampling,     return self.call(module, method, wrapped, instance, args, kwargs),   File "/usr/local/lib/python3.9/dist-packages/elasticapm/instrumentation/packages/pymongo.py", line 94, in call,     return wrapped(*args, **kwargs),   File "/usr/local/lib/python3.9/dist-packages/pymongo/collection.py", line 514, in bulk_write,     bulk_api_result = blk.execute(write_concern, session),   File "/usr/local/lib/python3.9/dist-packages/pymongo/bulk.py", line 495, in execute,     raise InvalidOperation("No operations to execute"), pymongo.errors.InvalidOperation: No operations to execute,

I believe this is an improvement opportunity for us.

The original error was send the empty list of flows (which I've already fixed on my scenario).

@viniarck viniarck added bug Something isn't working future_release Planned for the next release labels Aug 10, 2022
@viniarck
Copy link
Member

@italovalcy, for sure, and thanks for reporting this.

We've got this issue #73 to handle error in this listen_to handler, I suppose we can follow a similar approach refining the errors and follow an equivalent pattern that it's being used for kytos/flow_manager.flow.error, and ideally compatible to evolve to reuse rexisting validation functionality. If currently, mef_eline can avoid hitting those validation errors then I believe we should be able to prioritize this in a next opportunity, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants