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 de…
Browse files Browse the repository at this point in the history
…lete_device
  • Loading branch information
rishubhjain committed Dec 1, 2018
2 parents 4e01500 + d996927 commit 91f0e56
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion e2e/smartvol_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func testDeviceDelete(t *testing.T) {
for _, peer := range peerList {
deviceList, err = client.DeviceList(peer.ID.String())
r.Nil(err)
if len(deviceList) > 1 {
if len(deviceList) > 0 {
peerID = peer.ID.String()
break
}
Expand Down
3 changes: 0 additions & 3 deletions glusterd2/volgen/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ func init() {
{
Type: "debug/io-stats",
NameTmpl: "{{ volume.name }}",
Options: map[string]string{
"log-level": "DEBUG",
},
},
{
Type: "features/read-only",
Expand Down
31 changes: 23 additions & 8 deletions glusterd2/volgen/volgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type Entry struct {
// NamePrefix will be used to set prefix for xlator section
// name if Name is not set.
NamePrefix string
// NameSuffix will be used to set suffix for xlator section
// name if Name is not set.
NameSuffix string
// XlatorData represents the Xlator object with all the
// necessory information.
XlatorData Xlator
Expand Down Expand Up @@ -57,6 +60,12 @@ func (e *Entry) SetNamePrefix(name string) *Entry {
return e
}

// SetNameSuffix sets name prefix
func (e *Entry) SetNameSuffix(name string) *Entry {
e.NameSuffix = name
return e
}

// Generate generates Volfile content
func (v *Volfile) Generate() (string, error) {
return v.RootEntry.Generate()
Expand All @@ -80,18 +89,18 @@ func setNameAndType(entry *Entry) error {
if entry.Name == "" {
// If Xlator name template is not specified, construct the xlator
// graph name as <volume-name>-<xlator-suffix>
prefix := entry.NamePrefix
if prefix != "" {
prefix = prefix + "-"
}
entry.Name = entry.NamePrefix

if entry.NamePrefix == "" {
volname, exists := entry.VarStrData["volume.name"]
if exists {
prefix = volname + "-"
entry.Name = volname + "-" + entry.XlatorData.suffix()
}
}
entry.Name = prefix + entry.XlatorData.suffix()

if entry.NameSuffix != "" {
entry.Name = entry.Name + "-" + entry.NameSuffix
}
}
return nil
}
Expand Down Expand Up @@ -279,14 +288,19 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
// cluster/distribute graph again. Directly assign
// brick entries to main cluster/distribute itself
sentry := entry
svname := ""
if sv.Type != volume.SubvolDistribute || (sv.Type == volume.SubvolDistribute && numSubvols > 1) {
for _, sxl := range subvolXlators {
if !sxl.OnlyLocalBricks || (sxl.OnlyLocalBricks && numberOfLocalBricks > 0) {
svname = sxl.suffix() + "-" + strconv.Itoa(sidx)
sentry = sentry.Add(sxl, utils.MergeStringMaps(
*varStrData,
sv.StringMap(),
extraStringMaps.Subvols[sidx].StringMap,
)).SetNamePrefix(sv.Name)
)).SetNamePrefix(volinfo.Name).SetNameSuffix(svname)

// Set name for future use while adding brick entries
svname = volinfo.Name + "-" + svname
}
}
}
Expand Down Expand Up @@ -321,7 +335,8 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
map[string]string{"remote-port": remotePort},
)
}
bentry = bentry.Add(bxl, bopts).SetNamePrefix(sv.Name + "-" + strconv.Itoa(bidx))
bentry = bentry.Add(bxl, bopts).SetNamePrefix(svname).
SetNameSuffix(bxl.suffix() + "-" + strconv.Itoa(bidx))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/restclient/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package restclient
import (
"fmt"
"net/http"
"strings"

deviceapi "github.com/gluster/glusterd2/plugins/device/api"
)
Expand Down

0 comments on commit 91f0e56

Please sign in to comment.