Skip to content

bug: API-driven standalone mode does not properly handle resources with duplicate IDs #12259

Open
@bzp2010

Description

@bzp2010

Current Behavior

When two services with the same ID are entered (in fact, any resource), the Admin API accepts the input.
When fetching resources via GET, resources with the same ID are output.

Expected Behavior

Only one of multiple duplicate ID resources should be accepted. And reject the input if it is completely unprocessable, e.g., both ID and modifiedIndex are the same.

Error Logs

No response

Steps to Reproduce

{
    "ssls_conf_version": 0,
    "consumer_groups_conf_version": 1,
    "protos_conf_version": 1,
    "secrets_conf_version": 1,
    "plugin_metadata_conf_version": 0,
    "services": [
        {
            "modifiedIndex": 4,
            "desc": "desc",
            "name": "service1",
            "upstream": {
                "scheme": "https",
                "nodes": [
                    {
                        "host": "httpbin.org",
                        "weight": 100,
                        "port": 443
                    }
                ]
            },
            "id": "6e899c1108b88e75d4887b85f9a62c26d9571739",
            "hosts": [
                "example1.com",
                "example2.com"
            ]
        },
        {
            "modifiedIndex": 1,
            "id": "6e899c1108b88e75d4887b85f9a62c26d9571739",
            "name": "service1",
            "hosts": [
                "example1.com",
                "example2.com"
            ],
            "upstream": {
                "scheme": "https",
                "nodes": [
                    {
                        "host": "httpbin.org",
                        "port": 443,
                        "weight": 100
                    }
                ]
            }
        },
        {
            "modifiedIndex": 1,
            "id": "45d48919804fadc2db9d0180a65fe0ee0a8ddf9a",
            "name": "service2",
            "upstream": {
                "scheme": "https",
                "nodes": [
                    {
                        "host": "httpbin.org",
                        "port": 443,
                        "weight": 100
                    }
                ]
            }
        }
    ],
    "upstreams_conf_version": 0,
    "routes_conf_version": 0,
    "services_conf_version": 6,
    "plugin_configs_conf_version": 1,
    "consumers_conf_version": 0,
    "global_rules_conf_version": 0,
    "stream_routes_conf_version": 0
}
#1 update
curl http://localhost:19180/apisix/admin/configs -H "x-api-key: edd1c9f034335f136f87ad84b625c8f1" -XPUT --data '{"ssls_conf_version":0,"consumer_groups_conf_version":1,"protos_conf_version":1,"secrets_conf_version":1,"plugin_metadata_conf_version":0,"services":[{"modifiedIndex":4,"desc":"desc","name":"service1","upstream":{"scheme":"https","nodes":[{"host":"httpbin.org","weight":100,"port":443}]},"id":"6e899c1108b88e75d4887b85f9a62c26d9571739","hosts":["example1.com","example2.com"]},{"modifiedIndex":1,"id":"6e899c1108b88e75d4887b85f9a62c26d9571739","name":"service1","hosts":["example1.com","example2.com"],"upstream":{"scheme":"https","nodes":[{"host":"httpbin.org","port":443,"weight":100}]}},{"modifiedIndex":1,"id":"45d48919804fadc2db9d0180a65fe0ee0a8ddf9a","name":"service2","upstream":{"scheme":"https","nodes":[{"host":"httpbin.org","port":443,"weight":100}]}}],"upstreams_conf_version":0,"routes_conf_version":0,"services_conf_version":6,"plugin_configs_conf_version":1,"consumers_conf_version":0,"global_rules_conf_version":0,"stream_routes_conf_version":0}'
#2 get
curl http://localhost:19180/apisix/admin/configs -H "x-api-key: edd1c9f034335f136f87ad84b625c8f1"

Environment

  • APISIX version (run apisix version): master
  • Operating system (run uname -a): N/A
  • OpenResty / Nginx version (run openresty -V or nginx -V): N/A
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): N/A
  • APISIX Dashboard version, if relevant: N/A
  • Plugin runner version, for issues related to plugin runners: N/A
  • LuaRocks version, for installation issues (run luarocks --version): N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions