Skip to content

Commit

Permalink
Support replication of site replication state changes
Browse files Browse the repository at this point in the history
While few remote sites are down, any changes to the site
replication state e.g. `ReplicateILMExpiry` flag should
get replicated to site when it's back online. This would
be done exactly before healing any ILM rules changes during
remote sites were down, so that these flags are taken in
consideration.

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat committed Nov 3, 2023
1 parent 59a7fea commit 8fb3f68
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions cluster-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ type SiteReplicationInfo struct {
Name string `json:"name,omitempty"`
Sites []PeerInfo `json:"sites,omitempty"`
ServiceAccountAccessKey string `json:"serviceAccountAccessKey,omitempty"`
ReplicateILMExpiry bool `json:"replicate-ilm-expiry"`
}

// SiteReplicationInfo - returns cluster replication information.
Expand Down Expand Up @@ -155,7 +154,7 @@ type SRPeerJoinReq struct {
SvcAcctSecretKey string `json:"svcAcctSecretKey"`
SvcAcctParent string `json:"svcAcctParent"`
Peers map[string]PeerInfo `json:"peers"`
ReplicateILMExpiry bool `json:"replicate-ilm-expiry"`
UpdatedAt time.Time `json:"updatedAt"`
}

// PeerInfo - contains some properties of a cluster peer.
Expand Down Expand Up @@ -983,6 +982,36 @@ func (adm *AdminClient) SRPeerEdit(ctx context.Context, pi PeerInfo) error {
return nil
}

// SRStateEdit - used only by minio server to update peer state
// for a server already in the site replication setup
func (adm *AdminClient) SRStateEdit(ctx context.Context, state SRStateEditReq) error {
b, err := json.Marshal(state)
if err != nil {
return err
}

q := make(url.Values)
q.Set("api-version", SiteReplAPIVersion)

reqData := requestData{
relPath: adminAPIPrefix + "/site-replication/state/edit",
content: b,
queryValues: q,
}

resp, err := adm.executeMethod(ctx, http.MethodPut, reqData)
defer closeResponse(resp)
if err != nil {
return err
}

if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp)
}

return nil
}

// SiteReplicationRemove - unlinks a site from site replication
func (adm *AdminClient) SiteReplicationRemove(ctx context.Context, removeReq SRRemoveReq) (st ReplicateRemoveStatus, err error) {
rmvBytes, err := json.Marshal(removeReq)
Expand Down Expand Up @@ -1053,6 +1082,12 @@ type SRRemoveReq struct {
RemoveAll bool `json:"all"` // true if all sites are to be removed.
}

// SRStateEditReq - arg body for SRStateEditReq
type SRStateEditReq struct {
Peers map[string]PeerInfo `json:"peers"`
UpdatedAt time.Time `json:"updatedAt"`
}

const (
ReplicateRemoveStatusSuccess = "Requested site(s) were removed from cluster replication successfully."
ReplicateRemoveStatusPartial = "Some site(s) could not be removed from cluster replication configuration."
Expand Down

0 comments on commit 8fb3f68

Please sign in to comment.