You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/01 11:48:11 UTC
[GitHub] [apisix] slene opened a new issue #4516: bug: Generates lot of useless logs when cookie not found
slene opened a new issue #4516:
URL: https://github.com/apache/apisix/issues/4516
### Issue description
### Environment
* apisix version (cmd: `apisix version`): 2.6
* OS (cmd: `uname -a`): centos 7.8
### Minimal test code / Steps to reproduce the issue
```
{
"uris": [
"/*"
],
"name": "route",
"methods": [
"GET"
],
"vars": [
[
"cookie_upstream",
"==",
"dev"
]
],
"status": 1
}
```
When cookie cookie_upstream not found.
```
2021/07/01 19:30:06 [warn] 46#46: *2782 [lua] ctx.lua:157: __index(): failed to fetch cookie value by key: cookie_upstream error: nil, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:9181"
```
When cookie header not exists.
```
2021/07/01 19:38:50 [warn] 46#46: *19719 [lua] ctx.lua:157: __index(): failed to fetch cookie value by key: cookie_upstream error: no cookie found in the current request, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:9181"
```
It generates a lot of useless logs. If this is unexpected, I can submit a pr.
```diff
elseif core_str.has_prefix(key, "cookie_") then
local cookie = t.cookie
- if cookie then
+ if cookie and ngx.var.http_cookie then
local err
val, err = cookie:get(sub_str(key, 8))
- if not val then
+ if err then
log.warn("failed to fetch cookie value by key: ",
key, " error: ", err)
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4516:
URL: https://github.com/apache/apisix/issues/4516#issuecomment-872637838
Look like we don't need to change this part: "if not val then"?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #4516:
URL: https://github.com/apache/apisix/issues/4516
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4516:
URL: https://github.com/apache/apisix/issues/4516#issuecomment-872689722
Yes, you are right.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4516:
URL: https://github.com/apache/apisix/issues/4516#issuecomment-873715748
@slene
PR is welcome!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] slene commented on issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
slene commented on issue #4516:
URL: https://github.com/apache/apisix/issues/4516#issuecomment-872277821
@spacewander How about this ?
```diff
@@ -111,7 +111,11 @@ end
do
local var_methods = {
method = ngx.req.get_method,
- cookie = function () return ck:new() end
+ cookie = function ()
+ if ngx.var.http_cookie then
+ return ck:new()
+ end
+ end
}
local ngx_var_names = {
@@ -153,7 +157,7 @@ do
if cookie then
local err
val, err = cookie:get(sub_str(key, 8))
- if not val then
+ if err then
log.warn("failed to fetch cookie value by key: ",
key, " error: ", err)
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] slene commented on issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
slene commented on issue #4516:
URL: https://github.com/apache/apisix/issues/4516#issuecomment-872669982
@spacewander
I think that value does not exist is not an error. The log should be recorded when err exists.
```
local value = ctx.var["cookie_upstream"]
if value then
-- do something
end
```
```
2021/07/01 19:30:06 [warn] 46#46: *2782 [lua] ctx.lua:157: __index(): failed to fetch cookie value by key: cookie_upstream error: nil, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:9181"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4516: bug: Generates lot of useless logs when cookie not found
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4516:
URL: https://github.com/apache/apisix/issues/4516#issuecomment-872245763
We can do the check inside https://github.com/apache/apisix/blob/d902cb197bea3a951d151d92ef53b38d81939324/apisix/core/ctx.lua#L114
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org