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

Commit

Permalink
volgen: volgen changes for glustershd
Browse files Browse the repository at this point in the history
Fixes: #1111 and #1190
Signed-off-by: Aravinda VK <avishwan@redhat.com>
  • Loading branch information
aravindavk authored and Atin Mukherjee committed Nov 9, 2018
1 parent 95db1b2 commit d4dd56b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
21 changes: 20 additions & 1 deletion plugins/glustershd/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path"

"github.com/gluster/glusterd2/glusterd2/daemon"
"github.com/gluster/glusterd2/glusterd2/volgen"
"github.com/gluster/glusterd2/glusterd2/volume"
"github.com/gluster/glusterd2/glusterd2/xlator"
gderrors "github.com/gluster/glusterd2/pkg/errors"
Expand Down Expand Up @@ -48,7 +49,13 @@ func (actor *shdActor) Do(v *volume.Volinfo, key string, value string, volOp xla
return nil
}
}
err := daemon.Start(glustershDaemon, true, logger)

err = volgen.ClusterVolfileToFile(v, glustershDaemon.VolfileID, "glustershd")
if err != nil {
return err
}

err = daemon.Start(glustershDaemon, true, logger)
if err != nil && err != gderrors.ErrProcessAlreadyRunning {
return err
}
Expand Down Expand Up @@ -82,6 +89,10 @@ func (actor *shdActor) Do(v *volume.Volinfo, key string, value string, volOp xla
switch value {
case "on":
if isHealEnabled(v) {
err = volgen.ClusterVolfileToFile(v, glustershDaemon.VolfileID, "glustershd")
if err != nil {
return err
}
err = daemon.Start(glustershDaemon, true, logger)
if err != nil && err != gderrors.ErrProcessAlreadyRunning {
return err
Expand Down Expand Up @@ -144,6 +155,10 @@ func (actor *shdActor) Undo(v *volume.Volinfo, key string, value string, volOp x
}

case xlator.VolumeStop:
err = volgen.ClusterVolfileToFile(v, glustershDaemon.VolfileID, "glustershd")
if err != nil {
return err
}
err = daemon.Start(glustershDaemon, true, logger)
if err != nil && err != gderrors.ErrProcessAlreadyRunning {
return err
Expand All @@ -165,6 +180,10 @@ func (actor *shdActor) Undo(v *volume.Volinfo, key string, value string, volOp x
switch value {
case "off":
if isHealEnabled(v) {
err = volgen.ClusterVolfileToFile(v, glustershDaemon.VolfileID, "glustershd")
if err != nil {
return err
}
err = daemon.Start(glustershDaemon, true, logger)
if err != nil && err != gderrors.ErrProcessAlreadyRunning {
return err
Expand Down
9 changes: 5 additions & 4 deletions plugins/glustershd/glustershd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Glustershd struct {
args []string
socketfilepath string
pidfilepath string
VolfileID string
}

// Name returns human-friendly name of the glustershd process. This is used for
Expand All @@ -37,17 +38,17 @@ func (shd *Glustershd) Path() string {

// Args returns arguments to be passed to glustershd process during spawn.
func (shd *Glustershd) Args() []string {
shost, _, _ := net.SplitHostPort(config.GetString("clientaddress"))
shost, sport, _ := net.SplitHostPort(config.GetString("clientaddress"))
if shost == "" {
shost = "localhost"
}
volFileID := "gluster/glustershd"

logFile := path.Join(config.GetString("logdir"), "glusterfs", "glustershd.log")

shd.args = []string{}
shd.args = append(shd.args, "-s", shost)
shd.args = append(shd.args, "--volfile-id", volFileID)
shd.args = append(shd.args, "--volfile-server-port", sport)
shd.args = append(shd.args, "--volfile-id", shd.VolfileID)
shd.args = append(shd.args, "-p", shd.PidFile())
shd.args = append(shd.args, "-l", logFile)
shd.args = append(shd.args, "-S", shd.SocketFile())
Expand Down Expand Up @@ -87,7 +88,7 @@ func newGlustershd() (*Glustershd, error) {
if e != nil {
return nil, e
}
glustershdObject := &Glustershd{binarypath: path}
glustershdObject := &Glustershd{binarypath: path, VolfileID: "gluster/glustershd"}
return glustershdObject, nil
}

Expand Down

0 comments on commit d4dd56b

Please sign in to comment.