Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

[WIP] API to Enable/Disable peer #1121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions glusterd2/commands/peers/addpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func addPeerHandler(w http.ResponseWriter, r *http.Request) {
newpeer.Metadata[key] = value
}

if req.Disabled {
newpeer.Disabled = req.Disabled
}

//check if remotePeerAddress already present
found := utils.StringInSlice(remotePeerAddress, newpeer.PeerAddresses)
//if not found prepend the remotePeerAddress to peer details
Expand Down Expand Up @@ -142,6 +146,7 @@ func createPeerAddResp(p *peer.Peer) *api.PeerAddResp {
Name: p.Name,
PeerAddresses: p.PeerAddresses,
ClientAddresses: p.ClientAddresses,
Disabled: p.Disabled,
Metadata: p.Metadata,
}
}
1 change: 1 addition & 0 deletions glusterd2/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Peer struct {
Name string
PeerAddresses []string
ClientAddresses []string
Disabled bool
Metadata map[string]string
}

Expand Down
3 changes: 2 additions & 1 deletion glusterd2/peer/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ func AddSelfDetails() error {
if err == errors.ErrPeerNotFound {
p.Metadata = make(map[string]string)
p.Metadata["_zone"] = p.ID.String()
p.Disabled = false

} else if err == nil && peerInfo != nil {
p.Metadata = peerInfo.Metadata

p.Disabled = peerInfo.Disabled
found := utils.StringInSlice(p.PeerAddresses[0], peerInfo.PeerAddresses)
if !found {
p.PeerAddresses = append(peerInfo.PeerAddresses, p.PeerAddresses...)
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/peer_req_resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ type Peer struct {
ClientAddresses []string `json:"client-addresses"`
Online bool `json:"online"`
PID int `json:"pid,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Metadata map[string]string `json:"metadata"`
}

// PeerAddReq represents an incoming request to add a peer to the cluster
type PeerAddReq struct {
Addresses []string `json:"addresses"`
Zone string `json:"zone,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}

Expand Down