Debian: Eliminate nfv IOError logs during api calls

The underlying file object for sockets is different on
python2 (Centos) and python3 (Debian).

 The python2 socket._fileobject appears to allow 'flush'
to be invoked on it while closed.

 The python3 SocketWriter object does not appear to
permit operations like flush after it has been closed
and raises the IOError.

The sequence of calls is the same in both
environments, but the underlying issue is that a 'done'
method is being invoked twice for some API calls.

This change removes an extra call to 'done' by having
it just log a deprecation debug entry.

There should be no difference in functionality on either
environment, and this also stops the error logs on Debian.

Test Plan:
  Verified there are no errors in nfv logs on Centos.
  Verified there are no errors in nfv logs on Debian.
  Verified the sysinv logs are clean on both platforms
when invoking these particular nfv api calls.

Closes-Bug: #1967592
Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I41233aabbebd8d6162143e01981170e691c7011d
This commit is contained in:
Al Bailey 2022-03-30 23:47:13 +00:00
parent b4f3ee93c4
commit bb991828c2
1 changed files with 7 additions and 1 deletions

View File

@ -6,6 +6,7 @@
import json
import re
import requests
from six.moves import BaseHTTPServer
from six.moves import http_client as httplib
from six.moves import socketserver as SocketServer
@ -82,6 +83,10 @@ class RestAPIRequestDispatcher(BaseHTTPServer.BaseHTTPRequestHandler):
DLOG.error(format, *args)
def done(self):
# todo:abailey Remove the calls to 'done' in the plugins
DLOG.debug("Deprecated: 'done' method no longer supported")
def _done(self):
"""
Finished with processing the request.
"""
@ -112,7 +117,8 @@ class RestAPIRequestDispatcher(BaseHTTPServer.BaseHTTPRequestHandler):
Override finish so that the socket is not closed, until we respond.
"""
if not self._response_delayed:
self.done()
# Clean up the request
self._done()
def _dispatch(self, handlers):
"""