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

Commit 91f0e56

Browse files
committed
Merge branch 'master' of https://github.com/gluster/glusterd2 into delete_device
2 parents 4e01500 + d996927 commit 91f0e56

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

e2e/smartvol_ops_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func testDeviceDelete(t *testing.T) {
327327
for _, peer := range peerList {
328328
deviceList, err = client.DeviceList(peer.ID.String())
329329
r.Nil(err)
330-
if len(deviceList) > 1 {
330+
if len(deviceList) > 0 {
331331
peerID = peer.ID.String()
332332
break
333333
}

glusterd2/volgen/defaults.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ func init() {
103103
{
104104
Type: "debug/io-stats",
105105
NameTmpl: "{{ volume.name }}",
106-
Options: map[string]string{
107-
"log-level": "DEBUG",
108-
},
109106
},
110107
{
111108
Type: "features/read-only",

glusterd2/volgen/volgen.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ type Entry struct {
2121
// NamePrefix will be used to set prefix for xlator section
2222
// name if Name is not set.
2323
NamePrefix string
24+
// NameSuffix will be used to set suffix for xlator section
25+
// name if Name is not set.
26+
NameSuffix string
2427
// XlatorData represents the Xlator object with all the
2528
// necessory information.
2629
XlatorData Xlator
@@ -57,6 +60,12 @@ func (e *Entry) SetNamePrefix(name string) *Entry {
5760
return e
5861
}
5962

63+
// SetNameSuffix sets name prefix
64+
func (e *Entry) SetNameSuffix(name string) *Entry {
65+
e.NameSuffix = name
66+
return e
67+
}
68+
6069
// Generate generates Volfile content
6170
func (v *Volfile) Generate() (string, error) {
6271
return v.RootEntry.Generate()
@@ -80,18 +89,18 @@ func setNameAndType(entry *Entry) error {
8089
if entry.Name == "" {
8190
// If Xlator name template is not specified, construct the xlator
8291
// graph name as <volume-name>-<xlator-suffix>
83-
prefix := entry.NamePrefix
84-
if prefix != "" {
85-
prefix = prefix + "-"
86-
}
92+
entry.Name = entry.NamePrefix
8793

8894
if entry.NamePrefix == "" {
8995
volname, exists := entry.VarStrData["volume.name"]
9096
if exists {
91-
prefix = volname + "-"
97+
entry.Name = volname + "-" + entry.XlatorData.suffix()
9298
}
9399
}
94-
entry.Name = prefix + entry.XlatorData.suffix()
100+
101+
if entry.NameSuffix != "" {
102+
entry.Name = entry.Name + "-" + entry.NameSuffix
103+
}
95104
}
96105
return nil
97106
}
@@ -279,14 +288,19 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
279288
// cluster/distribute graph again. Directly assign
280289
// brick entries to main cluster/distribute itself
281290
sentry := entry
291+
svname := ""
282292
if sv.Type != volume.SubvolDistribute || (sv.Type == volume.SubvolDistribute && numSubvols > 1) {
283293
for _, sxl := range subvolXlators {
284294
if !sxl.OnlyLocalBricks || (sxl.OnlyLocalBricks && numberOfLocalBricks > 0) {
295+
svname = sxl.suffix() + "-" + strconv.Itoa(sidx)
285296
sentry = sentry.Add(sxl, utils.MergeStringMaps(
286297
*varStrData,
287298
sv.StringMap(),
288299
extraStringMaps.Subvols[sidx].StringMap,
289-
)).SetNamePrefix(sv.Name)
300+
)).SetNamePrefix(volinfo.Name).SetNameSuffix(svname)
301+
302+
// Set name for future use while adding brick entries
303+
svname = volinfo.Name + "-" + svname
290304
}
291305
}
292306
}
@@ -321,7 +335,8 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
321335
map[string]string{"remote-port": remotePort},
322336
)
323337
}
324-
bentry = bentry.Add(bxl, bopts).SetNamePrefix(sv.Name + "-" + strconv.Itoa(bidx))
338+
bentry = bentry.Add(bxl, bopts).SetNamePrefix(svname).
339+
SetNameSuffix(bxl.suffix() + "-" + strconv.Itoa(bidx))
325340
}
326341
}
327342
}

pkg/restclient/device.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package restclient
33
import (
44
"fmt"
55
"net/http"
6+
"strings"
67

78
deviceapi "github.com/gluster/glusterd2/plugins/device/api"
89
)

0 commit comments

Comments
 (0)