Skip to content

Commit

Permalink
Merge pull request #9450 from hexfusion/gw_naming
Browse files Browse the repository at this point in the history
etcdserver: improve Lease http path naming for gRPC gateway
  • Loading branch information
gyuho committed Mar 26, 2018
2 parents fc53917 + cd92d4a commit a994fde
Show file tree
Hide file tree
Showing 6 changed files with 495 additions and 243 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-3.4.md
Expand Up @@ -137,6 +137,8 @@ See [security doc](https://github.com/coreos/etcd/blob/master/Documentation/op-g
- Replace [gRPC gateway](https://github.com/grpc-ecosystem/grpc-gateway) `/v3beta` with [`/v3`](https://github.com/coreos/etcd/pull/9298).
- Deprecated [`/v3alpha`](https://github.com/coreos/etcd/pull/9298).
- To deprecate [`/v3beta`](https://github.com/coreos/etcd/issues/9189) in `v3.5`.
- Add API endpoints [`/{v3,v3beta}/lease/leases, /{v3,v3beta}/lease/revoke /{v3,v3beta}/lease/timetolive`](https://github.com/coreos/etcd/pull/9450).
- To deprecate [`/{v3,v3beta}/kv/lease/leases, /{v3,v3beta}/kv/lease/revoke, /{v3,v3beta}/kv/lease/timetolive`](https://github.com/coreos/etcd/issues/9430) in `v3.5`.

### Package `raft`

Expand Down
87 changes: 84 additions & 3 deletions Documentation/dev-guide/apispec/swagger/rpc.swagger.json
Expand Up @@ -615,7 +615,7 @@
"Lease"
],
"summary": "LeaseLeases lists all existing leases.",
"operationId": "LeaseLeases",
"operationId": "LeaseLeases2",
"parameters": [
{
"name": "body",
Expand All @@ -642,7 +642,7 @@
"Lease"
],
"summary": "LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.",
"operationId": "LeaseRevoke",
"operationId": "LeaseRevoke2",
"parameters": [
{
"name": "body",
Expand All @@ -669,7 +669,7 @@
"Lease"
],
"summary": "LeaseTimeToLive retrieves lease information.",
"operationId": "LeaseTimeToLive",
"operationId": "LeaseTimeToLive2",
"parameters": [
{
"name": "body",
Expand Down Expand Up @@ -826,6 +826,87 @@
}
}
},
"/v3/lease/leases": {
"post": {
"tags": [
"Lease"
],
"summary": "LeaseLeases lists all existing leases.",
"operationId": "LeaseLeases",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/etcdserverpbLeaseLeasesRequest"
}
}
],
"responses": {
"200": {
"description": "(empty)",
"schema": {
"$ref": "#/definitions/etcdserverpbLeaseLeasesResponse"
}
}
}
}
},
"/v3/lease/revoke": {
"post": {
"tags": [
"Lease"
],
"summary": "LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.",
"operationId": "LeaseRevoke",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/etcdserverpbLeaseRevokeRequest"
}
}
],
"responses": {
"200": {
"description": "(empty)",
"schema": {
"$ref": "#/definitions/etcdserverpbLeaseRevokeResponse"
}
}
}
}
},
"/v3/lease/timetolive": {
"post": {
"tags": [
"Lease"
],
"summary": "LeaseTimeToLive retrieves lease information.",
"operationId": "LeaseTimeToLive",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/etcdserverpbLeaseTimeToLiveRequest"
}
}
],
"responses": {
"200": {
"description": "(empty)",
"schema": {
"$ref": "#/definitions/etcdserverpbLeaseTimeToLiveResponse"
}
}
}
}
},
"/v3/maintenance/alarm": {
"post": {
"tags": [
Expand Down
19 changes: 18 additions & 1 deletion e2e/v3_curl_lease_test.go
Expand Up @@ -48,6 +48,8 @@ type v3cURLTest struct {
expected string
}

// TODO remove /kv/lease/timetolive, /kv/lease/revoke, /kv/lease/leases tests in 3.5 release

func testV3CurlLeaseGrant(cx ctlCtx) {
leaseID := randomLeaseID()

Expand All @@ -67,6 +69,11 @@ func testV3CurlLeaseGrant(cx ctlCtx) {
value: gwKVPutLease(cx, "foo", "bar", leaseID),
expected: `"revision":"`,
},
{
endpoint: "/lease/timetolive",
value: gwLeaseTTLWithKeys(cx, leaseID),
expected: `"grantedTTL"`,
},
{
endpoint: "/kv/lease/timetolive",
value: gwLeaseTTLWithKeys(cx, leaseID),
Expand All @@ -88,10 +95,15 @@ func testV3CurlLeaseRevoke(cx ctlCtx) {
expected: gwLeaseIDExpected(leaseID),
},
{
endpoint: "/kv/lease/revoke",
endpoint: "/lease/revoke",
value: gwLeaseRevoke(cx, leaseID),
expected: `"revision":"`,
},
{
endpoint: "/kv/lease/revoke",
value: gwLeaseRevoke(cx, leaseID),
expected: `etcdserver: requested lease not found`,
},
}
if err := cURLWithExpected(cx, tests); err != nil {
cx.t.Fatalf("testV3CurlLeaseRevoke: %v", err)
Expand All @@ -107,6 +119,11 @@ func testV3CurlLeaseLeases(cx ctlCtx) {
value: gwLeaseGrant(cx, leaseID, 0),
expected: gwLeaseIDExpected(leaseID),
},
{
endpoint: "/lease/leases",
value: "{}",
expected: gwLeaseIDExpected(leaseID),
},
{
endpoint: "/kv/lease/leases",
value: "{}",
Expand Down
144 changes: 141 additions & 3 deletions etcdserver/etcdserverpb/gw/rpc.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a994fde

Please sign in to comment.