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

Commit a6cd208

Browse files
committed
Merge branch 'master' of https://github.com/gluster/glusterd2 into delete_device
2 parents 17496a8 + 5f88917 commit a6cd208

37 files changed

+2134
-93
lines changed

doc/transaction.md

Lines changed: 413 additions & 0 deletions
Large diffs are not rendered by default.

glusterd2/commands/peers/peer-rpc-svc.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import (
88
"github.com/gluster/glusterd2/glusterd2/peer"
99
"github.com/gluster/glusterd2/glusterd2/servers/peerrpc"
1010
"github.com/gluster/glusterd2/glusterd2/store"
11+
"github.com/gluster/glusterd2/glusterd2/transactionv2"
12+
"github.com/gluster/glusterd2/glusterd2/transactionv2/cleanuphandler"
1113
"github.com/gluster/glusterd2/glusterd2/volume"
1214
"github.com/gluster/glusterd2/pkg/utils"
13-
"github.com/pborman/uuid"
1415

16+
"github.com/pborman/uuid"
1517
log "github.com/sirupsen/logrus"
1618
"google.golang.org/grpc"
1719
)
@@ -169,6 +171,8 @@ func ReconfigureStore(c *StoreConfig) error {
169171

170172
// Stop events framework
171173
events.Stop()
174+
transaction.StopTxnEngine()
175+
cleanuphandler.StopCleanupLeader()
172176

173177
// do not delete cluster namespace if this is not a loner node
174178
var deleteNamespace bool
@@ -217,7 +221,8 @@ func ReconfigureStore(c *StoreConfig) error {
217221

218222
// Now that new store is up, start events framework
219223
events.Start()
220-
224+
transaction.StartTxnEngine()
225+
cleanuphandler.StartCleanupLeader()
221226
return nil
222227
}
223228

glusterd2/commands/snapshot/snapshot-activate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) {
152152
DoFunc: "snap-activate.StoreSnapshot",
153153
UndoFunc: "snap-activate.UndoStoreSnapshot",
154154
Nodes: []uuid.UUID{gdctx.MyUUID},
155+
Sync: true,
155156
},
156157
}
157158
if err = txn.Do(); err != nil {

glusterd2/commands/snapshot/snapshot-clone.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) {
322322
{
323323
DoFunc: "snap-clone.CreateCloneVolinfo",
324324
Nodes: []uuid.UUID{gdctx.MyUUID},
325+
Sync: true,
325326
},
326327
{
327328
DoFunc: "snap-clone.TakeBrickSnapshots",
@@ -332,6 +333,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) {
332333
DoFunc: "snap-clone.StoreSnapshot",
333334
UndoFunc: "snap-clone.UndoStoreSnapshotOnClone",
334335
Nodes: []uuid.UUID{gdctx.MyUUID},
336+
Sync: true,
335337
},
336338
}
337339
if err = txn.Ctx.Set("snapname", &snapname); err != nil {

glusterd2/commands/snapshot/snapshot-create.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) {
763763
{
764764
DoFunc: "snap-create.CreateSnapinfo",
765765
Nodes: []uuid.UUID{gdctx.MyUUID},
766+
Sync: true,
766767
},
767768
{
768769
DoFunc: "snap-create.ActivateBarrier",
@@ -774,6 +775,8 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) {
774775
DoFunc: "snap-create.TakeBrickSnapshots",
775776
UndoFunc: "snap-create.UndoBrickSnapshots",
776777
Nodes: txn.Nodes,
778+
// All bricks need to be barriered before taking a snapshot
779+
Sync: true,
777780
},
778781
{
779782
DoFunc: "snap-create.DeactivateBarrier",
@@ -784,6 +787,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) {
784787
DoFunc: "snap-create.StoreSnapshot",
785788
UndoFunc: "snap-create.UndoStoreSnapshotOnCreate",
786789
Nodes: []uuid.UUID{gdctx.MyUUID},
790+
Sync: true,
787791
},
788792
}
789793

glusterd2/commands/snapshot/snapshot-deactivate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) {
148148
DoFunc: "snap-deactivate.StoreSnapshot",
149149
UndoFunc: "snap-deactivate.UndoStoreSnapshot",
150150
Nodes: []uuid.UUID{gdctx.MyUUID},
151+
Sync: true,
151152
},
152153
}
153154
if err = txn.Ctx.Set("oldsnapinfo", &snapinfo); err != nil {

glusterd2/commands/snapshot/snapshot-delete.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func snapshotDeleteHandler(w http.ResponseWriter, r *http.Request) {
161161
{
162162
DoFunc: "snap-delete.Store",
163163
Nodes: []uuid.UUID{gdctx.MyUUID},
164+
Sync: true,
164165
},
165166
}
166167

glusterd2/commands/snapshot/snapshot-restore.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ func snapshotRestoreHandler(w http.ResponseWriter, r *http.Request) {
364364
DoFunc: "snap-restore.Store",
365365
UndoFunc: "snap-restore.UndoStore",
366366
Nodes: []uuid.UUID{gdctx.MyUUID},
367+
Sync: true,
367368
},
368369
{
369370
DoFunc: "snap-restore.CleanBricks",

glusterd2/commands/volumes/brick-replace.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ LOOP:
161161
{
162162
DoFunc: "brick-replace.ReplaceVolinfo",
163163
Nodes: []uuid.UUID{gdctx.MyUUID},
164+
Sync: true,
164165
},
165166
{
166167
DoFunc: "vol-create.InitBricks",
@@ -175,6 +176,7 @@ LOOP:
175176
DoFunc: "vol-create.StoreVolume",
176177
UndoFunc: "vol-create.UndoStoreVolume",
177178
Nodes: []uuid.UUID{gdctx.MyUUID},
179+
Sync: true,
178180
},
179181
{
180182
DoFunc: "vol-expand.NotifyClients",

glusterd2/commands/volumes/common.go

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"io/ioutil"
89
"os"
10+
"path"
911
"path/filepath"
12+
"strings"
1013

1114
"github.com/gluster/glusterd2/glusterd2/brick"
1215
"github.com/gluster/glusterd2/glusterd2/gdctx"
@@ -22,6 +25,7 @@ import (
2225

2326
"github.com/pborman/uuid"
2427
log "github.com/sirupsen/logrus"
28+
config "github.com/spf13/viper"
2529
"golang.org/x/sys/unix"
2630
)
2731

@@ -302,8 +306,43 @@ func undoStoreVolume(c transaction.TxnCtx) error {
302306
return storeVolInfo(c, "oldvolinfo")
303307
}
304308

305-
// LoadDefaultGroupOptions loads the default group option map into the store
306-
func LoadDefaultGroupOptions() error {
309+
func loadDefaultGroupOptions() error {
310+
defaultProfilesPath := path.Join(config.GetString("localstatedir"), "templates", "profiles.json")
311+
// If directory not exists, create the directory and then generate default templates
312+
_, err := os.Stat(defaultProfilesPath)
313+
if os.IsNotExist(err) {
314+
content, err := json.MarshalIndent(defaultGroupOptions, "", " ")
315+
if err != nil {
316+
return err
317+
}
318+
319+
err = os.MkdirAll(path.Dir(defaultProfilesPath), os.ModeDir|os.ModePerm)
320+
if err != nil {
321+
return err
322+
}
323+
return ioutil.WriteFile(defaultProfilesPath, content, 0640)
324+
} else if err == nil {
325+
content, err := ioutil.ReadFile(defaultProfilesPath)
326+
if err != nil {
327+
return err
328+
}
329+
var grpOpts map[string]*api.OptionGroup
330+
err = json.Unmarshal(content, &grpOpts)
331+
if err != nil {
332+
return err
333+
}
334+
defaultGroupOptions = grpOpts
335+
return nil
336+
}
337+
return err
338+
}
339+
340+
// InitDefaultGroupOptions loads the default group option map into the store
341+
func InitDefaultGroupOptions() error {
342+
err := loadDefaultGroupOptions()
343+
if err != nil {
344+
return err
345+
}
307346
groupOptions, err := json.Marshal(defaultGroupOptions)
308347
if err != nil {
309348
return err
@@ -380,3 +419,23 @@ func txnGenerateBrickVolfiles(c transaction.TxnCtx) error {
380419
}
381420
return nil
382421
}
422+
423+
func containsReservedGroupProfile(opts interface{}) bool {
424+
pfx := "profile.default."
425+
switch value := opts.(type) {
426+
case map[string]string:
427+
for k := range value {
428+
if strings.HasPrefix(k, pfx) {
429+
return true
430+
}
431+
}
432+
case []string:
433+
for _, v := range value {
434+
if strings.HasPrefix(v, pfx) {
435+
return true
436+
}
437+
}
438+
}
439+
440+
return false
441+
}

0 commit comments

Comments
 (0)