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

Commit

Permalink
Merge branch 'master' of https://github.com/gluster/glusterd2 into re…
Browse files Browse the repository at this point in the history
…balance
  • Loading branch information
rishubhjain committed Jul 12, 2018
2 parents ef84e98 + 2b38ce4 commit 083371d
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 103 deletions.
11 changes: 0 additions & 11 deletions constants/constants.go

This file was deleted.

15 changes: 11 additions & 4 deletions doc/quick-start-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,26 @@ These packages require dependencies present in [EPEL](https://fedoraproject.org/
Install packages that provide GlusterFS server (brick process) and client (fuse, libgfapi):

```sh
# curl -o /etc/yum.repos.d/glusterfs-nighthly-master.repo http://artifacts.ci.centos.org/gluster/nightly/master.repo
# curl -o /etc/yum.repos.d/glusterfs-nightly-master.repo http://artifacts.ci.centos.org/gluster/nightly/master.repo
# yum install glusterfs-server glusterfs-fuse glusterfs-api
```

### Download glusterd2

Glusterd2 is a single binary without any external dependencies. Like all Go programs, dependencies are statically linked. You can download the [latest release](https://github.com/gluster/glusterd2/releases) from Github.
As we do not have releases often, our nightly RPMs are generally more stable
as they contain the latest fixes. If you are on centos 7, you can download the
latest glusterd2 nightly RPM using the following method:

```sh
$ wget https://github.com/gluster/glusterd2/releases/download/v4.0dev-7/glusterd2-v4.0dev-7-linux-amd64.tar.xz
$ tar -xf glusterd2-v4.0dev-7-linux-amd64.tar.xz
# curl -o /etc/yum.repos.d/glusterd2-nightly-master.repo http://artifacts.ci.centos.org/gluster/gd2-nightly/gd2-master.repo
# yum install glusterd2
```

Alternatlively, if you are using a non-RPM based distro, you can download
binaries of the latest release. Like all Go programs, glusterd2 is a single
binary (statically linked) without external dependencies. You can download the
[latest release](https://github.com/gluster/glusterd2/releases) from Github.

### Running glusterd2

**Create a working directory:** This is where glusterd2 will store all data which includes logs, pid files, etcd information etc. For this example, we will be using a temporary path. If a working directory is not specified, it defaults to current directory.
Expand Down
84 changes: 50 additions & 34 deletions glustercli/cmd/georep.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,27 +274,27 @@ func (a *georepAction) String() string {
}

func handleGeorepAction(args []string, action georepAction) {
masterdata, remotedata, err := getVolIDs(args)
masterVolID, remoteVolID, err := getVolIDs(args)
if err != nil {
failure(fmt.Sprintf("Geo-replication %s failed.\n", action.String()), err, 1)
}
switch action {
case georepStart:
_, err = client.GeorepStart(masterdata.id, remotedata.id, flagGeorepCmdForce)
_, err = client.GeorepStart(masterVolID, remoteVolID, flagGeorepCmdForce)
case georepStop:
_, err = client.GeorepStop(masterdata.id, remotedata.id, flagGeorepCmdForce)
_, err = client.GeorepStop(masterVolID, remoteVolID, flagGeorepCmdForce)
case georepPause:
_, err = client.GeorepPause(masterdata.id, remotedata.id, flagGeorepCmdForce)
_, err = client.GeorepPause(masterVolID, remoteVolID, flagGeorepCmdForce)
case georepResume:
_, err = client.GeorepResume(masterdata.id, remotedata.id, flagGeorepCmdForce)
_, err = client.GeorepResume(masterVolID, remoteVolID, flagGeorepCmdForce)
case georepDelete:
err = client.GeorepDelete(masterdata.id, remotedata.id, flagGeorepCmdForce)
err = client.GeorepDelete(masterVolID, remoteVolID, flagGeorepCmdForce)
}

if err != nil {
if verbose {
log.WithFields(log.Fields{
"volume": masterdata.volname,
"volume": args[0],
"error": err.Error(),
}).Error("geo-replication", action.String(), "failed")
}
Expand Down Expand Up @@ -363,33 +363,49 @@ func getRemoteClient(host string) (string, *restclient.Client, error) {
return clienturl, restclient.New(clienturl, "", "", "", true), nil
}

func getVolIDs(pargs []string) (*volumeDetails, *volumeDetails, error) {
var masterdata *volumeDetails
var remotedata *volumeDetails
var err error
func getVolIDs(pargs []string) (string, string, error) {
var (
masterVolID string
remoteVolID string
)

allSessions, err := client.GeorepStatus("", "")
if err != nil {
failure(errGeorepStatusCommandFailed, err, 1)
}

if len(pargs) >= 1 {
masterdata, err = getVolumeDetails(pargs[0], nil)
if err != nil {
return nil, nil, err
for _, s := range allSessions {
if s.MasterVol == pargs[0] {
masterVolID = s.MasterID.String()
}
}
if masterVolID == "" {
return "", "", errors.New("failed to get master volume info")
}
}

if len(pargs) >= 2 {
_, remotehost, remotevol, err := parseRemoteData(pargs[1])
if err != nil {
return nil, nil, err
return "", "", err
}
_, rclient, err := getRemoteClient(remotehost)
if err != nil {
return nil, nil, err

for _, s := range allSessions {
if s.RemoteVol == remotevol {

for _, host := range s.RemoteHosts {
if host.Hostname == remotehost {
remoteVolID = s.RemoteID.String()
}
}
}
}
remotedata, err = getVolumeDetails(remotevol, rclient)
if err != nil {
return nil, nil, err
if remoteVolID == "" {
return "", "", errors.New("failed to get remote volume info")
}
}
return masterdata, remotedata, nil
return masterVolID, remoteVolID, nil
}

var georepStatusCmd = &cobra.Command{
Expand All @@ -398,23 +414,23 @@ var georepStatusCmd = &cobra.Command{
Args: cobra.RangeArgs(0, 2),
Run: func(cmd *cobra.Command, args []string) {
var err error
masterdata, remotedata, err := getVolIDs(args)
masterVolID, remoteVolID, err := getVolIDs(args)
if err != nil {
failure(errGeorepStatusCommandFailed, err, 1)
}

var sessions []georepapi.GeorepSession
// If mastervolid or remotevolid is empty then get status of all and then filter
if masterdata == nil || remotedata == nil {
// If masterVolID or remoteVolID is empty then get status of all and then filter
if masterVolID == "" || remoteVolID == "" {
allSessions, err := client.GeorepStatus("", "")
if err != nil {
failure(errGeorepStatusCommandFailed, err, 1)
}
for _, s := range allSessions {
if masterdata != nil && s.MasterID.String() != masterdata.id {
if masterVolID != "" && s.MasterID.String() != masterVolID {
continue
}
if remotedata != nil && s.RemoteID.String() != remotedata.id {
if remoteVolID != "" && s.RemoteID.String() != remoteVolID {
continue
}
sessionDetail, err := client.GeorepStatus(s.MasterID.String(), s.RemoteID.String())
Expand All @@ -424,7 +440,7 @@ var georepStatusCmd = &cobra.Command{
sessions = append(sessions, sessionDetail[0])
}
} else {
sessions, err = client.GeorepStatus(masterdata.id, remotedata.id)
sessions, err = client.GeorepStatus(masterVolID, remoteVolID)
if err != nil {
failure(errGeorepStatusCommandFailed, err, 1)
}
Expand Down Expand Up @@ -469,12 +485,12 @@ var georepGetCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
var err error

masterdata, remotedata, err := getVolIDs(args)
masterVolID, remoteVolID, err := getVolIDs(args)
if err != nil {
failure("Error getting Volume IDs", err, 1)
}

opts, err := client.GeorepGet(masterdata.id, remotedata.id)
opts, err := client.GeorepGet(masterVolID, remoteVolID)
if err != nil {
failure("Error getting Options", err, 1)
}
Expand Down Expand Up @@ -540,15 +556,15 @@ var georepSetCmd = &cobra.Command{
Args: cobra.ExactArgs(4),
Run: func(cmd *cobra.Command, args []string) {
var err error
masterdata, remotedata, err := getVolIDs(args)
masterVolID, remoteVolID, err := getVolIDs(args)
if err != nil {
failure("Error getting Volume IDs", err, 1)
}

opts := make(map[string]string)
opts[args[2]] = args[3]

err = client.GeorepSet(masterdata.id, remotedata.id, opts)
err = client.GeorepSet(masterVolID, remoteVolID, opts)
if err != nil {
failure("Geo-replication session config set failed", err, 1)
}
Expand All @@ -562,12 +578,12 @@ var georepResetCmd = &cobra.Command{
Args: cobra.MinimumNArgs(3),
Run: func(cmd *cobra.Command, args []string) {
var err error
masterdata, remotedata, err := getVolIDs(args)
masterVolID, remoteVolID, err := getVolIDs(args)
if err != nil {
failure(err.Error(), err, 1)
}

err = client.GeorepReset(masterdata.id, remotedata.id, args[2:])
err = client.GeorepReset(masterVolID, remoteVolID, args[2:])
if err != nil {
failure("Geo-replication session config reset failed", err, 1)
}
Expand Down
Loading

0 comments on commit 083371d

Please sign in to comment.