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

feat: As a user, I want to check the subordinate relationship in the Admin API #6939

Open
spacewander opened this issue Apr 27, 2022 · 3 comments
Labels
For student This issue is reserved for the students in open source sponsor projects good first issue Good for newcomers

Comments

@spacewander
Copy link
Member

Description

See

-- TODO: check the subordinate relationship in the Admin API

We need to check the subordinate relationship in the Admin API, including:

  1. validate if the stream route with superior id exists and its protocol matches the subordinate
  2. when deleting a stream route, check if it is referenced by another stream route
@spacewander spacewander added the good first issue Good for newcomers label Apr 27, 2022
@spacewander spacewander added the For student This issue is reserved for the students in open source sponsor projects label May 9, 2022
@ro4i7
Copy link

ro4i7 commented Mar 12, 2023

Hello @spacewander @lijing-21

if this is still open, please consider my solution.

May be replacing code from line 79 to line number 84 in apisix/apisix/stream/router/ip_port.lua with below code may solve this issue:

local route = item.value
if route.protocol and route.protocol.superior_id then
    local admin_api = require("apisix.admin").check_http_admin()
    if not admin_api then
        ngx.log(ngx.ERR, "failed to get http admin node")
        goto CONTINUE
    end

    local route_id = route.id
    local superior_id = route.protocol.superior_id

    local res, err = admin_api:get("/stream/routes/" .. superior_id)
    if not res then
        ngx.log(ngx.ERR, "failed to fetch superior stream route: ", err)
        goto CONTINUE
    end

    if res.body.data and res.body.data.protocol == route.protocol then
        ngx.log(ngx.INFO, "matched stream route with superior id: ", superior_id)
    else
        ngx.log(ngx.ERR, "failed to match stream route with superior id: ", superior_id)
        goto CONTINUE
    end

    -- TODO: when deleting a stream route, check if it is referenced by another stream route

end

please, give me feedback on this.

@spacewander
Copy link
Member Author

You could submit a PR with test added to it.

@ro4i7
Copy link

ro4i7 commented Mar 20, 2023

You could submit a PR with test added to it.

@spacewander @starsz @navendu-pottekkat Please check #9116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For student This issue is reserved for the students in open source sponsor projects good first issue Good for newcomers
Projects
None yet
3 participants