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

Poc sqlite #23

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Poc sqlite #23

wants to merge 4 commits into from

Conversation

leowmjw
Copy link
Contributor

@leowmjw leowmjw commented Aug 23, 2023

Needs discussion; first preview

@CLAassistant
Copy link

CLAassistant commented Aug 23, 2023

CLA assistant check
All committers have signed the CLA.

@leowmjw
Copy link
Contributor Author

leowmjw commented Aug 24, 2023

Basic APISIX scenarios continue to show correct:

# No routes at the start
$ curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' http://localhost:9180/apisix/admin/routes

{"header":{"revision":"15"},"message":"Key not found"}

# Add route 1
$ curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{
  "methods": ["GET"],
  "uris": ["/get"],
  "upstream": {
    "nodes": {
      "httpbin.org:80": 1
    }
  }
}' http://localhost:9180/apisix/admin/routes/1

{"key":"/apisix/routes/1","value":{"priority":0,"uris":["/get"],"methods":["GET"],"update_time":1692857760,"create_time":1692857760,"id":"1","upstream":{"pass_host":"pass","nodes":{"httpbin.org:80":1},"type":"roundrobin","hash_on":"vars","scheme":"http"},"status":1}}

# Add route 2
$ curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{
  "methods": ["GET"],
  "uris": ["/foo"],
  "upstream": {
    "nodes": {
      "httpbin.org:80": 1
    }
  }
}' http://localhost:9180/apisix/admin/routes/2

{"key":"/apisix/routes/2","value":{"priority":0,"uris":["/foo"],"methods":["GET"],"update_time":1692857777,"create_time":1692857777,"id":"2","upstream":{"pass_host":"pass","nodes":{"httpbin.org:80":1},"type":"roundrobin","hash_on":"vars","scheme":"http"},"status":1}}

# List only the 1st routes even though
$ curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' http://localhost:9180/apisix/admin/routes

{"createdIndex":16,"value":{"priority":0,"uris":["/get"],"methods":["GET"],"update_time":1692857760,"create_time":1692857760,"id":"1","upstream":{"pass_host":"pass","nodes":{"httpbin.org:80":1},"type":"roundrobin","hash_on":"vars","scheme":"http"},"status":1},"modifiedIndex":16,"key":"/apisix/routes/1"}

# Individual route details show
$ curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' http://localhost:9180/apisix/admin/routes/1

{"createdIndex":16,"value":{"priority":0,"uris":["/get"],"methods":["GET"],"update_time":1692857760,"create_time":1692857760,"id":"1","upstream":{"pass_host":"pass","nodes":{"httpbin.org:80":1},"type":"roundrobin","hash_on":"vars","scheme":"http"},"status":1},"modifiedIndex":16,"key":"/apisix/routes/1"}

# Individual route details show
$ curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' http://localhost:9180/apisix/admin/routes/2

{"createdIndex":17,"value":{"priority":0,"uris":["/foo"],"methods":["GET"],"update_time":1692857777,"create_time":1692857777,"id":"2","upstream":{"pass_host":"pass","nodes":{"httpbin.org:80":1},"type":"roundrobin","hash_on":"vars","scheme":"http"},"status":1},"modifiedIndex":17,"key":"/apisix/routes/2"}

@leowmjw
Copy link
Contributor Author

leowmjw commented Aug 24, 2023

APISIX Route rules only work for the 1st route

# Now the first route seems to work
$ curl localhost:9080/get
{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Host": "localhost",
    "User-Agent": "curl/8.1.2",
    "X-Amzn-Trace-Id": "Root=1-64e6f5f0-65954e3038b40cdd62b74565",
    "X-Forwarded-Host": "localhost"
  },
  "origin": "127.0.0.1, 175.139.188.81",
  "url": "http://localhost/get"
}

# Second route does not seem to work
$ curl localhost:9080/foo

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.</p>

Routes are shown in the raw etcdctl calls:

$ etcdctl --endpoints=localhost:12379  get /apisix/routes --prefix  -w=fields

"ClusterID" : 0
"MemberID" : 0
"Revision" : 17
"RaftTerm" : 0
"Key" : "/apisix/routes/1"
"CreateRevision" : 16
"ModRevision" : 16
"Version" : 0
"Value" : "{\"priority\":0,\"uris\":[\"/get\"],\"methods\":[\"GET\"],\"update_time\":1692857760,\"create_time\":1692857760,\"id\":\"1\",\"upstream\":{\"pass_host\":\"pass\",\"nodes\":{\"httpbin.org:80\":1},\"type\":\"roundrobin\",\"hash_on\":\"vars\",\"scheme\":\"http\"},\"status\":1}"
"Lease" : 0
"Key" : "/apisix/routes/2"
"CreateRevision" : 17
"ModRevision" : 17
"Version" : 0
"Value" : "{\"priority\":0,\"uris\":[\"/foo\"],\"methods\":[\"GET\"],\"update_time\":1692857777,\"create_time\":1692857777,\"id\":\"2\",\"upstream\":{\"pass_host\":\"pass\",\"nodes\":{\"httpbin.org:80\":1},\"type\":\"roundrobin\",\"hash_on\":\"vars\",\"scheme\":\"http\"},\"status\":1}"
"Lease" : 0
"More" : false
"Count" : 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants