Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions interfaces/admin/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,16 @@ components:

CreateRaftGroupMemberParameters:
description: >-
Request to add another DSS node to a Raft group. This request is sent to a member of the group, which does not
know the node to add yet: the client passes it as `node`, as returned by
`GET /admin/v1/raft/groups/{group_name}/this_node` on the node to add.
Request to add another DSS node to a Raft group. This request is sent to a member of the group, which reads the
ID of the node to add from the node itself, at its URL.
type: object
required:
- node
- url
properties:
node:
$ref: '#/components/schemas/RaftNode'
replaces:
description: >-
ID of a node with the same URL and in the `member` state that the node replaces, e.g. after it lost its data directory.
Without it, adding a node whose URL is already used by a member is rejected.
The replaced member is not removed by this request: it must be removed once the node is added.
url:
description: URL at which the members of the Raft group send Raft messages to the node to add.
type: string
example: "5740029381146209443"
example: https://0.db.interuss.example.com:9500

CreateRaftGroupParameters:
description: >-
Expand Down Expand Up @@ -218,8 +212,8 @@ paths:
summary: Add a node to a Raft group, as a voter
description: >-
The request must be sent to a member of the group, and the node to add is another DSS node, which must be
running and waiting: as soon as it is added, it counts in the quorum of the group. A node started with an empty
data directory waits to be added. The request returns once the change is adopted by the group.
running and waiting: this member reads the ID of the node from the node itself, then adds it.
A node started with an empty data directory waits to be added. The request returns once the change is adopted by the group.
operationId: createRaftGroupMember
tags: [ raft ]
requestBody:
Expand Down Expand Up @@ -247,6 +241,20 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'409':
description: >-
The node at this URL is not waiting or does not run this Raft group in this cluster, or the URL is already
used by another member of the group.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'503':
description: The node cannot be reached at this URL, or this DSS node is not a member of the Raft group.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'

/admin/v1/raft/groups/{group_name}/members/{node_id}:
parameters:
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/adminv1/client.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ func (c *Client) CreateRaftGroupMember(ctx context.Context, groupName RaftGroupN
case 404:
response.Response404 = new(ErrorResponse)
err = json.NewDecoder(resp.Body).Decode(response.Response404)
case 409:
response.Response409 = new(ErrorResponse)
err = json.NewDecoder(resp.Body).Decode(response.Response409)
case 503:
response.Response503 = new(ErrorResponse)
err = json.NewDecoder(resp.Body).Decode(response.Response503)
case 500:
response.Response500 = new(api.InternalServerErrorBody)
err = json.NewDecoder(resp.Body).Decode(response.Response500)
Expand Down
8 changes: 7 additions & 1 deletion pkg/api/adminv1/interface.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ type CreateRaftGroupMemberResponseSet struct {
// This DSS node has no Raft group with this name, e.g. `scd` when it runs without `--enable_scd`.
Response404 *ErrorResponse

// The node at this URL is not waiting or does not run this Raft group in this cluster, or the URL is already used by another member of the group.
Response409 *ErrorResponse

// The node cannot be reached at this URL, or this DSS node is not a member of the Raft group.
Response503 *ErrorResponse

// Auto-generated internal server error response
Response500 *api.InternalServerErrorBody
}
Expand Down Expand Up @@ -173,7 +179,7 @@ type Implementation interface {

// Add a node to a Raft group, as a voter
// ---
// The request must be sent to a member of the group, and the node to add is another DSS node, which must be running and waiting: as soon as it is added, it counts in the quorum of the group. A node started with an empty data directory waits to be added. The request returns once the change is adopted by the group.
// The request must be sent to a member of the group, and the node to add is another DSS node, which must be running and waiting: this member reads the ID of the node from the node itself, then adds it. A node started with an empty data directory waits to be added. The request returns once the change is adopted by the group.
CreateRaftGroupMember(ctx context.Context, req *CreateRaftGroupMemberRequest) CreateRaftGroupMemberResponseSet

// Remove a node from a Raft group
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/adminv1/server.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ func (s *APIRouter) CreateRaftGroupMember(exp *regexp.Regexp, w http.ResponseWri
api.WriteJSON(w, 404, response.Response404)
return
}
if response.Response409 != nil {
api.WriteJSON(w, 409, response.Response409)
return
}
if response.Response503 != nil {
api.WriteJSON(w, 503, response.Response503)
return
}
if response.Response500 != nil {
api.WriteJSON(w, 500, response.Response500)
return
Expand Down
8 changes: 3 additions & 5 deletions pkg/api/adminv1/types.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ type RaftNode struct {
State string `json:"state"`
}

// Request to add another DSS node to a Raft group. This request is sent to a member of the group, which does not know the node to add yet: the client passes it as `node`, as returned by `GET /admin/v1/raft/groups/{group_name}/this_node` on the node to add.
// Request to add another DSS node to a Raft group. This request is sent to a member of the group, which reads the ID of the node to add from the node itself, at its URL.
type CreateRaftGroupMemberParameters struct {
Node RaftNode `json:"node"`

// ID of a node with the same URL and in the `member` state that the node replaces, e.g. after it lost its data directory. Without it, adding a node whose URL is already used by a member is rejected. The replaced member is not removed by this request: it must be removed once the node is added.
Replaces *string `json:"replaces,omitempty"`
// URL at which the members of the Raft group send Raft messages to the node to add.
Url string `json:"url"`
}

// Request to create a Raft group with this DSS node as its only member. Used for bootstrapping a new Raft group, which is then joined by the other nodes one at a time.
Expand Down
Loading