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

bug: Skywalking plugin can not be enabled both in Global and Route rules. #4571

Closed
gxthrj opened this issue Jul 9, 2021 · 0 comments · Fixed by #4589
Closed

bug: Skywalking plugin can not be enabled both in Global and Route rules. #4571

gxthrj opened this issue Jul 9, 2021 · 0 comments · Fixed by #4589
Labels
bug Something isn't working

Comments

@gxthrj
Copy link
Contributor

gxthrj commented Jul 9, 2021

Issue description

WhenSkywalking plugin is enabled both in Global and Route rules.
The route will be failed.

curl: (52) Empty reply from server

Environment

  • apisix version (cmd: apisix version): 2.6
  • OS (cmd: uname -a): centos 7 and docker

Minimal test code / Steps to reproduce the issue

Bug report without steps to reproduce will be ignored or closed.

  1. Binding skywalking plugin in route
curl http://127.0.0.1:9080/apisix/admin/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "methods": ["GET"],
    "uris": [
        "/*"
    ],
    "plugins": {
        "skywalking": {
            "sample_ratio": 1
        }
    },
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "httpbin.org": 1
        }
    }
}'
  1. take a request
curl -i http://127.0.0.1:9080/ip
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 45
Connection: keep-alive
Date: Fri, 09 Jul 2021 03:29:39 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Server: APISIX/2.6

{
  "origin": "172.19.0.1, 58.208.180.202"
}

3.Now add Global rule with skywalking plugin.

curl -X PUT \
  http://127.0.0.1:9080/apisix/admin/global_rules/1 \
  -H 'Content-Type: application/json' \
  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
  -d '{
        "plugins": {
            "skywalking": {
                "sample_ratio":1
            }
        }
    }'
  1. take a request
curl -iv http://127.0.0.1:9080/ip
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 9080 (#0)
> GET /ip HTTP/1.1
> Host: 127.0.0.1:9080
> User-Agent: curl/7.64.1
> Accept: */*
>
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server
* Closing connection 0

And the error log

2021/07/09 03:37:03 [error] 45#45: *1029911 failed to run body_filter_by_lua*: /usr/local/apisix//deps/share/lua/5.1/skywalking/span.lua:196: attempt to index local 'span' (a nil value)
stack traceback:
        /usr/local/apisix//deps/share/lua/5.1/skywalking/span.lua:196: in function 'setComponentId'
        /usr/local/apisix/apisix/plugins/skywalking.lua:94: in function 'phase_func'
        /usr/local/apisix/apisix/plugin.lua:689: in function 'run_plugin'
        /usr/local/apisix/apisix/init.lua:530: in function 'common_phase'
        /usr/local/apisix/apisix/init.lua:581: in function 'http_body_filter_phase'
        body_filter_by_lua:2: in main chunk while sending to client, client: 172.19.0.1, server: _, request: "GET /ip HTTP/1.1", upstream: "http://18.235.124.214:80/ip", host: "127.0.0.1:9080"
2021/07/09 03:37:03 [error] 45#45: *1029911 failed to run log_by_lua*: /usr/local/apisix//deps/share/lua/5.1/skywalking/span.lua:190: attempt to index field 'owner' (a nil value)
stack traceback:
        /usr/local/apisix//deps/share/lua/5.1/skywalking/span.lua:190: in function 'finish'
        /usr/local/apisix//deps/share/lua/5.1/skywalking/tracer.lua:108: in function 'prepareForReport'
        /usr/local/apisix/apisix/plugins/skywalking.lua:104: in function 'phase_func'
        /usr/local/apisix/apisix/plugin.lua:689: in function 'run_plugin'
        /usr/local/apisix/apisix/init.lua:530: in function 'common_phase'
        /usr/local/apisix/apisix/init.lua:639: in function 'http_log_phase'
        log_by_lua(nginx.conf:268):2: in main chunk while logging request, client: 172.19.0.1, server: _, request: "GET /ip HTTP/1.1", upstream: "http://18.235.124.214:80/ip", host: "127.0.0.1:9080"
@spacewander spacewander added the bug Something isn't working label Jul 9, 2021
spacewander added a commit to spacewander/incubator-apisix that referenced this issue Jul 12, 2021
Fix apache#4571

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
spacewander added a commit to spacewander/incubator-apisix that referenced this issue Jul 12, 2021
Fix apache#4571

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
spacewander added a commit to spacewander/incubator-apisix that referenced this issue Jul 12, 2021
Fix apache#4571

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
spacewander added a commit that referenced this issue Jul 14, 2021
Fix #4571

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
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