logger 499 error - bug in Swift or bad code
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I am not sure if it's something wrong I did or some bug. Here is the summary of what I did.
Consider the following proxy middleware - "logger-499" . This middleware does very minor things - it copy env to new variable, process the original request, than generate new request based on original env and return response back to the user.
I activate it by doing GET on some existing object . Here is the code of the middleware:
-------
from swift.common.utils import get_logger, register_swift_info
from swift.common.swob import Request
from swift.common.wsgi import WSGIContext
class Logger499Contex
def __init__(self, wsgi_app):
def handle_
app_resp = self._app_call(env)
if self._response_
return app_resp
class Logger499Middle
def __init__(self, app, conf):
self.app = app
self.logger = get_logger(conf, log_route=
def __call__(self, env, start_response):
'''
Check the 499 error by doing GET on some existing object.
If pipeline = ... proxy-logging logger-499... - ALL works fine. Logger prints 200 OK.
If pipeline = ... logger-499 proxy-logger ... Then:
Doing GET on existing object, logger will print two lines in log
499 Error and 200 OK. Client never receive 499, only 200 OK.
To re-solve this, I need to uncomment the # line. Have no idea why it solves it :)
'''
req = Request(env)
try:
except ValueError:
return self.app(env, start_response)
orig_env = req.environ.copy()
ctx = Logger499Contex
del env['swift.
ctx = Logger499Contex
return ctx.handle_
def filter_
conf = global_conf.copy()
conf.
swift_info = {}
register_
def logger_
return Logger499Middle
return logger_499_filter
-------
This middleware does very minor things - it copy env to new variable, process the original request, than generate new request based on original env and return response back to the user.
I then activate it by doing GET on existing object
Here is the problem:
If pipeline defined as :
pipeline = .... proxy-logging logger-499 .... proxy-server
Than all works fine and logger prints a single line into proxy-log :
Mar 30 13:47:34 my-laptop proxy-server: 127.0.0.1 127.0.0.1 30/Mar/
tx1ffba725a1c34
BUT, if I change position of proxy-logging and logger-499, making pipeline to be as
*******
pipeline = .... logger-499 proxy-logging .... proxy-server
Then if I do the same GET i am getting
Mar 30 13:47:34 my-laptop proxy-server: 127.0.0.1 127.0.0.1 30/Mar/
Mar 30 13:47:34 my-laptop proxy-server: 127.0.0.1 127.0.0.1 30/Mar/
tx1ffba725a1c34
To resolve this strange 499 error i need to add
env['swift.
( see the line #env['swift.
Can someone explain me what is wrong with it? Is it something I did wrong or some bug?
I'd like to see the full pipeline, not the abbreviated one, if possible. If there are sensitive filter names in there, of course, redact them.
The typical pipeline starts with "catch_errors gatekeeper proxy_logging", then has a big pile of middleware names, then finishes with "proxy_logging proxy_server". The key thing is that proxy_logging is in there twice. If your middleware isn't between the two, I don't think any requests that it makes will be logged.
The goal is that each request does, in fact, get logged... so for example SLO, there'd be one logged GET that the client made, plus one logged GET for each segment or submanifest.
I'm not sure where the 499 is coming from, but if your middleware is actually making a second request, then there should definitely be two log lines.