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 13, 2018
2 parents 17496a8 + 5f88917 commit fb3f69a
Show file tree
Hide file tree
Showing 39 changed files with 2,150 additions and 104 deletions.
413 changes: 413 additions & 0 deletions doc/transaction.md

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions glusterd2/commands/peers/peer-rpc-svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"github.com/gluster/glusterd2/glusterd2/peer"
"github.com/gluster/glusterd2/glusterd2/servers/peerrpc"
"github.com/gluster/glusterd2/glusterd2/store"
"github.com/gluster/glusterd2/glusterd2/transactionv2"
"github.com/gluster/glusterd2/glusterd2/transactionv2/cleanuphandler"
"github.com/gluster/glusterd2/glusterd2/volume"
"github.com/gluster/glusterd2/pkg/utils"
"github.com/pborman/uuid"

"github.com/pborman/uuid"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -169,6 +171,8 @@ func ReconfigureStore(c *StoreConfig) error {

// Stop events framework
events.Stop()
transaction.StopTxnEngine()
cleanuphandler.StopCleanupLeader()

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

// Now that new store is up, start events framework
events.Start()

transaction.StartTxnEngine()
cleanuphandler.StartCleanupLeader()
return nil
}

Expand Down
1 change: 1 addition & 0 deletions glusterd2/commands/snapshot/snapshot-activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) {
DoFunc: "snap-activate.StoreSnapshot",
UndoFunc: "snap-activate.UndoStoreSnapshot",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
}
if err = txn.Do(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions glusterd2/commands/snapshot/snapshot-clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) {
{
DoFunc: "snap-clone.CreateCloneVolinfo",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
{
DoFunc: "snap-clone.TakeBrickSnapshots",
Expand All @@ -332,6 +333,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) {
DoFunc: "snap-clone.StoreSnapshot",
UndoFunc: "snap-clone.UndoStoreSnapshotOnClone",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
}
if err = txn.Ctx.Set("snapname", &snapname); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions glusterd2/commands/snapshot/snapshot-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) {
{
DoFunc: "snap-create.CreateSnapinfo",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
{
DoFunc: "snap-create.ActivateBarrier",
Expand All @@ -774,6 +775,8 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) {
DoFunc: "snap-create.TakeBrickSnapshots",
UndoFunc: "snap-create.UndoBrickSnapshots",
Nodes: txn.Nodes,
// All bricks need to be barriered before taking a snapshot
Sync: true,
},
{
DoFunc: "snap-create.DeactivateBarrier",
Expand All @@ -784,6 +787,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) {
DoFunc: "snap-create.StoreSnapshot",
UndoFunc: "snap-create.UndoStoreSnapshotOnCreate",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
}

Expand Down
1 change: 1 addition & 0 deletions glusterd2/commands/snapshot/snapshot-deactivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) {
DoFunc: "snap-deactivate.StoreSnapshot",
UndoFunc: "snap-deactivate.UndoStoreSnapshot",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
}
if err = txn.Ctx.Set("oldsnapinfo", &snapinfo); err != nil {
Expand Down
1 change: 1 addition & 0 deletions glusterd2/commands/snapshot/snapshot-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func snapshotDeleteHandler(w http.ResponseWriter, r *http.Request) {
{
DoFunc: "snap-delete.Store",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
}

Expand Down
1 change: 1 addition & 0 deletions glusterd2/commands/snapshot/snapshot-restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ func snapshotRestoreHandler(w http.ResponseWriter, r *http.Request) {
DoFunc: "snap-restore.Store",
UndoFunc: "snap-restore.UndoStore",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
{
DoFunc: "snap-restore.CleanBricks",
Expand Down
2 changes: 2 additions & 0 deletions glusterd2/commands/volumes/brick-replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ LOOP:
{
DoFunc: "brick-replace.ReplaceVolinfo",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
{
DoFunc: "vol-create.InitBricks",
Expand All @@ -175,6 +176,7 @@ LOOP:
DoFunc: "vol-create.StoreVolume",
UndoFunc: "vol-create.UndoStoreVolume",
Nodes: []uuid.UUID{gdctx.MyUUID},
Sync: true,
},
{
DoFunc: "vol-expand.NotifyClients",
Expand Down
63 changes: 61 additions & 2 deletions glusterd2/commands/volumes/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"

"github.com/gluster/glusterd2/glusterd2/brick"
"github.com/gluster/glusterd2/glusterd2/gdctx"
Expand All @@ -22,6 +25,7 @@ import (

"github.com/pborman/uuid"
log "github.com/sirupsen/logrus"
config "github.com/spf13/viper"
"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -302,8 +306,43 @@ func undoStoreVolume(c transaction.TxnCtx) error {
return storeVolInfo(c, "oldvolinfo")
}

// LoadDefaultGroupOptions loads the default group option map into the store
func LoadDefaultGroupOptions() error {
func loadDefaultGroupOptions() error {
defaultProfilesPath := path.Join(config.GetString("localstatedir"), "templates", "profiles.json")
// If directory not exists, create the directory and then generate default templates
_, err := os.Stat(defaultProfilesPath)
if os.IsNotExist(err) {
content, err := json.MarshalIndent(defaultGroupOptions, "", " ")
if err != nil {
return err
}

err = os.MkdirAll(path.Dir(defaultProfilesPath), os.ModeDir|os.ModePerm)
if err != nil {
return err
}
return ioutil.WriteFile(defaultProfilesPath, content, 0640)
} else if err == nil {
content, err := ioutil.ReadFile(defaultProfilesPath)
if err != nil {
return err
}
var grpOpts map[string]*api.OptionGroup
err = json.Unmarshal(content, &grpOpts)
if err != nil {
return err
}
defaultGroupOptions = grpOpts
return nil
}
return err
}

// InitDefaultGroupOptions loads the default group option map into the store
func InitDefaultGroupOptions() error {
err := loadDefaultGroupOptions()
if err != nil {
return err
}
groupOptions, err := json.Marshal(defaultGroupOptions)
if err != nil {
return err
Expand Down Expand Up @@ -380,3 +419,23 @@ func txnGenerateBrickVolfiles(c transaction.TxnCtx) error {
}
return nil
}

func containsReservedGroupProfile(opts interface{}) bool {
pfx := "profile.default."
switch value := opts.(type) {
case map[string]string:
for k := range value {
if strings.HasPrefix(k, pfx) {
return true
}
}
case []string:
for _, v := range value {
if strings.HasPrefix(v, pfx) {
return true
}
}
}

return false
}
Loading

0 comments on commit fb3f69a

Please sign in to comment.