From 8daa908a903adf48b9fd73fb90c93a14dcc6a9cf Mon Sep 17 00:00:00 2001 From: Renjie Cai Date: Wed, 17 Apr 2019 15:55:06 +0800 Subject: [PATCH] fix test --- .travis.yml | 5 +- README.md | 2 +- etcd3/rpc.swagger.json | 2347 -------------------------------------- etcd3/stateful/lock.py | 3 +- etcd3/stateful/watch.py | 22 +- etcd3/utils.py | 5 + requirements_py3.txt | 2 +- tests/conftest.py | 5 + tests/test_watch_util.py | 15 +- 9 files changed, 39 insertions(+), 2367 deletions(-) delete mode 100644 etcd3/rpc.swagger.json create mode 100644 tests/conftest.py diff --git a/.travis.yml b/.travis.yml index 5339fdd..f91b10f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,9 @@ env: # - ETCD_VER=v3.3.4 # - ETCD_VER=v3.3.7 # - ETCD_VER=v3.3.9 - - ETCD_VER=v3.3.10 - +# - ETCD_VER=v3.3.10 + - ETCD_VER=v3.3.12 + before_install: - sudo docker pull quay.io/coreos/etcd:$ETCD_VER diff --git a/README.md b/README.md index be59e9a..1d33c00 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Notice: The authentication header through gRPC-JSON-Gateway only supported in [e ## Features -* [x] Support python2.7 and python3.5+ +* [x] Support python2.7 and python3.5+ (aiohttp requires python3.5.2+) * [x] Sync client based on requests * [x] Async client based on aiohttp * [x] TLS Connection diff --git a/etcd3/rpc.swagger.json b/etcd3/rpc.swagger.json deleted file mode 100644 index 3f7d23d..0000000 --- a/etcd3/rpc.swagger.json +++ /dev/null @@ -1,2347 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "etcdserver/etcdserverpb/rpc.proto", - "version": "version not set" - }, - "schemes": [ - "http", - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/v3alpha/auth/authenticate": { - "post": { - "summary": "Authenticate processes an authenticate request.", - "operationId": "Authenticate", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthenticateResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthenticateRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/disable": { - "post": { - "summary": "AuthDisable disables authentication.", - "operationId": "AuthDisable", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthDisableResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthDisableRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/enable": { - "post": { - "summary": "AuthEnable enables authentication.", - "operationId": "AuthEnable", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthEnableResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthEnableRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/role/add": { - "post": { - "summary": "RoleAdd adds a new role.", - "operationId": "RoleAdd", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleAddResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleAddRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/role/delete": { - "post": { - "summary": "RoleDelete deletes a specified role.", - "operationId": "RoleDelete", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleDeleteResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleDeleteRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/role/get": { - "post": { - "summary": "RoleGet gets detailed role information.", - "operationId": "RoleGet", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleGetResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleGetRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/role/grant": { - "post": { - "summary": "RoleGrantPermission grants a permission of a specified key or range to a specified role.", - "operationId": "RoleGrantPermission", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleGrantPermissionResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleGrantPermissionRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/role/list": { - "post": { - "summary": "RoleList gets lists of all roles.", - "operationId": "RoleList", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleListResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleListRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/role/revoke": { - "post": { - "summary": "RoleRevokePermission revokes a key or range permission of a specified role.", - "operationId": "RoleRevokePermission", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleRevokePermissionResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthRoleRevokePermissionRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/add": { - "post": { - "summary": "UserAdd adds a new user.", - "operationId": "UserAdd", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserAddResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserAddRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/changepw": { - "post": { - "summary": "UserChangePassword changes the password of a specified user.", - "operationId": "UserChangePassword", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserChangePasswordResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserChangePasswordRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/delete": { - "post": { - "summary": "UserDelete deletes a specified user.", - "operationId": "UserDelete", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserDeleteResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserDeleteRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/get": { - "post": { - "summary": "UserGet gets detailed user information.", - "operationId": "UserGet", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserGetResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserGetRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/grant": { - "post": { - "summary": "UserGrant grants a role to a specified user.", - "operationId": "UserGrantRole", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserGrantRoleResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserGrantRoleRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/list": { - "post": { - "summary": "UserList gets a list of all users.", - "operationId": "UserList", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserListResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserListRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/auth/user/revoke": { - "post": { - "summary": "UserRevokeRole revokes a role of specified user.", - "operationId": "UserRevokeRole", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserRevokeRoleResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAuthUserRevokeRoleRequest" - } - } - ], - "tags": [ - "Auth" - ] - } - }, - "/v3alpha/cluster/member/add": { - "post": { - "summary": "MemberAdd adds a member into the cluster.", - "operationId": "MemberAdd", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbMemberAddResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbMemberAddRequest" - } - } - ], - "tags": [ - "Cluster" - ] - } - }, - "/v3alpha/cluster/member/list": { - "post": { - "summary": "MemberList lists all the members in the cluster.", - "operationId": "MemberList", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbMemberListResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbMemberListRequest" - } - } - ], - "tags": [ - "Cluster" - ] - } - }, - "/v3alpha/cluster/member/remove": { - "post": { - "summary": "MemberRemove removes an existing member from the cluster.", - "operationId": "MemberRemove", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbMemberRemoveResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbMemberRemoveRequest" - } - } - ], - "tags": [ - "Cluster" - ] - } - }, - "/v3alpha/cluster/member/update": { - "post": { - "summary": "MemberUpdate updates the member configuration.", - "operationId": "MemberUpdate", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbMemberUpdateResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbMemberUpdateRequest" - } - } - ], - "tags": [ - "Cluster" - ] - } - }, - "/v3alpha/kv/compaction": { - "post": { - "summary": "Compact compacts the event history in the etcd key-value store. The key-value\nstore should be periodically compacted or the event history will continue to grow\nindefinitely.", - "operationId": "Compact", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbCompactionResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbCompactionRequest" - } - } - ], - "tags": [ - "KV" - ] - } - }, - "/v3alpha/kv/deleterange": { - "post": { - "summary": "DeleteRange deletes the given range from the key-value store.\nA delete request increments the revision of the key-value store\nand generates a delete event in the event history for every deleted key.", - "operationId": "DeleteRange", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbDeleteRangeResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbDeleteRangeRequest" - } - } - ], - "tags": [ - "KV" - ] - } - }, - "/v3alpha/kv/lease/revoke": { - "post": { - "summary": "LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.", - "operationId": "LeaseRevoke", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseRevokeResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseRevokeRequest" - } - } - ], - "tags": [ - "Lease" - ] - } - }, - "/v3alpha/kv/lease/timetolive": { - "post": { - "summary": "LeaseTimeToLive retrieves lease information.", - "operationId": "LeaseTimeToLive", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseTimeToLiveRequest" - } - } - ], - "tags": [ - "Lease" - ] - } - }, - "/v3alpha/kv/put": { - "post": { - "summary": "Put puts the given key into the key-value store.\nA put request increments the revision of the key-value store\nand generates one event in the event history.", - "operationId": "Put", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbPutResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbPutRequest" - } - } - ], - "tags": [ - "KV" - ] - } - }, - "/v3alpha/kv/range": { - "post": { - "summary": "Range gets the keys in the range from the key-value store.", - "operationId": "Range", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbRangeResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbRangeRequest" - } - } - ], - "tags": [ - "KV" - ] - } - }, - "/v3alpha/kv/txn": { - "post": { - "summary": "Txn processes multiple requests in a single transaction.\nA txn request increments the revision of the key-value store\nand generates events with the same revision for every completed request.\nIt is not allowed to modify the same key several times within one txn.", - "operationId": "Txn", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbTxnResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbTxnRequest" - } - } - ], - "tags": [ - "KV" - ] - } - }, - "/v3alpha/lease/grant": { - "post": { - "summary": "LeaseGrant creates a lease which expires if the server does not receive a keepAlive\nwithin a given time to live period. All keys attached to the lease will be expired and\ndeleted if the lease expires. Each expired key generates a delete event in the event history.", - "operationId": "LeaseGrant", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseGrantResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseGrantRequest" - } - } - ], - "tags": [ - "Lease" - ] - } - }, - "/v3alpha/lease/keepalive": { - "post": { - "summary": "LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client\nto the server and streaming keep alive responses from the server to the client.", - "operationId": "LeaseKeepAlive", - "responses": { - "200": { - "description": "(streaming responses)", - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseKeepAliveResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "description": "(streaming inputs)", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbLeaseKeepAliveRequest" - } - } - ], - "tags": [ - "Lease" - ] - } - }, - "/v3beta/lock/lock": { - "post": { - "summary": "Lock acquires a distributed shared lock on a given named lock.\nOn success, it will return a unique key that exists so long asnthe lock is held by the caller. This key can be used in\nconjunction with transactions to safely ensure updates to etcdnonly occur while holding lock ownership. The lock is held until\nUnlock is called on the key or the lease associate with thenowner expires.", - "operationId": "Lock", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbLockResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbLockRequest" - } - } - ], - "tags": [ - "Lock" - ] - } - }, - "/v3beta/lock/unlock": { - "post": { - "summary": "Unlock takes a key returned by Lock and releases the hold on\nlock. The next Lock caller waiting for the lock will then benwoken up and given ownership of the lock.", - "operationId": "Unlock", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbUnlockResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbUnlockRequest" - } - } - ], - "tags": [ - "Lock" - ] - } - }, - "/v3alpha/maintenance/alarm": { - "post": { - "summary": "Alarm activates, deactivates, and queries alarms regarding cluster health.", - "operationId": "Alarm", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbAlarmResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbAlarmRequest" - } - } - ], - "tags": [ - "Maintenance" - ] - } - }, - "/v3alpha/maintenance/defragment": { - "post": { - "summary": "Defragment defragments a member's backend database to recover storage space.", - "operationId": "Defragment", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbDefragmentResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbDefragmentRequest" - } - } - ], - "tags": [ - "Maintenance" - ] - } - }, - "/v3alpha/maintenance/hash": { - "post": { - "summary": "Hash returns the hash of the local KV state for consistency checking purpose.\nThis is designed for testing; do not use this in production when there\nare ongoing transactions.", - "operationId": "Hash", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbHashResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbHashRequest" - } - } - ], - "tags": [ - "Maintenance" - ] - } - }, - "/v3alpha/maintenance/snapshot": { - "post": { - "summary": "Snapshot sends a snapshot of the entire backend from a member over a stream to a client.", - "operationId": "Snapshot", - "responses": { - "200": { - "description": "(streaming responses)", - "schema": { - "$ref": "#/definitions/etcdserverpbSnapshotResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbSnapshotRequest" - } - } - ], - "tags": [ - "Maintenance" - ] - } - }, - "/v3alpha/maintenance/status": { - "post": { - "summary": "Status gets the status of the member.", - "operationId": "Status", - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/etcdserverpbStatusResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbStatusRequest" - } - } - ], - "tags": [ - "Maintenance" - ] - } - }, - "/v3alpha/watch": { - "post": { - "summary": "Watch watches for events happening or that have happened. Both input and output\nare streams; the input stream is for creating and canceling watchers and the output\nstream sends events. One watch RPC can watch on multiple key ranges, streaming events\nfor several watches at once. The entire event history can be watched starting from the\nlast compaction revision.", - "operationId": "Watch", - "responses": { - "200": { - "description": "(streaming responses)", - "schema": { - "$ref": "#/definitions/etcdserverpbWatchResponse" - } - } - }, - "parameters": [ - { - "name": "body", - "description": "(streaming inputs)", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/etcdserverpbWatchRequest" - } - } - ], - "tags": [ - "Watch" - ] - } - } - }, - "definitions": { - "AlarmRequestAlarmAction": { - "type": "string", - "enum": [ - "GET", - "ACTIVATE", - "DEACTIVATE" - ], - "default": "GET" - }, - "CompareCompareResult": { - "type": "string", - "enum": [ - "EQUAL", - "GREATER", - "LESS", - "NOT_EQUAL" - ], - "default": "EQUAL" - }, - "CompareCompareTarget": { - "type": "string", - "enum": [ - "VERSION", - "CREATE", - "MOD", - "VALUE" - ], - "default": "VERSION" - }, - "EventEventType": { - "type": "string", - "enum": [ - "PUT", - "DELETE" - ], - "default": "PUT" - }, - "RangeRequestSortOrder": { - "type": "string", - "enum": [ - "NONE", - "ASCEND", - "DESCEND" - ], - "default": "NONE" - }, - "RangeRequestSortTarget": { - "type": "string", - "enum": [ - "KEY", - "VERSION", - "CREATE", - "MOD", - "VALUE" - ], - "default": "KEY" - }, - "WatchCreateRequestFilterType": { - "type": "string", - "enum": [ - "NOPUT", - "NODELETE" - ], - "default": "NOPUT", - "description": " - NOPUT: filter out put event.\n - NODELETE: filter out delete event." - }, - "authpbPermission": { - "type": "object", - "properties": { - "permType": { - "$ref": "#/definitions/authpbPermissionType" - }, - "key": { - "type": "string", - "format": "byte" - }, - "range_end": { - "type": "string", - "format": "byte" - } - }, - "title": "Permission is a single entity" - }, - "authpbPermissionType": { - "type": "string", - "enum": [ - "READ", - "WRITE", - "READWRITE" - ], - "default": "READ" - }, - "etcdserverpbAlarmMember": { - "type": "object", - "properties": { - "memberID": { - "type": "string", - "format": "uint64", - "description": "memberID is the ID of the member associated with the raised alarm." - }, - "alarm": { - "$ref": "#/definitions/etcdserverpbAlarmType", - "description": "alarm is the type of alarm which has been raised." - } - } - }, - "etcdserverpbAlarmRequest": { - "type": "object", - "properties": { - "action": { - "$ref": "#/definitions/AlarmRequestAlarmAction", - "description": "action is the kind of alarm request to issue. The action\nmay GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a\nraised alarm." - }, - "memberID": { - "type": "string", - "format": "uint64", - "description": "memberID is the ID of the member associated with the alarm. If memberID is 0, the\nalarm request covers all members." - }, - "alarm": { - "$ref": "#/definitions/etcdserverpbAlarmType", - "description": "alarm is the type of alarm to consider for this request." - } - } - }, - "etcdserverpbAlarmResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "alarms": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbAlarmMember" - }, - "description": "alarms is a list of alarms associated with the alarm request." - } - } - }, - "etcdserverpbAlarmType": { - "type": "string", - "enum": [ - "NONE", - "NOSPACE" - ], - "default": "NONE" - }, - "etcdserverpbAuthDisableRequest": { - "type": "object" - }, - "etcdserverpbAuthDisableResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthEnableRequest": { - "type": "object" - }, - "etcdserverpbAuthEnableResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthRoleAddRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "name is the name of the role to add to the authentication system." - } - } - }, - "etcdserverpbAuthRoleAddResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthRoleDeleteRequest": { - "type": "object", - "properties": { - "role": { - "type": "string" - } - } - }, - "etcdserverpbAuthRoleDeleteResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthRoleGetRequest": { - "type": "object", - "properties": { - "role": { - "type": "string" - } - } - }, - "etcdserverpbAuthRoleGetResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "perm": { - "type": "array", - "items": { - "$ref": "#/definitions/authpbPermission" - } - } - } - }, - "etcdserverpbAuthRoleGrantPermissionRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "name is the name of the role which will be granted the permission." - }, - "perm": { - "$ref": "#/definitions/authpbPermission", - "description": "perm is the permission to grant to the role." - } - } - }, - "etcdserverpbAuthRoleGrantPermissionResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthRoleListRequest": { - "type": "object" - }, - "etcdserverpbAuthRoleListResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "etcdserverpbAuthRoleRevokePermissionRequest": { - "type": "object", - "properties": { - "role": { - "type": "string" - }, - "key": { - "type": "string" - }, - "range_end": { - "type": "string" - } - } - }, - "etcdserverpbAuthRoleRevokePermissionResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthUserAddRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, - "etcdserverpbAuthUserAddResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthUserChangePasswordRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "name is the name of the user whose password is being changed." - }, - "password": { - "type": "string", - "description": "password is the new password for the user." - } - } - }, - "etcdserverpbAuthUserChangePasswordResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthUserDeleteRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "name is the name of the user to delete." - } - } - }, - "etcdserverpbAuthUserDeleteResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthUserGetRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - } - } - }, - "etcdserverpbAuthUserGetResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "etcdserverpbAuthUserGrantRoleRequest": { - "type": "object", - "properties": { - "user": { - "type": "string", - "description": "user is the name of the user which should be granted a given role." - }, - "role": { - "type": "string", - "description": "role is the name of the role to grant to the user." - } - } - }, - "etcdserverpbAuthUserGrantRoleResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthUserListRequest": { - "type": "object" - }, - "etcdserverpbAuthUserListResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "users": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "etcdserverpbAuthUserRevokeRoleRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "role": { - "type": "string" - } - } - }, - "etcdserverpbAuthUserRevokeRoleResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbAuthenticateRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, - "etcdserverpbAuthenticateResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "token": { - "type": "string", - "title": "token is an authorized token that can be used in succeeding RPCs" - } - } - }, - "etcdserverpbCompactionRequest": { - "type": "object", - "properties": { - "revision": { - "type": "string", - "format": "int64", - "description": "revision is the key-value store revision for the compaction operation." - }, - "physical": { - "type": "boolean", - "format": "boolean", - "description": "physical is set so the RPC will wait until the compaction is physically\napplied to the local database such that compacted entries are totally\nremoved from the backend database." - } - }, - "description": "CompactionRequest compacts the key-value store up to a given revision. All superseded keys\nwith a revision less than the compaction revision will be removed." - }, - "etcdserverpbCompactionResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbCompare": { - "type": "object", - "properties": { - "result": { - "$ref": "#/definitions/CompareCompareResult", - "description": "result is logical comparison operation for this comparison." - }, - "target": { - "$ref": "#/definitions/CompareCompareTarget", - "description": "target is the key-value field to inspect for the comparison." - }, - "key": { - "type": "string", - "format": "byte", - "description": "key is the subject key for the comparison operation." - }, - "version": { - "type": "string", - "format": "int64", - "title": "version is the version of the given key" - }, - "create_revision": { - "type": "string", - "format": "int64", - "title": "create_revision is the creation revision of the given key" - }, - "mod_revision": { - "type": "string", - "format": "int64", - "description": "mod_revision is the last modified revision of the given key." - }, - "value": { - "type": "string", - "format": "byte", - "description": "value is the value of the given key, in bytes." - } - } - }, - "etcdserverpbDefragmentRequest": { - "type": "object" - }, - "etcdserverpbDefragmentResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbDeleteRangeRequest": { - "type": "object", - "properties": { - "key": { - "type": "string", - "format": "byte", - "description": "key is the first key to delete in the range." - }, - "range_end": { - "type": "string", - "format": "byte", - "description": "range_end is the key following the last key to delete for the range [key, range_end).\nIf range_end is not given, the range is defined to contain only the key argument.\nIf range_end is one bit larger than the given key, then the range is all the keys\nwith the prefix (the given key).\nIf range_end is '\\0', the range is all keys greater than or equal to the key argument." - }, - "prev_kv": { - "type": "boolean", - "format": "boolean", - "description": "If prev_kv is set, etcd gets the previous key-value pairs before deleting it.\nThe previous key-value pairs will be returned in the delete response." - } - } - }, - "etcdserverpbDeleteRangeResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "deleted": { - "type": "string", - "format": "int64", - "description": "deleted is the number of keys deleted by the delete range request." - }, - "prev_kvs": { - "type": "array", - "items": { - "$ref": "#/definitions/mvccpbKeyValue" - }, - "description": "if prev_kv is set in the request, the previous key-value pairs will be returned." - } - } - }, - "etcdserverpbHashRequest": { - "type": "object" - }, - "etcdserverpbHashResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "hash": { - "type": "integer", - "format": "int64", - "description": "hash is the hash value computed from the responding member's key-value store." - } - } - }, - "etcdserverpbLeaseGrantRequest": { - "type": "object", - "properties": { - "TTL": { - "type": "string", - "format": "int64", - "description": "TTL is the advisory time-to-live in seconds." - }, - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID." - } - } - }, - "etcdserverpbLeaseGrantResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the lease ID for the granted lease." - }, - "TTL": { - "type": "string", - "format": "int64", - "description": "TTL is the server chosen lease time-to-live in seconds." - }, - "error": { - "type": "string" - } - } - }, - "etcdserverpbLeaseKeepAliveRequest": { - "type": "object", - "properties": { - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the lease ID for the lease to keep alive." - } - } - }, - "etcdserverpbLeaseKeepAliveResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the lease ID from the keep alive request." - }, - "TTL": { - "type": "string", - "format": "int64", - "description": "TTL is the new time-to-live for the lease." - } - } - }, - "etcdserverpbLeaseRevokeRequest": { - "type": "object", - "properties": { - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted." - } - } - }, - "etcdserverpbLeaseRevokeResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbLeaseTimeToLiveRequest": { - "type": "object", - "properties": { - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the lease ID for the lease." - }, - "keys": { - "type": "boolean", - "format": "boolean", - "description": "keys is true to query all the keys attached to this lease." - } - } - }, - "etcdserverpbLeaseTimeToLiveResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "ID": { - "type": "string", - "format": "int64", - "description": "ID is the lease ID from the keep alive request." - }, - "TTL": { - "type": "string", - "format": "int64", - "description": "TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds." - }, - "grantedTTL": { - "type": "string", - "format": "int64", - "description": "GrantedTTL is the initial granted time in seconds upon lease creation/renewal." - }, - "keys": { - "type": "array", - "items": { - "type": "string", - "format": "byte" - }, - "description": "Keys is the list of keys attached to this lease." - } - } - }, - "etcdserverpbLockRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "format": "byte", - "description": "name is the identifier for the distributed shared lock to be acquired." - }, - "lease": { - "type": "string", - "format": "int64", - "description": "lease is the ID of the lease that will be attached to ownership of the lock. If the lease expires or is revoked and currently holds the lock, the lock is automatically released. Calls to Lock with the same lease will be treated as a single acquisition; locking twice with the same lease is a no-op." - } - } - }, - "etcdserverpbLockResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "key": { - "type": "string", - "format": "byte", - "description": "key is a key that will exist on etcd for the duration that the Lock caller owns the lock. Users should not modify this key or the lock may exhibit undefined behavior." - } - } - }, - "etcdserverpbUnlockRequest": { - "type": "object", - "properties": { - "key": { - "type": "string", - "format": "byte", - "description": "key is the lock ownership key granted by Lock." - } - } - }, - "etcdserverpbUnlockResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - } - } - }, - "etcdserverpbMember": { - "type": "object", - "properties": { - "ID": { - "type": "string", - "format": "uint64", - "description": "ID is the member ID for this member." - }, - "name": { - "type": "string", - "description": "name is the human-readable name of the member. If the member is not started, the name will be an empty string." - }, - "peerURLs": { - "type": "array", - "items": { - "type": "string" - }, - "description": "peerURLs is the list of URLs the member exposes to the cluster for communication." - }, - "clientURLs": { - "type": "array", - "items": { - "type": "string" - }, - "description": "clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty." - } - } - }, - "etcdserverpbMemberAddRequest": { - "type": "object", - "properties": { - "peerURLs": { - "type": "array", - "items": { - "type": "string" - }, - "description": "peerURLs is the list of URLs the added member will use to communicate with the cluster." - } - } - }, - "etcdserverpbMemberAddResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "member": { - "$ref": "#/definitions/etcdserverpbMember", - "description": "member is the member information for the added member." - }, - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbMember" - }, - "description": "members is a list of all members after adding the new member." - } - } - }, - "etcdserverpbMemberListRequest": { - "type": "object" - }, - "etcdserverpbMemberListResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbMember" - }, - "description": "members is a list of all members associated with the cluster." - } - } - }, - "etcdserverpbMemberRemoveRequest": { - "type": "object", - "properties": { - "ID": { - "type": "string", - "format": "uint64", - "description": "ID is the member ID of the member to remove." - } - } - }, - "etcdserverpbMemberRemoveResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbMember" - }, - "description": "members is a list of all members after removing the member." - } - } - }, - "etcdserverpbMemberUpdateRequest": { - "type": "object", - "properties": { - "ID": { - "type": "string", - "format": "uint64", - "description": "ID is the member ID of the member to update." - }, - "peerURLs": { - "type": "array", - "items": { - "type": "string" - }, - "description": "peerURLs is the new list of URLs the member will use to communicate with the cluster." - } - } - }, - "etcdserverpbMemberUpdateResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "members": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbMember" - }, - "description": "members is a list of all members after updating the member." - } - } - }, - "etcdserverpbPutRequest": { - "type": "object", - "properties": { - "key": { - "type": "string", - "format": "byte", - "description": "key is the key, in bytes, to put into the key-value store." - }, - "value": { - "type": "string", - "format": "byte", - "description": "value is the value, in bytes, to associate with the key in the key-value store." - }, - "lease": { - "type": "string", - "format": "int64", - "description": "lease is the lease ID to associate with the key in the key-value store. A lease\nvalue of 0 indicates no lease." - }, - "prev_kv": { - "type": "boolean", - "format": "boolean", - "description": "If prev_kv is set, etcd gets the previous key-value pair before changing it.\nThe previous key-value pair will be returned in the put response." - }, - "ignore_value": { - "type": "boolean", - "format": "boolean", - "description": "If ignore_value is set, etcd updates the key using its current value.\nReturns an error if the key does not exist." - }, - "ignore_lease": { - "type": "boolean", - "format": "boolean", - "description": "If ignore_lease is set, etcd updates the key using its current lease.\nReturns an error if the key does not exist." - } - } - }, - "etcdserverpbPutResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "prev_kv": { - "$ref": "#/definitions/mvccpbKeyValue", - "description": "if prev_kv is set in the request, the previous key-value pair will be returned." - } - } - }, - "etcdserverpbRangeRequest": { - "type": "object", - "properties": { - "key": { - "type": "string", - "format": "byte", - "description": "key is the first key for the range. If range_end is not given, the request only looks up key." - }, - "range_end": { - "type": "string", - "format": "byte", - "description": "range_end is the upper bound on the requested range [key, range_end).\nIf range_end is '\\0', the range is all keys \u003e= key.\nIf range_end is key plus one (e.g., \"aa\"+1 == \"ab\", \"a\\xff\"+1 == \"b\"),\nthen the range request gets all keys prefixed with key.\nIf both key and range_end are '\\0', then the range request returns all keys." - }, - "limit": { - "type": "string", - "format": "int64", - "description": "limit is a limit on the number of keys returned for the request. When limit is set to 0,\nit is treated as no limit." - }, - "revision": { - "type": "string", - "format": "int64", - "description": "revision is the point-in-time of the key-value store to use for the range.\nIf revision is less or equal to zero, the range is over the newest key-value store.\nIf the revision has been compacted, ErrCompacted is returned as a response." - }, - "sort_order": { - "$ref": "#/definitions/RangeRequestSortOrder", - "description": "sort_order is the order for returned sorted results." - }, - "sort_target": { - "$ref": "#/definitions/RangeRequestSortTarget", - "description": "sort_target is the key-value field to use for sorting." - }, - "serializable": { - "type": "boolean", - "format": "boolean", - "description": "serializable sets the range request to use serializable member-local reads.\nRange requests are linearizable by default; linearizable requests have higher\nlatency and lower throughput than serializable requests but reflect the current\nconsensus of the cluster. For better performance, in exchange for possible stale reads,\na serializable range request is served locally without needing to reach consensus\nwith other nodes in the cluster." - }, - "keys_only": { - "type": "boolean", - "format": "boolean", - "description": "keys_only when set returns only the keys and not the values." - }, - "count_only": { - "type": "boolean", - "format": "boolean", - "description": "count_only when set returns only the count of the keys in the range." - }, - "min_mod_revision": { - "type": "string", - "format": "int64", - "description": "min_mod_revision is the lower bound for returned key mod revisions; all keys with\nlesser mod revisions will be filtered away." - }, - "max_mod_revision": { - "type": "string", - "format": "int64", - "description": "max_mod_revision is the upper bound for returned key mod revisions; all keys with\ngreater mod revisions will be filtered away." - }, - "min_create_revision": { - "type": "string", - "format": "int64", - "description": "min_create_revision is the lower bound for returned key create revisions; all keys with\nlesser create trevisions will be filtered away." - }, - "max_create_revision": { - "type": "string", - "format": "int64", - "description": "max_create_revision is the upper bound for returned key create revisions; all keys with\ngreater create revisions will be filtered away." - } - } - }, - "etcdserverpbRangeResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "kvs": { - "type": "array", - "items": { - "$ref": "#/definitions/mvccpbKeyValue" - }, - "description": "kvs is the list of key-value pairs matched by the range request.\nkvs is empty when count is requested." - }, - "more": { - "type": "boolean", - "format": "boolean", - "description": "more indicates if there are more keys to return in the requested range." - }, - "count": { - "type": "string", - "format": "int64", - "description": "count is set to the number of keys within the range when requested." - } - } - }, - "etcdserverpbRequestOp": { - "type": "object", - "properties": { - "request_range": { - "$ref": "#/definitions/etcdserverpbRangeRequest" - }, - "request_put": { - "$ref": "#/definitions/etcdserverpbPutRequest" - }, - "request_delete_range": { - "$ref": "#/definitions/etcdserverpbDeleteRangeRequest" - } - } - }, - "etcdserverpbResponseHeader": { - "type": "object", - "properties": { - "cluster_id": { - "type": "string", - "format": "uint64", - "description": "cluster_id is the ID of the cluster which sent the response." - }, - "member_id": { - "type": "string", - "format": "uint64", - "description": "member_id is the ID of the member which sent the response." - }, - "revision": { - "type": "string", - "format": "int64", - "description": "revision is the key-value store revision when the request was applied." - }, - "raft_term": { - "type": "string", - "format": "uint64", - "description": "raft_term is the raft term when the request was applied." - } - } - }, - "etcdserverpbResponseOp": { - "type": "object", - "properties": { - "response_range": { - "$ref": "#/definitions/etcdserverpbRangeResponse" - }, - "response_put": { - "$ref": "#/definitions/etcdserverpbPutResponse" - }, - "response_delete_range": { - "$ref": "#/definitions/etcdserverpbDeleteRangeResponse" - } - } - }, - "etcdserverpbSnapshotRequest": { - "type": "object" - }, - "etcdserverpbSnapshotResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader", - "description": "header has the current key-value store information. The first header in the snapshot\nstream indicates the point in time of the snapshot." - }, - "remaining_bytes": { - "type": "string", - "format": "uint64", - "title": "remaining_bytes is the number of blob bytes to be sent after this message" - }, - "blob": { - "type": "string", - "format": "byte", - "description": "blob contains the next chunk of the snapshot in the snapshot stream." - } - } - }, - "etcdserverpbStatusRequest": { - "type": "object" - }, - "etcdserverpbStatusResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "version": { - "type": "string", - "description": "version is the cluster protocol version used by the responding member." - }, - "dbSize": { - "type": "string", - "format": "int64", - "description": "dbSize is the size of the backend database, in bytes, of the responding member." - }, - "leader": { - "type": "string", - "format": "uint64", - "description": "leader is the member ID which the responding member believes is the current leader." - }, - "raftIndex": { - "type": "string", - "format": "uint64", - "description": "raftIndex is the current raft index of the responding member." - }, - "raftTerm": { - "type": "string", - "format": "uint64", - "description": "raftTerm is the current raft term of the responding member." - } - } - }, - "etcdserverpbTxnRequest": { - "type": "object", - "properties": { - "compare": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbCompare" - }, - "description": "compare is a list of predicates representing a conjunction of terms.\nIf the comparisons succeed, then the success requests will be processed in order,\nand the response will contain their respective responses in order.\nIf the comparisons fail, then the failure requests will be processed in order,\nand the response will contain their respective responses in order." - }, - "success": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbRequestOp" - }, - "description": "success is a list of requests which will be applied when compare evaluates to true." - }, - "failure": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbRequestOp" - }, - "description": "failure is a list of requests which will be applied when compare evaluates to false." - } - }, - "description": "From google paxosdb paper:\nOur implementation hinges around a powerful primitive which we call MultiOp. All other database\noperations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically\nand consists of three components:\n1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check\nfor the absence or presence of a value, or compare with a given value. Two different tests in the guard\nmay apply to the same or different entries in the database. All tests in the guard are applied and\nMultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise\nit executes f op (see item 3 below).\n2. A list of database operations called t op. Each operation in the list is either an insert, delete, or\nlookup operation, and applies to a single database entry. Two different operations in the list may apply\nto the same or different entries in the database. These operations are executed\nif guard evaluates to\ntrue.\n3. A list of database operations called f op. Like t op, but executed if guard evaluates to false." - }, - "etcdserverpbTxnResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "succeeded": { - "type": "boolean", - "format": "boolean", - "description": "succeeded is set to true if the compare evaluated to true or false otherwise." - }, - "responses": { - "type": "array", - "items": { - "$ref": "#/definitions/etcdserverpbResponseOp" - }, - "description": "responses is a list of responses corresponding to the results from applying\nsuccess if succeeded is true or failure if succeeded is false." - } - } - }, - "etcdserverpbWatchCancelRequest": { - "type": "object", - "properties": { - "watch_id": { - "type": "string", - "format": "int64", - "description": "watch_id is the watcher id to cancel so that no more events are transmitted." - } - } - }, - "etcdserverpbWatchCreateRequest": { - "type": "object", - "properties": { - "key": { - "type": "string", - "format": "byte", - "description": "key is the key to register for watching." - }, - "range_end": { - "type": "string", - "format": "byte", - "description": "range_end is the end of the range [key, range_end) to watch. If range_end is not given,\nonly the key argument is watched. If range_end is equal to '\\0', all keys greater than\nor equal to the key argument are watched.\nIf the range_end is one bit larger than the given key,\nthen all keys with the prefix (the given key) will be watched." - }, - "start_revision": { - "type": "string", - "format": "int64", - "description": "start_revision is an optional revision to watch from (inclusive). No start_revision is \"now\"." - }, - "progress_notify": { - "type": "boolean", - "format": "boolean", - "description": "progress_notify is set so that the etcd server will periodically send a WatchResponse with\nno events to the new watcher if there are no recent events. It is useful when clients\nwish to recover a disconnected watcher starting from a recent known revision.\nThe etcd server may decide how often it will send notifications based on current load." - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/definitions/WatchCreateRequestFilterType" - }, - "description": "filters filter the events at server side before it sends back to the watcher." - }, - "prev_kv": { - "type": "boolean", - "format": "boolean", - "description": "If prev_kv is set, created watcher gets the previous KV before the event happens.\nIf the previous KV is already compacted, nothing will be returned." - } - } - }, - "etcdserverpbWatchRequest": { - "type": "object", - "properties": { - "create_request": { - "$ref": "#/definitions/etcdserverpbWatchCreateRequest" - }, - "cancel_request": { - "$ref": "#/definitions/etcdserverpbWatchCancelRequest" - } - } - }, - "etcdserverpbWatchResponse": { - "type": "object", - "properties": { - "header": { - "$ref": "#/definitions/etcdserverpbResponseHeader" - }, - "watch_id": { - "type": "string", - "format": "int64", - "description": "watch_id is the ID of the watcher that corresponds to the response." - }, - "created": { - "type": "boolean", - "format": "boolean", - "description": "created is set to true if the response is for a create watch request.\nThe client should record the watch_id and expect to receive events for\nthe created watcher from the same stream.\nAll events sent to the created watcher will attach with the same watch_id." - }, - "canceled": { - "type": "boolean", - "format": "boolean", - "description": "canceled is set to true if the response is for a cancel watch request.\nNo further events will be sent to the canceled watcher." - }, - "compact_revision": { - "type": "string", - "format": "int64", - "description": "compact_revision is set to the minimum index if a watcher tries to watch\nat a compacted index.\n\nThis happens when creating a watcher at a compacted revision or the watcher cannot\ncatch up with the progress of the key-value store. \n\nThe client should treat the watcher as canceled and should not try to create any\nwatcher with the same start_revision again." - }, - "cancel_reason": { - "type": "string", - "description": "cancel_reason indicates the reason for canceling the watcher." - }, - "events": { - "type": "array", - "items": { - "$ref": "#/definitions/mvccpbEvent" - } - } - } - }, - "mvccpbEvent": { - "type": "object", - "properties": { - "type": { - "$ref": "#/definitions/EventEventType", - "description": "type is the kind of event. If type is a PUT, it indicates\nnew data has been stored to the key. If type is a DELETE,\nit indicates the key was deleted." - }, - "kv": { - "$ref": "#/definitions/mvccpbKeyValue", - "description": "kv holds the KeyValue for the event.\nA PUT event contains current kv pair.\nA PUT event with kv.Version=1 indicates the creation of a key.\nA DELETE/EXPIRE event contains the deleted key with\nits modification revision set to the revision of deletion." - }, - "prev_kv": { - "$ref": "#/definitions/mvccpbKeyValue", - "description": "prev_kv holds the key-value pair before the event happens." - } - } - }, - "mvccpbKeyValue": { - "type": "object", - "properties": { - "key": { - "type": "string", - "format": "byte", - "description": "key is the key in bytes. An empty key is not allowed." - }, - "create_revision": { - "type": "string", - "format": "int64", - "description": "create_revision is the revision of last creation on this key." - }, - "mod_revision": { - "type": "string", - "format": "int64", - "description": "mod_revision is the revision of last modification on this key." - }, - "version": { - "type": "string", - "format": "int64", - "description": "version is the version of the key. A deletion resets\nthe version to zero and any modification of the key\nincreases its version." - }, - "value": { - "type": "string", - "format": "byte", - "description": "value is the value held by the key, in bytes." - }, - "lease": { - "type": "string", - "format": "int64", - "description": "lease is the ID of the lease that attached to key.\nWhen the attached lease expires, the key will be deleted.\nIf lease is 0, then no lease is attached to the key." - } - } - } - } -} diff --git a/etcd3/stateful/lock.py b/etcd3/stateful/lock.py index 4846e9b..7a82ff3 100644 --- a/etcd3/stateful/lock.py +++ b/etcd3/stateful/lock.py @@ -9,6 +9,7 @@ from .watch import EventType from ..errors import ErrLeaseNotFound from ..utils import log +from ..utils import get_ident class EtcdLockError(Exception): @@ -65,7 +66,7 @@ def _get_uuid(self): elif self.reentrant == self.PROCESS: return '%s:proc:%s' % (hostname, os.getpid()) elif self.reentrant == self.THREAD: - return '%s:thrd:%s' % (hostname, threading.get_ident()) + return '%s:thrd:%s' % (hostname, get_ident()) elif self.reentrant == self.HOST: return self._get_global_uuid('%s:host:%s' % (hostname, socket.gethostbyname(hostname))) else: diff --git a/etcd3/stateful/watch.py b/etcd3/stateful/watch.py index e34b33b..7e6f63f 100644 --- a/etcd3/stateful/watch.py +++ b/etcd3/stateful/watch.py @@ -12,6 +12,7 @@ from ..errors import Etcd3WatchCanceled from ..models import EventEventType from ..utils import check_param +from ..utils import get_ident from ..utils import log EventType = EventEventType @@ -152,6 +153,12 @@ def clear_revision(self): self.start_revision = None self.revision = None + def clear_callbacks(self): + """ + Remove all callbacks + """ + self.callbacks = [] + def request_create(self): """ Start a watch request @@ -223,12 +230,6 @@ def onEvent(self, filter_or_cb, cb=None): raise TypeError('callback should be a callable') self.callbacks.append((self.get_filter(filter), filter, cb)) - def clear_callbacks(self): - """ - Remove all callbacks - """ - self.callbacks = [] - def dispatch_event(self, event): """ Find the callbacks, if callback's filter fits this event, call the callback @@ -247,14 +248,14 @@ def _ensure_callbacks(self): def _ensure_not_watching(self): if self.watching is True: raise RuntimeError("already watching") - if self._thread and self._thread.is_alive() and self._thread.ident != threading.get_ident(): + if self._thread and self._thread.is_alive() and self._thread.ident != get_ident(): raise RuntimeError("watch thread seems running") def _kill_response_stream(self): if not self._resp or (self._resp and self._resp.raw.closed): return try: - log.debug("killing response stream") + log.debug("closing response stream") self.request_cancel() s = socket.fromfd(self._resp.raw._fp.fileno(), socket.AF_INET, socket.SOCK_STREAM) s.shutdown(socket.SHUT_RDWR) @@ -284,7 +285,7 @@ def stop(self): log.debug("stop watching") self.watching = False self._kill_response_stream() - if self._thread and self._thread.is_alive() and self._thread.ident != threading.get_ident(): + if self._thread and self._thread.is_alive() and self._thread.ident != get_ident(): self._thread.join() cancel = stop @@ -356,7 +357,8 @@ def __iter__(self): log.debug("watch request created") self.start_revision = r.header.revision self.watch_id = r.watch_id - if 'canceled' in r and r.canceled: + if ('canceled' in r and r.canceled) or ('compact_revision' in r and r.compact_revision): + # etcd version < 3.3 returns compact_revision without canceled compacted = False if 'compact_revision' in r and r.compact_revision > 0: compacted = True diff --git a/etcd3/utils.py b/etcd3/utils.py index bf7f90c..fff0bb7 100644 --- a/etcd3/utils.py +++ b/etcd3/utils.py @@ -17,6 +17,11 @@ except ImportError: from typing import Hashable +try: # pragma: no cover + from threading import get_ident +except: + from thread import get_ident + try: # pragma: no cover from inspect import getfullargspec as getargspec except ImportError: # pragma: no cover diff --git a/requirements_py3.txt b/requirements_py3.txt index 9cceb84..31edbb4 100644 --- a/requirements_py3.txt +++ b/requirements_py3.txt @@ -1,2 +1,2 @@ -r requirements.txt -aiohttp>=3.0.7 +aiohttp>=3.0.0 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..44387a3 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,5 @@ +import sys + +collect_ignore = [] +if sys.version_info[0] < 3: + collect_ignore.append("test_py3") diff --git a/tests/test_watch_util.py b/tests/test_watch_util.py index 9103d93..b5bd138 100644 --- a/tests/test_watch_util.py +++ b/tests/test_watch_util.py @@ -115,7 +115,7 @@ def test_watcher(client): # test ensure callbacks with pytest.raises(TypeError): - w.callbacks.clear() + w.clear_callbacks() w.runDaemon() @@ -151,7 +151,6 @@ def test_watcher_watch_once_and_cancel_handling(client): assert w.revision == old_revision + 10 # test watch cancel handling - compact_revision = client.hash().header.revision etcdctl("compaction --physical %s" % compact_revision) with pytest.raises(Etcd3WatchCanceled): @@ -168,23 +167,29 @@ def test_watcher_watch_once_and_cancel_handling(client): @pytest.mark.timeout(60) def test_watcher_rewatch_on_compaction(client): # compaction while re-watching - w = client.Watcher(all=True) + etcdctl('del', '--from-key', '') + w = client.Watcher("foo") + assert w.revision is None + assert w.start_revision is None times = 3 with w: etcdctl('put foo bare') revision = None for e in w: + assert w.revision + assert w.start_revision if not times: break - assert e.key == b'foo' - assert e.value == b'bare' if revision: assert e.header.revision == revision + 11 + assert e.key == b'foo' + assert e.value == b'bare' revision = e.header.revision for i in range(10): # these event will be compacted etcdctl('put foo %s' % i) etcdctl('put foo bare') # will receive this event when re-watch client.compact(client.hash().header.revision, True) + assert client.hash().header.revision == revision + 11 # etcdctl("compaction --physical %s" % client.hash().header.revision) times -= 1 w._kill_response_stream() # trigger a re-watch