From fba332e1ba1479c0e722ba2acd3ac39678312c37 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 10:49:10 +0530 Subject: [PATCH 1/7] Rename glusterd2/transaction to glusterd2/oldtransaction --- .../commands/options/setclusteroptions.go | 4 +-- glusterd2/commands/peers/editpeer.go | 12 +++---- glusterd2/commands/snapshot/common.go | 8 ++--- .../commands/snapshot/snapshot-activate.go | 18 +++++----- glusterd2/commands/snapshot/snapshot-clone.go | 22 ++++++------ .../commands/snapshot/snapshot-create.go | 28 +++++++-------- .../commands/snapshot/snapshot-deactivate.go | 18 +++++----- .../commands/snapshot/snapshot-delete.go | 14 ++++---- .../commands/snapshot/snapshot-restore.go | 20 +++++------ .../commands/snapshot/snapshot-status.go | 12 +++---- .../commands/volumes/brick-replace-txn.go | 8 ++--- glusterd2/commands/volumes/brick-replace.go | 10 +++--- glusterd2/commands/volumes/bricks-status.go | 12 +++---- glusterd2/commands/volumes/common.go | 20 +++++------ .../commands/volumes/volume-create-txn.go | 6 ++-- glusterd2/commands/volumes/volume-create.go | 8 ++--- glusterd2/commands/volumes/volume-delete.go | 10 +++--- glusterd2/commands/volumes/volume-edit.go | 4 +-- .../commands/volumes/volume-expand-txn.go | 12 +++---- glusterd2/commands/volumes/volume-expand.go | 10 +++--- glusterd2/commands/volumes/volume-option.go | 30 ++++++++-------- glusterd2/commands/volumes/volume-profile.go | 10 +++--- glusterd2/commands/volumes/volume-reset.go | 10 +++--- .../commands/volumes/volume-smartvol-txn.go | 16 ++++----- glusterd2/commands/volumes/volume-start.go | 12 +++---- .../commands/volumes/volume-statedump.go | 10 +++--- glusterd2/commands/volumes/volume-stop.go | 10 +++--- .../context.go | 2 +- .../context_mock.go | 2 +- .../{transaction => oldtransaction}/lock.go | 2 +- .../registry.go | 2 +- .../rpc-client.go | 2 +- .../rpc-service.go | 2 +- .../{transaction => oldtransaction}/step.go | 2 +- .../transaction-rpc.pb.go | 2 +- .../transaction-rpc.proto | 0 .../transaction.go | 2 +- glusterd2/servers/rest/utils/utils.go | 4 +-- glusterd2/servers/sunrpc/callback.go | 8 ++--- glusterd2/transactionv2/steprunner.go | 16 ++++----- glusterd2/transactionv2/steptracing.go | 6 ++-- glusterd2/transactionv2/transaction.go | 34 +++++++++---------- glusterd2/transactionv2/txnmanager.go | 12 +++---- plugins/bitrot/init.go | 10 +++--- plugins/bitrot/rest.go | 20 +++++------ plugins/bitrot/transactions.go | 8 ++--- .../gluster-virtblock/gluster_virtblock.go | 6 ++-- .../blockvolume/hostvol/hostvol_manager.go | 4 +-- plugins/blockvolume/hostvol/utils.go | 4 +-- plugins/device/deviceutils/store-utils.go | 6 ++-- plugins/device/init.go | 4 +-- plugins/device/rest.go | 8 ++--- plugins/device/transaction.go | 8 ++--- plugins/events/rest.go | 12 +++---- plugins/georeplication/init.go | 24 ++++++------- plugins/georeplication/rest.go | 34 +++++++++---------- plugins/georeplication/transactions.go | 28 +++++++-------- plugins/glustershd/init.go | 4 +-- plugins/glustershd/rest.go | 8 ++--- plugins/glustershd/transactions.go | 4 +-- plugins/rebalance/eventnotify.go | 4 +-- plugins/rebalance/init.go | 10 +++--- plugins/rebalance/rest.go | 16 ++++----- plugins/rebalance/transaction.go | 10 +++--- plugins/tracemgmt/init.go | 14 ++++---- plugins/tracemgmt/rest.go | 8 ++--- plugins/tracemgmt/transactions.go | 16 ++++----- 67 files changed, 361 insertions(+), 361 deletions(-) rename glusterd2/{transaction => oldtransaction}/context.go (99%) rename glusterd2/{transaction => oldtransaction}/context_mock.go (98%) rename glusterd2/{transaction => oldtransaction}/lock.go (99%) rename glusterd2/{transaction => oldtransaction}/registry.go (97%) rename glusterd2/{transaction => oldtransaction}/rpc-client.go (98%) rename glusterd2/{transaction => oldtransaction}/rpc-service.go (98%) rename glusterd2/{transaction => oldtransaction}/step.go (99%) rename glusterd2/{transaction => oldtransaction}/transaction-rpc.pb.go (99%) rename glusterd2/{transaction => oldtransaction}/transaction-rpc.proto (100%) rename glusterd2/{transaction => oldtransaction}/transaction.go (99%) diff --git a/glusterd2/commands/options/setclusteroptions.go b/glusterd2/commands/options/setclusteroptions.go index cb2772478..41ba0ca5b 100644 --- a/glusterd2/commands/options/setclusteroptions.go +++ b/glusterd2/commands/options/setclusteroptions.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/options" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" ) @@ -24,7 +24,7 @@ func setClusterOptionsHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, lockKey) + txn, err := oldtransaction.NewTxnWithLocks(ctx, lockKey) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) diff --git a/glusterd2/commands/peers/editpeer.go b/glusterd2/commands/peers/editpeer.go index 56a9d9855..0af7ee669 100644 --- a/glusterd2/commands/peers/editpeer.go +++ b/glusterd2/commands/peers/editpeer.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -41,7 +41,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) { } } - txn, err := transaction.NewTxnWithLocks(ctx, peerID) + txn, err := oldtransaction.NewTxnWithLocks(ctx, peerID) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -49,7 +49,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) { } defer txn.Done() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "peer-edit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -85,7 +85,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) { } -func txnPeerEdit(c transaction.TxnCtx) error { +func txnPeerEdit(c oldtransaction.TxnCtx) error { var peerID string if err := c.Get("peerid", &peerID); err != nil { c.Logger().WithError(err).WithField("key", "peerID").Error("Failed to get key from transaction context") @@ -134,12 +134,12 @@ func txnPeerEdit(c transaction.TxnCtx) error { func registerPeerEditStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"peer-edit", txnPeerEdit}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } diff --git a/glusterd2/commands/snapshot/common.go b/glusterd2/commands/snapshot/common.go index d73fd5805..800badcc2 100644 --- a/glusterd2/commands/snapshot/common.go +++ b/glusterd2/commands/snapshot/common.go @@ -1,22 +1,22 @@ package snapshotcommands import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" ) // undoStoreSnapshot revert back snapinfo and to generate client volfile -func undoStoreSnapshot(c transaction.TxnCtx) error { +func undoStoreSnapshot(c oldtransaction.TxnCtx) error { return storeSnapinfo(c, "oldsnapinfo") } // StoreSnapahot uses to store the snapinfo and to generate client volfile -func storeSnapshot(c transaction.TxnCtx) error { +func storeSnapshot(c oldtransaction.TxnCtx) error { return storeSnapinfo(c, "snapinfo") } // storeSnapInfo uses to store the snapinfo based on key and to generate client volfile -func storeSnapinfo(c transaction.TxnCtx, key string) error { +func storeSnapinfo(c oldtransaction.TxnCtx, key string) error { var snapinfo snapshot.Snapinfo if err := c.Get(key, &snapinfo); err != nil { diff --git a/glusterd2/commands/snapshot/snapshot-activate.go b/glusterd2/commands/snapshot/snapshot-activate.go index 6ccce5bd5..f2bc71205 100644 --- a/glusterd2/commands/snapshot/snapshot-activate.go +++ b/glusterd2/commands/snapshot/snapshot-activate.go @@ -7,9 +7,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -19,7 +19,7 @@ import ( log "github.com/sirupsen/logrus" ) -func activateSnapshot(c transaction.TxnCtx) error { +func activateSnapshot(c oldtransaction.TxnCtx) error { var snapinfo snapshot.Snapinfo activate := true @@ -53,7 +53,7 @@ func activateSnapshot(c transaction.TxnCtx) error { return err } -func rollbackActivateSnapshot(c transaction.TxnCtx) error { +func rollbackActivateSnapshot(c oldtransaction.TxnCtx) error { activate := false var snapinfo snapshot.Snapinfo var brickinfos []brick.Brickinfo @@ -85,10 +85,10 @@ func rollbackActivateSnapshot(c transaction.TxnCtx) error { } func registerSnapActivateStepFuncs() { - transaction.RegisterStepFunc(activateSnapshot, "snap-activate.Commit") - transaction.RegisterStepFunc(rollbackActivateSnapshot, "snap-activate.Undo") - transaction.RegisterStepFunc(storeSnapshot, "snap-activate.StoreSnapshot") - transaction.RegisterStepFunc(undoStoreSnapshot, "snap-activate.UndoStoreSnapshot") + oldtransaction.RegisterStepFunc(activateSnapshot, "snap-activate.Commit") + oldtransaction.RegisterStepFunc(rollbackActivateSnapshot, "snap-activate.Undo") + oldtransaction.RegisterStepFunc(storeSnapshot, "snap-activate.StoreSnapshot") + oldtransaction.RegisterStepFunc(undoStoreSnapshot, "snap-activate.UndoStoreSnapshot") } @@ -99,7 +99,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) { snapname := mux.Vars(r)["snapname"] - txn, err := transaction.NewTxnWithLocks(ctx, snapname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -142,7 +142,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) { //Populating Nodes neeed not be under lock, because snapshot is a read only config txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-activate.Commit", UndoFunc: "snap-activate.Undo", diff --git a/glusterd2/commands/snapshot/snapshot-clone.go b/glusterd2/commands/snapshot/snapshot-clone.go index 9b9719567..acc8c0f9c 100644 --- a/glusterd2/commands/snapshot/snapshot-clone.go +++ b/glusterd2/commands/snapshot/snapshot-clone.go @@ -6,9 +6,9 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -20,7 +20,7 @@ import ( config "github.com/spf13/viper" ) -func undoSnapshotClone(c transaction.TxnCtx) error { +func undoSnapshotClone(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -38,7 +38,7 @@ func undoSnapshotClone(c transaction.TxnCtx) error { return nil } -func undoStoreSnapshotClone(c transaction.TxnCtx) error { +func undoStoreSnapshotClone(c oldtransaction.TxnCtx) error { var ( vol volume.Volinfo err error @@ -52,7 +52,7 @@ func undoStoreSnapshotClone(c transaction.TxnCtx) error { return err } -func storeSnapshotClone(c transaction.TxnCtx) error { +func storeSnapshotClone(c oldtransaction.TxnCtx) error { var vol volume.Volinfo if err := c.Get("volinfo", &vol); err != nil { return err @@ -65,7 +65,7 @@ func storeSnapshotClone(c transaction.TxnCtx) error { return nil } -func takeSnapshotClone(c transaction.TxnCtx) error { +func takeSnapshotClone(c oldtransaction.TxnCtx) error { var snapname string var newVol volume.Volinfo @@ -135,7 +135,7 @@ func populateCloneBrickMountData(volinfo *volume.Volinfo, name string) (map[stri return nodeData, nil } -func validateSnapClone(c transaction.TxnCtx) error { +func validateSnapClone(c oldtransaction.TxnCtx) error { var ( statusStr []string err error @@ -190,7 +190,7 @@ func validateSnapClone(c transaction.TxnCtx) error { return nil } -func createCloneVolinfo(c transaction.TxnCtx) error { +func createCloneVolinfo(c oldtransaction.TxnCtx) error { var clonename, snapname string nodeData := make(map[string]snapshot.BrickMountData) @@ -253,7 +253,7 @@ func snapshotCloneBrickCreate(cloneName, brickDirSuffix string, subvolNumber, br func registerSnapCloneStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"snap-clone.Validate", validateSnapClone}, {"snap-clone.CreateCloneVolinfo", createCloneVolinfo}, @@ -263,7 +263,7 @@ func registerSnapCloneStepFuncs() { {"snap-clone.UndoStoreSnapshotOnClone", undoStoreSnapshotClone}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -288,7 +288,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, req.CloneName, snapname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, req.CloneName, snapname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -316,7 +316,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) { return } txn.Nodes = snapVol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-clone.Validate", Nodes: txn.Nodes, diff --git a/glusterd2/commands/snapshot/snapshot-create.go b/glusterd2/commands/snapshot/snapshot-create.go index 4c69b5fbd..8fbba00cb 100644 --- a/glusterd2/commands/snapshot/snapshot-create.go +++ b/glusterd2/commands/snapshot/snapshot-create.go @@ -21,10 +21,10 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" @@ -102,7 +102,7 @@ func barrierActivateDeactivateFunc(volinfo *volume.Volinfo, option string, origi } return nil } -func deactivateBarrier(c transaction.TxnCtx) error { +func deactivateBarrier(c oldtransaction.TxnCtx) error { var barrierOp string var snapInfo snapshot.Snapinfo if err := c.Get("barrier-enabled", &barrierOp); err != nil { @@ -136,7 +136,7 @@ func deactivateBarrier(c transaction.TxnCtx) error { } -func activateBarrier(c transaction.TxnCtx) error { +func activateBarrier(c oldtransaction.TxnCtx) error { var barrierOp string var snapInfo snapshot.Snapinfo if err := c.Get("barrier-enabled", &barrierOp); err != nil { @@ -171,7 +171,7 @@ func activateBarrier(c transaction.TxnCtx) error { return err } -func undoBrickSnapshots(c transaction.TxnCtx) error { +func undoBrickSnapshots(c oldtransaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -189,7 +189,7 @@ func undoBrickSnapshots(c transaction.TxnCtx) error { return nil } -func undoStoreSnapshotOnCreate(c transaction.TxnCtx) error { +func undoStoreSnapshotOnCreate(c oldtransaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -208,7 +208,7 @@ func undoStoreSnapshotOnCreate(c transaction.TxnCtx) error { } // storeSnapshot uses to store the volinfo and to generate client volfile -func storeSnapshotCreate(c transaction.TxnCtx) error { +func storeSnapshotCreate(c oldtransaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -316,7 +316,7 @@ func populateSnapBrickMountData(volinfo *volume.Volinfo, snapName string) (map[s return nodeData, nil } -func validateSnapCreate(c transaction.TxnCtx) error { +func validateSnapCreate(c oldtransaction.TxnCtx) error { var ( statusStr []string err error @@ -455,7 +455,7 @@ func brickSnapshot(errCh chan error, wg *sync.WaitGroup, snapBrick, b brick.Bric return } -func takeSnapshots(c transaction.TxnCtx) error { +func takeSnapshots(c oldtransaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -517,7 +517,7 @@ func createSnapSubvols(newVolinfo, origVolinfo *volume.Volinfo, nodeData map[str return nil } -func createSnapinfo(c transaction.TxnCtx) error { +func createSnapinfo(c oldtransaction.TxnCtx) error { var data txnData ignoreOps := map[string]string{ "features/quota": "off", @@ -646,7 +646,7 @@ func snapshotBrickCreate(snapName, volName, brickDirSuffix string, subvolNumber, return brickPath } -func validateOriginNodeSnapCreate(c transaction.TxnCtx) error { +func validateOriginNodeSnapCreate(c oldtransaction.TxnCtx) error { var data txnData if err := c.Get("data", &data); err != nil { @@ -690,7 +690,7 @@ func validateOriginNodeSnapCreate(c transaction.TxnCtx) error { func registerSnapCreateStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"snap-create.Validate", validateSnapCreate}, {"snap-create.CreateSnapinfo", createSnapinfo}, @@ -702,7 +702,7 @@ func registerSnapCreateStepFuncs() { {"snap-create.UndoStoreSnapshotOnCreate", undoStoreSnapshotOnCreate}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -732,7 +732,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, req.VolName, req.SnapName) + txn, err := oldtransaction.NewTxnWithLocks(ctx, req.VolName, req.SnapName) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -763,7 +763,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-create.Validate", Nodes: txn.Nodes, diff --git a/glusterd2/commands/snapshot/snapshot-deactivate.go b/glusterd2/commands/snapshot/snapshot-deactivate.go index 5fa9095f9..1cb68738f 100644 --- a/glusterd2/commands/snapshot/snapshot-deactivate.go +++ b/glusterd2/commands/snapshot/snapshot-deactivate.go @@ -5,9 +5,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -18,7 +18,7 @@ import ( log "github.com/sirupsen/logrus" ) -func deactivateSnapshot(c transaction.TxnCtx) error { +func deactivateSnapshot(c oldtransaction.TxnCtx) error { var snapinfo snapshot.Snapinfo if err := c.Get("oldsnapinfo", &snapinfo); err != nil { @@ -71,7 +71,7 @@ func deactivateSnapshot(c transaction.TxnCtx) error { } -func rollbackDeactivateSnapshot(c transaction.TxnCtx) error { +func rollbackDeactivateSnapshot(c oldtransaction.TxnCtx) error { activate := true var snapinfo snapshot.Snapinfo var brickinfos []brick.Brickinfo @@ -102,10 +102,10 @@ func rollbackDeactivateSnapshot(c transaction.TxnCtx) error { } func registerSnapDeactivateStepFuncs() { - transaction.RegisterStepFunc(deactivateSnapshot, "snap-deactivate.Commit") - transaction.RegisterStepFunc(rollbackDeactivateSnapshot, "snap-deactivate.Undo") - transaction.RegisterStepFunc(storeSnapshot, "snap-deactivate.StoreSnapshot") - transaction.RegisterStepFunc(undoStoreSnapshot, "snap-deactivate.UndoStoreSnapshot") + oldtransaction.RegisterStepFunc(deactivateSnapshot, "snap-deactivate.Commit") + oldtransaction.RegisterStepFunc(rollbackDeactivateSnapshot, "snap-deactivate.Undo") + oldtransaction.RegisterStepFunc(storeSnapshot, "snap-deactivate.StoreSnapshot") + oldtransaction.RegisterStepFunc(undoStoreSnapshot, "snap-deactivate.UndoStoreSnapshot") } @@ -116,7 +116,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) { snapname := mux.Vars(r)["snapname"] - txn, err := transaction.NewTxnWithLocks(ctx, snapname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -138,7 +138,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-deactivate.Commit", UndoFunc: "snap-deactivate.Undo", diff --git a/glusterd2/commands/snapshot/snapshot-delete.go b/glusterd2/commands/snapshot/snapshot-delete.go index dbca0ab36..d4c0593ae 100644 --- a/glusterd2/commands/snapshot/snapshot-delete.go +++ b/glusterd2/commands/snapshot/snapshot-delete.go @@ -8,9 +8,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/lvmutils" @@ -49,7 +49,7 @@ func snapshotBrickDelete(errCh chan error, wg *sync.WaitGroup, snapVol volume.Vo return } -func snapshotDelete(c transaction.TxnCtx) error { +func snapshotDelete(c oldtransaction.TxnCtx) error { var snapinfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapinfo); err != nil { return err @@ -81,7 +81,7 @@ func snapshotDelete(c transaction.TxnCtx) error { return err } -func snapshotDeleteStore(c transaction.TxnCtx) error { +func snapshotDeleteStore(c oldtransaction.TxnCtx) error { var ( snapinfo snapshot.Snapinfo @@ -105,7 +105,7 @@ snapshot if something fails. func registerSnapDeleteStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"snap-delete.Commit", snapshotDelete}, {"snap-delete.Store", snapshotDeleteStore}, @@ -116,7 +116,7 @@ func registerSnapDeleteStepFuncs() { */ } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -136,7 +136,7 @@ func snapshotDeleteHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) + txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -153,7 +153,7 @@ func snapshotDeleteHandler(w http.ResponseWriter, r *http.Request) { } volinfo := &snapinfo.SnapVolinfo - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-delete.Commit", Nodes: volinfo.Nodes(), diff --git a/glusterd2/commands/snapshot/snapshot-restore.go b/glusterd2/commands/snapshot/snapshot-restore.go index fd4dc5573..b255ff46e 100644 --- a/glusterd2/commands/snapshot/snapshot-restore.go +++ b/glusterd2/commands/snapshot/snapshot-restore.go @@ -7,9 +7,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" @@ -22,7 +22,7 @@ import ( const volumeIDXattrKey = "trusted.glusterfs.volume-id" -func snapRestore(c transaction.TxnCtx) error { +func snapRestore(c oldtransaction.TxnCtx) error { var snapname string if err := c.Get("snapname", &snapname); err != nil { return err @@ -91,7 +91,7 @@ func remountBrick(b brick.Brickinfo, volinfo *volume.Volinfo, mtab []*volume.Mnt } -func undoSnapStore(c transaction.TxnCtx) error { +func undoSnapStore(c oldtransaction.TxnCtx) error { var snapInfo snapshot.Snapinfo var volinfo volume.Volinfo @@ -126,7 +126,7 @@ func undoSnapStore(c transaction.TxnCtx) error { return nil } -func undoSnapRestore(c transaction.TxnCtx) error { +func undoSnapRestore(c oldtransaction.TxnCtx) error { var snapname string if err := c.Get("snapname", &snapname); err != nil { return err @@ -242,7 +242,7 @@ func createRestoreVolinfo(snapinfo *snapshot.Snapinfo, vol *volume.Volinfo) volu return newVol } -func storeSnapRestore(c transaction.TxnCtx) error { +func storeSnapRestore(c oldtransaction.TxnCtx) error { var snapname string if err := c.Get("snapname", &snapname); err != nil { return err @@ -287,7 +287,7 @@ func storeSnapRestore(c transaction.TxnCtx) error { return nil } -func cleanParentBricks(c transaction.TxnCtx) error { +func cleanParentBricks(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -301,7 +301,7 @@ func cleanParentBricks(c transaction.TxnCtx) error { func registerSnapRestoreStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"snap-restore.Commit", snapRestore}, {"snap-restore.UndoCommit", undoSnapRestore}, @@ -310,7 +310,7 @@ func registerSnapRestoreStepFuncs() { {"snap-restore.CleanBricks", cleanParentBricks}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -326,7 +326,7 @@ func snapshotRestoreHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) + txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -356,7 +356,7 @@ func snapshotRestoreHandler(w http.ResponseWriter, r *http.Request) { } bricksAutoProvisioned := vol.IsAutoProvisioned() || vol.IsSnapshotProvisioned() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-restore.Commit", UndoFunc: "snap-restore.UndoCommit", diff --git a/glusterd2/commands/snapshot/snapshot-status.go b/glusterd2/commands/snapshot/snapshot-status.go index 6fcf0d1ef..fcaf6a661 100644 --- a/glusterd2/commands/snapshot/snapshot-status.go +++ b/glusterd2/commands/snapshot/snapshot-status.go @@ -5,9 +5,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" @@ -48,7 +48,7 @@ func createSnapshotStatusResp(brickStatuses []brick.Brickstatus) []*api.SnapBric } -func snapshotStatus(ctx transaction.TxnCtx) error { +func snapshotStatus(ctx oldtransaction.TxnCtx) error { var snapname string if err := ctx.Get("snapname", &snapname); err != nil { ctx.Logger().WithError(err).Error("Failed to get key from transaction context.") @@ -77,7 +77,7 @@ func snapshotStatus(ctx transaction.TxnCtx) error { } func registerSnapshotStatusStepFuncs() { - transaction.RegisterStepFunc(snapshotStatus, "snap-status.Check") + oldtransaction.RegisterStepFunc(snapshotStatus, "snap-status.Check") } func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPError(ctx, w, http.StatusBadRequest, errors.ErrSnapNotActivated) return } - txn, err := transaction.NewTxnWithLocks(ctx, vol.Name) + txn, err := oldtransaction.NewTxnWithLocks(ctx, vol.Name) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -106,7 +106,7 @@ func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { } defer txn.Done() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "snap-status.Check", Nodes: vol.Nodes(), @@ -128,7 +128,7 @@ func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, resp) } -func createSnapshotStatusesResp(ctx transaction.TxnCtx, snap *snapshot.Snapinfo) *api.SnapStatusResp { +func createSnapshotStatusesResp(ctx oldtransaction.TxnCtx, snap *snapshot.Snapinfo) *api.SnapStatusResp { // bmap is a map of brick statuses keyed by brick ID diff --git a/glusterd2/commands/volumes/brick-replace-txn.go b/glusterd2/commands/volumes/brick-replace-txn.go index 3d194a0d9..6757eefbc 100644 --- a/glusterd2/commands/volumes/brick-replace-txn.go +++ b/glusterd2/commands/volumes/brick-replace-txn.go @@ -2,12 +2,12 @@ package volumecommands import ( "github.com/gluster/glusterd2/glusterd2/brick" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" ) -func prepareBricks(c transaction.TxnCtx) error { +func prepareBricks(c oldtransaction.TxnCtx) error { var volInfo volume.Volinfo if err := c.Get("volinfo", &volInfo); err != nil { return err @@ -22,7 +22,7 @@ func prepareBricks(c transaction.TxnCtx) error { return PrepareBrickLvm(req, c) } -func replaceVolinfo(c transaction.TxnCtx) error { +func replaceVolinfo(c oldtransaction.TxnCtx) error { var newBrick api.BrickReq var err error if err = c.Get("newBrick", &newBrick); err != nil { @@ -93,7 +93,7 @@ func replaceVolinfo(c transaction.TxnCtx) error { return err } -func startBrick(c transaction.TxnCtx) error { +func startBrick(c oldtransaction.TxnCtx) error { var newBrickInfo []brick.Brickinfo if err := c.Get("bricks", newBrickInfo); err != nil { diff --git a/glusterd2/commands/volumes/brick-replace.go b/glusterd2/commands/volumes/brick-replace.go index 507bf33fe..3429467cb 100644 --- a/glusterd2/commands/volumes/brick-replace.go +++ b/glusterd2/commands/volumes/brick-replace.go @@ -6,9 +6,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/bricksplanner" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -20,14 +20,14 @@ import ( func registerReplaceBrickStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"brick-replace.PrepareBricks", prepareBricks}, {"brick-replace.ReplaceVolinfo", replaceVolinfo}, {"brick-replace.StartBrick", startBrick}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -146,7 +146,7 @@ LOOP: } allPeerIDs := vol.Nodes() nodes := []uuid.UUID{peerID} - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -154,7 +154,7 @@ LOOP: } defer txn.Done() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "brick-replace.PrepareBricks", Nodes: nodes, diff --git a/glusterd2/commands/volumes/bricks-status.go b/glusterd2/commands/volumes/bricks-status.go index 0bf20a9b4..6c987b0a1 100644 --- a/glusterd2/commands/volumes/bricks-status.go +++ b/glusterd2/commands/volumes/bricks-status.go @@ -5,8 +5,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gorilla/mux" @@ -17,10 +17,10 @@ const ( ) func registerBricksStatusStepFuncs() { - transaction.RegisterStepFunc(bricksStatus, "bricks-status.Check") + oldtransaction.RegisterStepFunc(bricksStatus, "bricks-status.Check") } -func bricksStatus(ctx transaction.TxnCtx) error { +func bricksStatus(ctx oldtransaction.TxnCtx) error { var volname string if err := ctx.Get("volname", &volname); err != nil { ctx.Logger().WithError(err).Error("Failed to get key from transaction context.") @@ -57,9 +57,9 @@ func volumeBricksStatusHandler(w http.ResponseWriter, r *http.Request) { return } - txn := transaction.NewTxn(ctx) + txn := oldtransaction.NewTxn(ctx) defer txn.Done() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "bricks-status.Check", Nodes: vol.Nodes(), @@ -89,7 +89,7 @@ func volumeBricksStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, result) } -func createBricksStatusResp(ctx transaction.TxnCtx, vol *volume.Volinfo) (*api.BricksStatusResp, error) { +func createBricksStatusResp(ctx oldtransaction.TxnCtx, vol *volume.Volinfo) (*api.BricksStatusResp, error) { // bmap is a map of brick statuses keyed by brick ID bmap := make(map[string]api.BrickStatus) diff --git a/glusterd2/commands/volumes/common.go b/glusterd2/commands/volumes/common.go index bf2eafca1..fe6977b6b 100644 --- a/glusterd2/commands/volumes/common.go +++ b/glusterd2/commands/volumes/common.go @@ -13,10 +13,10 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/options" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" @@ -169,7 +169,7 @@ func expandGroupOptionsReset(reqOpts []string) ([]string, error) { return options, nil } -func notifyVolfileChange(c transaction.TxnCtx) error { +func notifyVolfileChange(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -186,7 +186,7 @@ func notifyVolfileChange(c transaction.TxnCtx) error { } // This txn step is used in volume create and in volume expand -func validateBricks(c transaction.TxnCtx) error { +func validateBricks(c oldtransaction.TxnCtx) error { var err error @@ -228,7 +228,7 @@ func validateBricks(c transaction.TxnCtx) error { } // This txn step is used in volume create, replace brick and in volume expand -func initBricks(c transaction.TxnCtx) error { +func initBricks(c oldtransaction.TxnCtx) error { var err error @@ -274,7 +274,7 @@ func initBricks(c transaction.TxnCtx) error { } // This txn step is used in volume create and in volume expand -func undoInitBricks(c transaction.TxnCtx) error { +func undoInitBricks(c oldtransaction.TxnCtx) error { var bricks []brick.Brickinfo if err := c.Get("bricks", &bricks); err != nil { @@ -296,12 +296,12 @@ func undoInitBricks(c transaction.TxnCtx) error { } // StoreVolume uses to store the volinfo and to generate client volfile -func storeVolume(c transaction.TxnCtx) error { +func storeVolume(c oldtransaction.TxnCtx) error { return storeVolInfo(c, "volinfo") } // storeVolInfo uses to store the volinfo based on key and to generate client volfile -func storeVolInfo(c transaction.TxnCtx, key string) error { +func storeVolInfo(c oldtransaction.TxnCtx, key string) error { var volinfo volume.Volinfo if err := c.Get(key, &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -319,7 +319,7 @@ func storeVolInfo(c transaction.TxnCtx, key string) error { } // undoStoreVolume revert back volinfo and to generate client volfile -func undoStoreVolume(c transaction.TxnCtx) error { +func undoStoreVolume(c oldtransaction.TxnCtx) error { return storeVolInfo(c, "oldvolinfo") } @@ -401,7 +401,7 @@ func isActionStepRequired(opt map[string]string, volinfo *volume.Volinfo) bool { return false } -func txnDeleteBrickVolfiles(c transaction.TxnCtx) error { +func txnDeleteBrickVolfiles(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -420,7 +420,7 @@ func txnDeleteBrickVolfiles(c transaction.TxnCtx) error { return nil } -func txnGenerateBrickVolfiles(c transaction.TxnCtx) error { +func txnGenerateBrickVolfiles(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { return err diff --git a/glusterd2/commands/volumes/volume-create-txn.go b/glusterd2/commands/volumes/volume-create-txn.go index 5dd325a20..6c25015f3 100644 --- a/glusterd2/commands/volumes/volume-create-txn.go +++ b/glusterd2/commands/volumes/volume-create-txn.go @@ -6,14 +6,14 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/brick" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/pborman/uuid" ) -func undoStoreVolumeOnCreate(c transaction.TxnCtx) error { +func undoStoreVolumeOnCreate(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -178,7 +178,7 @@ func newVolinfo(req *api.VolCreateReq) (*volume.Volinfo, error) { return volinfo, nil } -func createVolinfo(c transaction.TxnCtx) error { +func createVolinfo(c oldtransaction.TxnCtx) error { var req api.VolCreateReq if err := c.Get("req", &req); err != nil { diff --git a/glusterd2/commands/volumes/volume-create.go b/glusterd2/commands/volumes/volume-create.go index 25d420789..3d30dd09f 100644 --- a/glusterd2/commands/volumes/volume-create.go +++ b/glusterd2/commands/volumes/volume-create.go @@ -10,8 +10,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/bricksplanner" "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -84,7 +84,7 @@ func checkDupBrickEntryVolCreate(req api.VolCreateReq) error { func registerVolCreateStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"vol-create.CreateVolinfo", createVolinfo}, {"vol-create.ValidateBricks", validateBricks}, @@ -96,7 +96,7 @@ func registerVolCreateStepFuncs() { {"vol-create.UndoPrepareBricks", txnUndoPrepareBricks}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -209,7 +209,7 @@ func CreateVolume(ctx context.Context, req api.VolCreateReq) (status int, err er return http.StatusBadRequest, gderrors.ErrVolExists } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-create.PrepareBricks", UndoFunc: "vol-create.UndoPrepareBricks", diff --git a/glusterd2/commands/volumes/volume-delete.go b/glusterd2/commands/volumes/volume-delete.go index 59b079050..1beb98573 100644 --- a/glusterd2/commands/volumes/volume-delete.go +++ b/glusterd2/commands/volumes/volume-delete.go @@ -6,8 +6,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" "github.com/gluster/glusterd2/glusterd2/volume" @@ -17,7 +17,7 @@ import ( "go.opencensus.io/trace" ) -func deleteVolume(c transaction.TxnCtx) error { +func deleteVolume(c oldtransaction.TxnCtx) error { var ( volinfo volume.Volinfo @@ -32,8 +32,8 @@ func deleteVolume(c transaction.TxnCtx) error { } func registerVolDeleteStepFuncs() { - transaction.RegisterStepFunc(deleteVolume, "vol-delete.Store") - transaction.RegisterStepFunc(txnCleanBricks, "vol-delete.CleanBricks") + oldtransaction.RegisterStepFunc(deleteVolume, "vol-delete.Store") + oldtransaction.RegisterStepFunc(txnCleanBricks, "vol-delete.CleanBricks") } func volumeDeleteHandler(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func volumeDeleteHandler(w http.ResponseWriter, r *http.Request) { } bricksAutoProvisioned := volinfo.IsAutoProvisioned() || volinfo.IsSnapshotProvisioned() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-delete.CleanBricks", Nodes: volinfo.Nodes(), diff --git a/glusterd2/commands/volumes/volume-edit.go b/glusterd2/commands/volumes/volume-edit.go index 4a3c7a415..51403fd31 100644 --- a/glusterd2/commands/volumes/volume-edit.go +++ b/glusterd2/commands/volumes/volume-edit.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" @@ -29,7 +29,7 @@ func volumeEditHandler(w http.ResponseWriter, r *http.Request) { } //Lock on Volume Name - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) diff --git a/glusterd2/commands/volumes/volume-expand-txn.go b/glusterd2/commands/volumes/volume-expand-txn.go index e024da377..700cbed0d 100644 --- a/glusterd2/commands/volumes/volume-expand-txn.go +++ b/glusterd2/commands/volumes/volume-expand-txn.go @@ -9,7 +9,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/brickmux" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/lvmutils" @@ -19,7 +19,7 @@ import ( log "github.com/sirupsen/logrus" ) -func expandValidatePrepare(c transaction.TxnCtx) error { +func expandValidatePrepare(c oldtransaction.TxnCtx) error { var req api.VolExpandReq if err := c.Get("req", &req); err != nil { @@ -97,7 +97,7 @@ func expandValidatePrepare(c transaction.TxnCtx) error { return err } -func startBricksOnExpand(c transaction.TxnCtx) error { +func startBricksOnExpand(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -163,7 +163,7 @@ func startBricksOnExpand(c transaction.TxnCtx) error { return nil } -func undoStartBricksOnExpand(c transaction.TxnCtx) error { +func undoStartBricksOnExpand(c oldtransaction.TxnCtx) error { var newBricks []brick.Brickinfo if err := c.Get("bricks", &newBricks); err != nil { @@ -196,7 +196,7 @@ func undoStartBricksOnExpand(c transaction.TxnCtx) error { return nil } -func updateVolinfoOnExpand(c transaction.TxnCtx) error { +func updateVolinfoOnExpand(c oldtransaction.TxnCtx) error { var newBricks []brick.Brickinfo if err := c.Get("bricks", &newBricks); err != nil { @@ -294,7 +294,7 @@ func updateVolinfoOnExpand(c transaction.TxnCtx) error { return nil } -func resizeLVM(c transaction.TxnCtx) error { +func resizeLVM(c oldtransaction.TxnCtx) error { var req api.VolExpandReq if err := c.Get("req", &req); err != nil { return err diff --git a/glusterd2/commands/volumes/volume-expand.go b/glusterd2/commands/volumes/volume-expand.go index b638ca7f7..ce56f685c 100644 --- a/glusterd2/commands/volumes/volume-expand.go +++ b/glusterd2/commands/volumes/volume-expand.go @@ -6,9 +6,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" @@ -23,7 +23,7 @@ import ( func registerVolExpandStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"vol-expand.ValidateAndPrepare", expandValidatePrepare}, {"vol-expand.ValidateBricks", validateBricks}, @@ -38,7 +38,7 @@ func registerVolExpandStepFuncs() { {"vol-expand.LvmResize", resizeLVM}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -84,7 +84,7 @@ func volumeExpandHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -163,7 +163,7 @@ func volumeExpandHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = allNodes - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ // TODO: This is a lot of steps. We can combine a few if we // do not re-use the same step functions across multiple // volume operations. diff --git a/glusterd2/commands/volumes/volume-option.go b/glusterd2/commands/volumes/volume-option.go index 3dc4b8fff..851369783 100644 --- a/glusterd2/commands/volumes/volume-option.go +++ b/glusterd2/commands/volumes/volume-option.go @@ -5,10 +5,10 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/options" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" "github.com/gluster/glusterd2/pkg/api" @@ -20,7 +20,7 @@ import ( "go.opencensus.io/trace" ) -func optionSetValidate(c transaction.TxnCtx) error { +func optionSetValidate(c oldtransaction.TxnCtx) error { var req api.VolOptionReq if err := c.Get("req", &req); err != nil { @@ -69,42 +69,42 @@ const ( txnUndo ) -func xlatorActionDoSet(c transaction.TxnCtx) error { +func xlatorActionDoSet(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeSet) } -func xlatorActionUndoSet(c transaction.TxnCtx) error { +func xlatorActionUndoSet(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeSet) } -func xlatorActionDoReset(c transaction.TxnCtx) error { +func xlatorActionDoReset(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeReset) } -func xlatorActionUndoReset(c transaction.TxnCtx) error { +func xlatorActionUndoReset(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeReset) } -func xlatorActionDoVolumeStart(c transaction.TxnCtx) error { +func xlatorActionDoVolumeStart(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeStart) } -func xlatorActionUndoVolumeStart(c transaction.TxnCtx) error { +func xlatorActionUndoVolumeStart(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeStart) } -func xlatorActionDoVolumeStop(c transaction.TxnCtx) error { +func xlatorActionDoVolumeStop(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeStop) } -func xlatorActionUndoVolumeStop(c transaction.TxnCtx) error { +func xlatorActionUndoVolumeStop(c oldtransaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeStop) } // This function can be reused when volume reset operation is implemented. // However, volume reset can be also be treated logically as volume set but // with the value set to default value. -func xlatorAction(c transaction.TxnCtx, txnOp txnOpType, volOp xlator.VolumeOpType) error { +func xlatorAction(c oldtransaction.TxnCtx, txnOp txnOpType, volOp xlator.VolumeOpType) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -176,7 +176,7 @@ func xlatorAction(c transaction.TxnCtx, txnOp txnOpType, volOp xlator.VolumeOpTy func registerVolOptionStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"vol-option.Validate", optionSetValidate}, {"vol-option.XlatorActionDoSet", xlatorActionDoSet}, @@ -188,7 +188,7 @@ func registerVolOptionStepFuncs() { {"vol-option.GenerateBrickvolfiles.Undo", txnDeleteBrickVolfiles}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -211,7 +211,7 @@ func volumeOptionsHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -237,7 +237,7 @@ func volumeOptionsHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-option.Validate", Nodes: []uuid.UUID{gdctx.MyUUID}, diff --git a/glusterd2/commands/volumes/volume-profile.go b/glusterd2/commands/volumes/volume-profile.go index dd2a3bf81..ece959ec3 100644 --- a/glusterd2/commands/volumes/volume-profile.go +++ b/glusterd2/commands/volumes/volume-profile.go @@ -10,9 +10,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gorilla/mux" @@ -26,7 +26,7 @@ const ( ) func registerVolProfileStepFuncs() { - transaction.RegisterStepFunc(txnVolumeProfile, "volume.Profile") + oldtransaction.RegisterStepFunc(txnVolumeProfile, "volume.Profile") } func volumeProfileHandler(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func volumeProfileHandler(w http.ResponseWriter, r *http.Request) { volname := mux.Vars(r)["volname"] option := mux.Vars(r)["option"] - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -61,7 +61,7 @@ func volumeProfileHandler(w http.ResponseWriter, r *http.Request) { } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "volume.Profile", Nodes: volinfo.Nodes(), @@ -217,7 +217,7 @@ func decodeIntervalKey(key string) (string, string) { return fop, k } -func txnVolumeProfile(c transaction.TxnCtx) error { +func txnVolumeProfile(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo var nodeProfileInfo []map[string]string if err := c.Get("volinfo", &volinfo); err != nil { diff --git a/glusterd2/commands/volumes/volume-reset.go b/glusterd2/commands/volumes/volume-reset.go index fa707dc49..5d7855557 100644 --- a/glusterd2/commands/volumes/volume-reset.go +++ b/glusterd2/commands/volumes/volume-reset.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" "github.com/gluster/glusterd2/pkg/api" @@ -20,13 +20,13 @@ import ( func registerVolOptionResetStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"vol-option.XlatorActionDoReset", xlatorActionDoReset}, {"vol-option.XlatorActionUndoReset", xlatorActionUndoReset}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -55,7 +55,7 @@ func volumeResetHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -156,7 +156,7 @@ func volumeResetHandler(w http.ResponseWriter, r *http.Request) { opt[key] = "" } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-option.XlatorActionDoReset", UndoFunc: "vol-option.XlatorActionUndoReset", diff --git a/glusterd2/commands/volumes/volume-smartvol-txn.go b/glusterd2/commands/volumes/volume-smartvol-txn.go index da27d1f9e..10a749cca 100644 --- a/glusterd2/commands/volumes/volume-smartvol-txn.go +++ b/glusterd2/commands/volumes/volume-smartvol-txn.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/fsutils" @@ -16,7 +16,7 @@ import ( log "github.com/sirupsen/logrus" ) -func txnPrepareBricks(c transaction.TxnCtx) error { +func txnPrepareBricks(c oldtransaction.TxnCtx) error { var req api.VolCreateReq if err := c.Get("req", &req); err != nil { c.Logger().WithError(err).WithField("key", "req").Error("failed to get key from store") @@ -41,7 +41,7 @@ func txnPrepareBricks(c transaction.TxnCtx) error { } // PrepareBrickLvm prepares(Creates thin pool, creates LV, mounts etc.) a single brick -func PrepareBrickLvm(b api.BrickReq, c transaction.TxnCtx) error { +func PrepareBrickLvm(b api.BrickReq, c oldtransaction.TxnCtx) error { if b.PeerID != gdctx.MyUUID.String() { return nil } @@ -128,7 +128,7 @@ func PrepareBrickLvm(b api.BrickReq, c transaction.TxnCtx) error { return nil } -func txnUndoPrepareBricks(c transaction.TxnCtx) error { +func txnUndoPrepareBricks(c oldtransaction.TxnCtx) error { var req api.VolCreateReq if err := c.Get("req", &req); err != nil { c.Logger().WithError(err).WithField("key", "req").Error("failed to get key from store") @@ -140,7 +140,7 @@ func txnUndoPrepareBricks(c transaction.TxnCtx) error { return txnUndoPrepareBricksLvm(req, c) } -func txnUndoPrepareBricksLvm(req api.VolCreateReq, c transaction.TxnCtx) error { +func txnUndoPrepareBricksLvm(req api.VolCreateReq, c oldtransaction.TxnCtx) error { for _, sv := range req.Subvols { for _, b := range sv.Bricks { @@ -191,7 +191,7 @@ func txnUndoPrepareBricksLvm(req api.VolCreateReq, c transaction.TxnCtx) error { } // PrepareBrickLoop prepares a single brick -func PrepareBrickLoop(b api.BrickReq, c transaction.TxnCtx) error { +func PrepareBrickLoop(b api.BrickReq, c oldtransaction.TxnCtx) error { if b.PeerID != gdctx.MyUUID.String() { return nil } @@ -277,7 +277,7 @@ func PrepareBrickLoop(b api.BrickReq, c transaction.TxnCtx) error { return nil } -func txnUndoPrepareBricksLoop(req api.VolCreateReq, c transaction.TxnCtx) error { +func txnUndoPrepareBricksLoop(req api.VolCreateReq, c oldtransaction.TxnCtx) error { for _, sv := range req.Subvols { for _, b := range sv.Bricks { @@ -321,7 +321,7 @@ func txnUndoPrepareBricksLoop(req api.VolCreateReq, c transaction.TxnCtx) error return nil } -func txnCleanBricks(c transaction.TxnCtx) error { +func txnCleanBricks(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( diff --git a/glusterd2/commands/volumes/volume-start.go b/glusterd2/commands/volumes/volume-start.go index a195bb2da..533b5ee40 100644 --- a/glusterd2/commands/volumes/volume-start.go +++ b/glusterd2/commands/volumes/volume-start.go @@ -8,8 +8,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brickmux" "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" @@ -22,7 +22,7 @@ import ( "go.opencensus.io/trace" ) -func startAllBricks(c transaction.TxnCtx) error { +func startAllBricks(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -81,7 +81,7 @@ func startAllBricks(c transaction.TxnCtx) error { return nil } -func stopAllBricks(c transaction.TxnCtx) error { +func stopAllBricks(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -111,7 +111,7 @@ func stopAllBricks(c transaction.TxnCtx) error { func registerVolStartStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"vol-start.StartBricks", startAllBricks}, {"vol-start.StartBricksUndo", stopAllBricks}, @@ -121,7 +121,7 @@ func registerVolStartStepFuncs() { {"vol-start.UpdateVolinfo.Undo", undoStoreVolume}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -173,7 +173,7 @@ func StartVolume(ctx context.Context, volname string, req api.VolumeStartReq) (v return nil, http.StatusBadRequest, errors.ErrVolAlreadyStarted } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-start.StartBricks", UndoFunc: "vol-start.StartBricksUndo", diff --git a/glusterd2/commands/volumes/volume-statedump.go b/glusterd2/commands/volumes/volume-statedump.go index 2010144dd..1de5df0f7 100644 --- a/glusterd2/commands/volumes/volume-statedump.go +++ b/glusterd2/commands/volumes/volume-statedump.go @@ -7,9 +7,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -37,7 +37,7 @@ func validateVolStatedumpReq(req *api.VolStatedumpReq) error { return nil } -func takeStatedump(c transaction.TxnCtx) error { +func takeStatedump(c oldtransaction.TxnCtx) error { var req api.VolStatedumpReq if err := c.Get("req", &req); err != nil { @@ -83,7 +83,7 @@ func takeStatedump(c transaction.TxnCtx) error { } func registerVolStatedumpFuncs() { - transaction.RegisterStepFunc(takeStatedump, "vol-statedump.TakeStatedump") + oldtransaction.RegisterStepFunc(takeStatedump, "vol-statedump.TakeStatedump") } func volumeStatedumpHandler(w http.ResponseWriter, r *http.Request) { @@ -103,7 +103,7 @@ func volumeStatedumpHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -123,7 +123,7 @@ func volumeStatedumpHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-statedump.TakeStatedump", Nodes: volinfo.Nodes(), diff --git a/glusterd2/commands/volumes/volume-stop.go b/glusterd2/commands/volumes/volume-stop.go index f1c721fde..6cd8ff8e4 100644 --- a/glusterd2/commands/volumes/volume-stop.go +++ b/glusterd2/commands/volumes/volume-stop.go @@ -9,8 +9,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" @@ -23,7 +23,7 @@ import ( "go.opencensus.io/trace" ) -func stopBricks(c transaction.TxnCtx) error { +func stopBricks(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -101,7 +101,7 @@ func stopBricks(c transaction.TxnCtx) error { func registerVolStopStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"vol-stop.StopBricks", stopBricks}, {"vol-stop.XlatorActionDoVolumeStop", xlatorActionDoVolumeStop}, @@ -110,7 +110,7 @@ func registerVolStopStepFuncs() { {"vol-stop.UpdateVolinfo.Undo", undoStoreVolume}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -149,7 +149,7 @@ func volumeStopHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-stop.StopBricks", Nodes: volinfo.Nodes(), diff --git a/glusterd2/transaction/context.go b/glusterd2/oldtransaction/context.go similarity index 99% rename from glusterd2/transaction/context.go rename to glusterd2/oldtransaction/context.go index 40d4c1077..2c2f56705 100644 --- a/glusterd2/transaction/context.go +++ b/glusterd2/oldtransaction/context.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction import ( "context" diff --git a/glusterd2/transaction/context_mock.go b/glusterd2/oldtransaction/context_mock.go similarity index 98% rename from glusterd2/transaction/context_mock.go rename to glusterd2/oldtransaction/context_mock.go index cb5b60db7..ef6162109 100644 --- a/glusterd2/transaction/context_mock.go +++ b/glusterd2/oldtransaction/context_mock.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction import ( "errors" diff --git a/glusterd2/transaction/lock.go b/glusterd2/oldtransaction/lock.go similarity index 99% rename from glusterd2/transaction/lock.go rename to glusterd2/oldtransaction/lock.go index 45720bdf1..0a3059775 100644 --- a/glusterd2/transaction/lock.go +++ b/glusterd2/oldtransaction/lock.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction import ( "context" diff --git a/glusterd2/transaction/registry.go b/glusterd2/oldtransaction/registry.go similarity index 97% rename from glusterd2/transaction/registry.go rename to glusterd2/oldtransaction/registry.go index e06254a9d..589829d74 100644 --- a/glusterd2/transaction/registry.go +++ b/glusterd2/oldtransaction/registry.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction // The StepFunc registry registers StepFunc's to be used by transaction framework diff --git a/glusterd2/transaction/rpc-client.go b/glusterd2/oldtransaction/rpc-client.go similarity index 98% rename from glusterd2/transaction/rpc-client.go rename to glusterd2/oldtransaction/rpc-client.go index f51e7843b..e10832c93 100644 --- a/glusterd2/transaction/rpc-client.go +++ b/glusterd2/oldtransaction/rpc-client.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction import ( "context" diff --git a/glusterd2/transaction/rpc-service.go b/glusterd2/oldtransaction/rpc-service.go similarity index 98% rename from glusterd2/transaction/rpc-service.go rename to glusterd2/oldtransaction/rpc-service.go index 43ca372aa..0a93accbb 100644 --- a/glusterd2/transaction/rpc-service.go +++ b/glusterd2/oldtransaction/rpc-service.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction import ( "context" diff --git a/glusterd2/transaction/step.go b/glusterd2/oldtransaction/step.go similarity index 99% rename from glusterd2/transaction/step.go rename to glusterd2/oldtransaction/step.go index 525d8bd4d..53b71a0f1 100644 --- a/glusterd2/transaction/step.go +++ b/glusterd2/oldtransaction/step.go @@ -1,4 +1,4 @@ -package transaction +package oldtransaction import ( "context" diff --git a/glusterd2/transaction/transaction-rpc.pb.go b/glusterd2/oldtransaction/transaction-rpc.pb.go similarity index 99% rename from glusterd2/transaction/transaction-rpc.pb.go rename to glusterd2/oldtransaction/transaction-rpc.pb.go index 2e1ff4928..a7aae426c 100644 --- a/glusterd2/transaction/transaction-rpc.pb.go +++ b/glusterd2/oldtransaction/transaction-rpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: glusterd2/transaction/transaction-rpc.proto -package transaction +package oldtransaction import ( fmt "fmt" diff --git a/glusterd2/transaction/transaction-rpc.proto b/glusterd2/oldtransaction/transaction-rpc.proto similarity index 100% rename from glusterd2/transaction/transaction-rpc.proto rename to glusterd2/oldtransaction/transaction-rpc.proto diff --git a/glusterd2/transaction/transaction.go b/glusterd2/oldtransaction/transaction.go similarity index 99% rename from glusterd2/transaction/transaction.go rename to glusterd2/oldtransaction/transaction.go index deca9501d..d29a90086 100644 --- a/glusterd2/transaction/transaction.go +++ b/glusterd2/oldtransaction/transaction.go @@ -1,5 +1,5 @@ // Package transaction implements a distributed transaction handling framework -package transaction +package oldtransaction import ( "context" diff --git a/glusterd2/servers/rest/utils/utils.go b/glusterd2/servers/rest/utils/utils.go index 8eea0e697..f394f0928 100644 --- a/glusterd2/servers/rest/utils/utils.go +++ b/glusterd2/servers/rest/utils/utils.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" ) @@ -100,7 +100,7 @@ func ErrToStatusCode(err error) (int, error) { statuscode = http.StatusNotFound case gderrors.ErrSnapNotFound: statuscode = http.StatusNotFound - case transaction.ErrLockTimeout: + case oldtransaction.ErrLockTimeout: statuscode = http.StatusConflict default: statuscode = http.StatusInternalServerError diff --git a/glusterd2/servers/sunrpc/callback.go b/glusterd2/servers/sunrpc/callback.go index 706f12f4f..63b26a4c0 100644 --- a/glusterd2/servers/sunrpc/callback.go +++ b/glusterd2/servers/sunrpc/callback.go @@ -5,7 +5,7 @@ import ( "net" "sync/atomic" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/pkg/sunrpc" "github.com/gluster/glusterd2/pkg/utils" @@ -90,7 +90,7 @@ const ( gfCbkStatedump = 9 ) -func fetchNotify(t transaction.TxnCtx, op fetchOp) { +func fetchNotify(t oldtransaction.TxnCtx, op fetchOp) { clientsList.RLock() defer clientsList.RUnlock() @@ -114,13 +114,13 @@ func fetchNotify(t transaction.TxnCtx, op fetchOp) { // FetchSpecNotify notifies all clients connected to glusterd that the volfile // has changed and the clients should fetch the new volfile. -func FetchSpecNotify(t transaction.TxnCtx) { +func FetchSpecNotify(t oldtransaction.TxnCtx) { fetchNotify(t, gfCbkFetchSpec) } // FetchSnapNotify notifies all clients connected to glusterd that a snapshot // has been created or modified. -func FetchSnapNotify(t transaction.TxnCtx) { +func FetchSnapNotify(t oldtransaction.TxnCtx) { fetchNotify(t, gfCbkGetSnaps) } diff --git a/glusterd2/transactionv2/steprunner.go b/glusterd2/transactionv2/steprunner.go index a0c2f3f00..97c4fc571 100644 --- a/glusterd2/transactionv2/steprunner.go +++ b/glusterd2/transactionv2/steprunner.go @@ -5,16 +5,16 @@ import ( "time" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/pborman/uuid" ) // StepManager is an interface for running a step and also rollback step on local node type StepManager interface { - RunStep(ctx context.Context, step *transaction.Step, txnCtx transaction.TxnCtx) error - RollBackStep(ctx context.Context, step *transaction.Step, txnCtx transaction.TxnCtx) error + RunStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error + RollBackStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error SyncStep(ctx context.Context, stepIndex int, txn *Txn) error } @@ -30,7 +30,7 @@ func newStepManager() StepManager { } } -func (sm *stepManager) shouldRunStep(step *transaction.Step) bool { +func (sm *stepManager) shouldRunStep(step *oldtransaction.Step) bool { if step.Skip { return false } @@ -46,9 +46,9 @@ func (sm *stepManager) shouldRunStep(step *transaction.Step) bool { // runStep synchronises the locally cached keys and values from the store // before running the step function on node -func (sm *stepManager) runStep(ctx context.Context, stepName string, txnCtx transaction.TxnCtx) error { +func (sm *stepManager) runStep(ctx context.Context, stepName string, txnCtx oldtransaction.TxnCtx) error { txnCtx.SyncCache() - return transaction.RunStepFuncLocally(ctx, stepName, txnCtx) + return oldtransaction.RunStepFuncLocally(ctx, stepName, txnCtx) } // isPrevStepsExecutedOnNode reports that all previous steps @@ -92,7 +92,7 @@ func (sm *stepManager) SyncStep(ctx context.Context, syncStepIndex int, txn *Txn } // RollBackStep will rollback a given step on local node -func (sm *stepManager) RollBackStep(ctx context.Context, step *transaction.Step, txnCtx transaction.TxnCtx) error { +func (sm *stepManager) RollBackStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error { if !sm.shouldRunStep(step) { txnCtx.Logger().WithField("step", step.UndoFunc).Debug("peer is excluded in running this step") return nil @@ -106,7 +106,7 @@ func (sm *stepManager) RollBackStep(ctx context.Context, step *transaction.Step, } // RunStepRunStep will execute the step on local node -func (sm *stepManager) RunStep(ctx context.Context, step *transaction.Step, txnCtx transaction.TxnCtx) error { +func (sm *stepManager) RunStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error { if !sm.shouldRunStep(step) { txnCtx.Logger().WithField("step", step.DoFunc).Debug("peer is excluded in running this step") return nil diff --git a/glusterd2/transactionv2/steptracing.go b/glusterd2/transactionv2/steptracing.go index f198d20e4..c04fd03d1 100644 --- a/glusterd2/transactionv2/steptracing.go +++ b/glusterd2/transactionv2/steptracing.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "go.opencensus.io/trace" ) @@ -18,7 +18,7 @@ type tracingManager struct { } // RunStep is a middleware which creates tracing span for step.DoFunc -func (t *tracingManager) RunStep(ctx context.Context, step *transaction.Step, txnCtx transaction.TxnCtx) (err error) { +func (t *tracingManager) RunStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) (err error) { spanName := fmt.Sprintf("RunStep/%s", step.DoFunc) ctx, span := trace.StartSpan(ctx, spanName) defer span.End() @@ -37,7 +37,7 @@ func (t *tracingManager) RunStep(ctx context.Context, step *transaction.Step, tx } // RollBackStep is a middleware which creates tracing span for step.UndoFunc -func (t *tracingManager) RollBackStep(ctx context.Context, step *transaction.Step, txnCtx transaction.TxnCtx) (err error) { +func (t *tracingManager) RollBackStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) (err error) { spanName := fmt.Sprintf("RollBackStep/%s", step.UndoFunc) ctx, span := trace.StartSpan(ctx, spanName) defer span.End() diff --git a/glusterd2/transactionv2/transaction.go b/glusterd2/transactionv2/transaction.go index a80e3ea19..34a5bc5de 100644 --- a/glusterd2/transactionv2/transaction.go +++ b/glusterd2/transactionv2/transaction.go @@ -9,8 +9,8 @@ import ( "time" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/coreos/etcd/clientv3" "github.com/pborman/uuid" @@ -25,21 +25,21 @@ const ( // Txn is a set of steps type Txn struct { - locks transaction.Locks + locks oldtransaction.Locks // Nodes is the union of the all the TxnStep.Nodes and is implicitly // set in Txn.Do(). This list is used to determine liveness of the // nodes before running the transaction steps. - Nodes []uuid.UUID `json:"nodes"` - StorePrefix string `json:"store_prefix"` - ID uuid.UUID `json:"id"` - ReqID uuid.UUID `json:"req_id"` - Ctx transaction.TxnCtx `json:"ctx"` - Steps []*transaction.Step `json:"steps"` - DontCheckAlive bool `json:"dont_check_alive"` - DisableRollback bool `json:"disable_rollback"` - StartTime time.Time `json:"start_time"` - TxnSpanCtx trace.SpanContext `json:"txn_span_ctx"` + Nodes []uuid.UUID `json:"nodes"` + StorePrefix string `json:"store_prefix"` + ID uuid.UUID `json:"id"` + ReqID uuid.UUID `json:"req_id"` + Ctx oldtransaction.TxnCtx `json:"ctx"` + Steps []*oldtransaction.Step `json:"steps"` + DontCheckAlive bool `json:"dont_check_alive"` + DisableRollback bool `json:"disable_rollback"` + StartTime time.Time `json:"start_time"` + TxnSpanCtx trace.SpanContext `json:"txn_span_ctx"` success chan struct{} error chan error @@ -53,16 +53,16 @@ func NewTxn(ctx context.Context) *Txn { t.ID = uuid.NewRandom() t.ReqID = gdctx.GetReqID(ctx) - t.locks = transaction.Locks{} + t.locks = oldtransaction.Locks{} t.StorePrefix = txnPrefix + t.ID.String() + "/" - config := &transaction.TxnCtxConfig{ + config := &oldtransaction.TxnCtxConfig{ LogFields: log.Fields{ "txnid": t.ID.String(), "reqid": t.ReqID.String(), }, StorePrefix: t.StorePrefix, } - t.Ctx = transaction.NewCtx(config) + t.Ctx = oldtransaction.NewCtx(config) spanCtx := trace.FromContext(ctx) t.TxnSpanCtx = spanCtx.SpanContext() t.Ctx.Logger().Debug("new transaction created") @@ -72,14 +72,14 @@ func NewTxn(ctx context.Context) *Txn { // NewTxnWithLocks returns an empty Txn with locks obtained on given lockIDs func NewTxnWithLocks(ctx context.Context, lockIDs ...string) (*Txn, error) { t := NewTxn(ctx) - t.locks = transaction.Locks{} + t.locks = oldtransaction.Locks{} err := t.acquireClusterLocks(lockIDs...) return t, err } func (t *Txn) acquireClusterLocks(lockIDs ...string) error { if t.locks == nil { - t.locks = transaction.Locks{} + t.locks = oldtransaction.Locks{} } for _, id := range lockIDs { diff --git a/glusterd2/transactionv2/txnmanager.go b/glusterd2/transactionv2/txnmanager.go index a2cd5174d..9407467bd 100644 --- a/glusterd2/transactionv2/txnmanager.go +++ b/glusterd2/transactionv2/txnmanager.go @@ -10,8 +10,8 @@ import ( "sync" "time" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/mvcc/mvccpb" @@ -186,7 +186,7 @@ func (tm *txnManager) watchRespToTxns(resp clientv3.WatchResponse) (txns []*Txn) continue } - txn := &Txn{Ctx: new(transaction.Tctx)} + txn := &Txn{Ctx: new(oldtransaction.Tctx)} if err := json.Unmarshal(event.Kv.Value, txn); err != nil { continue } @@ -220,7 +220,7 @@ func (tm *txnManager) GetTxnByUUID(id uuid.UUID) (*Txn, error) { kv := resp.Kvs[0] - txn := &Txn{Ctx: new(transaction.Tctx)} + txn := &Txn{Ctx: new(oldtransaction.Tctx)} if err := json.Unmarshal(kv.Value, txn); err != nil { return nil, err } @@ -239,7 +239,7 @@ func (tm *txnManager) GetTxns() (txns []*Txn) { continue } - txn := &Txn{Ctx: new(transaction.Tctx)} + txn := &Txn{Ctx: new(oldtransaction.Tctx)} if err := json.Unmarshal(kv.Value, txn); err != nil { continue } @@ -252,7 +252,7 @@ func (tm *txnManager) GetTxns() (txns []*Txn) { func (tm *txnManager) UpDateTxnStatus(status TxnStatus, txnID uuid.UUID, nodeIDs ...uuid.UUID) error { var ( ctx, cancel = context.WithTimeout(context.Background(), etcdTxnTimeout) - clusterLock = transaction.Locks{} + clusterLock = oldtransaction.Locks{} putOps []clientv3.Op ) @@ -284,7 +284,7 @@ func (tm *txnManager) GetTxnStatus(txnID uuid.UUID, nodeID uuid.UUID) (TxnStatus var ( ctx, cancel = context.WithCancel(context.Background()) key = tm.getStoreKey(txnID.String(), nodeID.String(), TxnStatusPrefix) - clusterLock = transaction.Locks{} + clusterLock = oldtransaction.Locks{} ) defer cancel() diff --git a/plugins/bitrot/init.go b/plugins/bitrot/init.go index 38f3d5df3..bf5a984ec 100644 --- a/plugins/bitrot/init.go +++ b/plugins/bitrot/init.go @@ -1,8 +1,8 @@ package bitrot import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" - "github.com/gluster/glusterd2/glusterd2/transaction" ) const name = "bitrot" @@ -49,9 +49,9 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - transaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-enable.Commit") - transaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-disable.Commit") - transaction.RegisterStepFunc(txnBitrotScrubOndemand, "bitrot-scrubondemand.Commit") - transaction.RegisterStepFunc(txnBitrotScrubStatus, "bitrot-scrubstatus.Commit") + oldtransaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-enable.Commit") + oldtransaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-disable.Commit") + oldtransaction.RegisterStepFunc(txnBitrotScrubOndemand, "bitrot-scrubondemand.Commit") + oldtransaction.RegisterStepFunc(txnBitrotScrubStatus, "bitrot-scrubstatus.Commit") return } diff --git a/plugins/bitrot/rest.go b/plugins/bitrot/rest.go index e7542e94c..84d0c39cc 100644 --- a/plugins/bitrot/rest.go +++ b/plugins/bitrot/rest.go @@ -5,8 +5,8 @@ import ( "strconv" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" "github.com/gluster/glusterd2/pkg/errors" @@ -23,7 +23,7 @@ func bitrotEnableHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -68,7 +68,7 @@ func bitrotEnableHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = volinfo.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-option.UpdateVolinfo", UndoFunc: "vol-option.UpdateVolinfo.Undo", @@ -107,7 +107,7 @@ func bitrotDisableHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -140,7 +140,7 @@ func bitrotDisableHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = volinfo.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-option.UpdateVolinfo", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -173,7 +173,7 @@ func bitrotScrubOndemandHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -202,7 +202,7 @@ func bitrotScrubOndemandHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = volinfo.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "bitrot-scrubondemand.Commit", Nodes: txn.Nodes, @@ -229,7 +229,7 @@ func bitrotScrubStatusHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -264,7 +264,7 @@ func bitrotScrubStatusHandler(w http.ResponseWriter, r *http.Request) { txn.DisableRollback = true txn.Nodes = volinfo.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "bitrot-scrubstatus.Commit", Nodes: txn.Nodes, @@ -293,7 +293,7 @@ func bitrotScrubStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, result) } -func createScrubStatusResp(ctx transaction.TxnCtx, volinfo *volume.Volinfo) (*bitrotapi.ScrubStatus, error) { +func createScrubStatusResp(ctx oldtransaction.TxnCtx, volinfo *volume.Volinfo) (*bitrotapi.ScrubStatus, error) { var resp bitrotapi.ScrubStatus var exists bool diff --git a/plugins/bitrot/transactions.go b/plugins/bitrot/transactions.go index d5c3775b4..b4db53d05 100644 --- a/plugins/bitrot/transactions.go +++ b/plugins/bitrot/transactions.go @@ -7,8 +7,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" @@ -101,7 +101,7 @@ func ManageScrubd(logger log.FieldLogger, volinfo *volume.Volinfo) error { return nil } -func txnBitrotEnableDisable(c transaction.TxnCtx) error { +func txnBitrotEnableDisable(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -129,7 +129,7 @@ Err: return err } -func txnBitrotScrubOndemand(c transaction.TxnCtx) error { +func txnBitrotScrubOndemand(c oldtransaction.TxnCtx) error { var volname string if err := c.Get("volname", &volname); err != nil { @@ -176,7 +176,7 @@ func txnBitrotScrubOndemand(c transaction.TxnCtx) error { return nil } -func txnBitrotScrubStatus(c transaction.TxnCtx) error { +func txnBitrotScrubStatus(c oldtransaction.TxnCtx) error { var volname string if err := c.Get("volname", &volname); err != nil { diff --git a/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go b/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go index 4cca4830c..73d732694 100644 --- a/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go +++ b/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" "github.com/gluster/glusterd2/pkg/utils" @@ -75,7 +75,7 @@ func mountHost(g *GlusterVirtBlk, hostVolume string) (string, error) { func (g *GlusterVirtBlk) CreateBlockVolume(name string, size uint64, hostVolume string, options ...blockprovider.BlockVolOption) (blockprovider.BlockVolume, error) { var ( blockVolOpts = &blockprovider.BlockVolumeOptions{} - clusterLocks = transaction.Locks{} + clusterLocks = oldtransaction.Locks{} ) blockVolOpts.ApplyOpts(options...) @@ -145,7 +145,7 @@ func (g *GlusterVirtBlk) CreateBlockVolume(name string, size uint64, hostVolume func (g *GlusterVirtBlk) DeleteBlockVolume(name string, options ...blockprovider.BlockVolOption) error { var ( blockVolOpts = &blockprovider.BlockVolumeOptions{} - clusterLocks = transaction.Locks{} + clusterLocks = oldtransaction.Locks{} ) blockVolOpts.ApplyOpts(options...) diff --git a/plugins/blockvolume/hostvol/hostvol_manager.go b/plugins/blockvolume/hostvol/hostvol_manager.go index 46b6a2e16..42532d269 100644 --- a/plugins/blockvolume/hostvol/hostvol_manager.go +++ b/plugins/blockvolume/hostvol/hostvol_manager.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/plugins/blockvolume/api" @@ -58,7 +58,7 @@ func (g *GlusterVolManager) GetHostingVolumesInUse() []*volume.Volinfo { func (g *GlusterVolManager) GetOrCreateHostingVolume(name string, minSizeLimit uint64, hostVolumeInfo *api.HostVolumeInfo) (*volume.Volinfo, error) { var ( volInfo *volume.Volinfo - clusterLocks = transaction.Locks{} + clusterLocks = oldtransaction.Locks{} ) if err := clusterLocks.Lock(path.Join(globalLockID, name)); err != nil { diff --git a/plugins/blockvolume/hostvol/utils.go b/plugins/blockvolume/hostvol/utils.go index 6f258896d..f205c76eb 100644 --- a/plugins/blockvolume/hostvol/utils.go +++ b/plugins/blockvolume/hostvol/utils.go @@ -11,7 +11,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/commands/volumes" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/size" @@ -92,7 +92,7 @@ func CreateAndStartHostingVolume(req *api.VolCreateReq) (*volume.Volinfo, error) // f := func(a, b uint64) uint64{return a +b } func ResizeBlockHostingVolume(volName string, blockSize interface{}, resizeFunc func(blockHostingAvailableSize, blockSize uint64) uint64) error { var ( - clusterLocks = transaction.Locks{} + clusterLocks = oldtransaction.Locks{} ) if err := clusterLocks.Lock(volName); err != nil { diff --git a/plugins/device/deviceutils/store-utils.go b/plugins/device/deviceutils/store-utils.go index 750b5cd2b..1c13438ca 100644 --- a/plugins/device/deviceutils/store-utils.go +++ b/plugins/device/deviceutils/store-utils.go @@ -6,8 +6,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transaction" gderrors "github.com/gluster/glusterd2/pkg/errors" "github.com/gluster/glusterd2/pkg/lvmutils" deviceapi "github.com/gluster/glusterd2/plugins/device/api" @@ -117,7 +117,7 @@ func UpdateDeviceFreeSize(peerID, device string) error { // AddDeviceFreeSize updates device available size func AddDeviceFreeSize(peerID, device string, size uint64) error { - clusterLocks := transaction.Locks{} + clusterLocks := oldtransaction.Locks{} if err := clusterLocks.Lock(peerID + device); err != nil { return err } @@ -135,7 +135,7 @@ func AddDeviceFreeSize(peerID, device string, size uint64) error { // ReduceDeviceFreeSize updates device available size func ReduceDeviceFreeSize(peerID, device string, size uint64) error { - clusterLocks := transaction.Locks{} + clusterLocks := oldtransaction.Locks{} if err := clusterLocks.Lock(peerID + device); err != nil { return err } diff --git a/plugins/device/init.go b/plugins/device/init.go index 3c2628193..dea5388ef 100644 --- a/plugins/device/init.go +++ b/plugins/device/init.go @@ -1,8 +1,8 @@ package device import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" deviceapi "github.com/gluster/glusterd2/plugins/device/api" ) @@ -61,5 +61,5 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - transaction.RegisterStepFunc(txnPrepareDevice, "prepare-device") + oldtransaction.RegisterStepFunc(txnPrepareDevice, "prepare-device") } diff --git a/plugins/device/rest.go b/plugins/device/rest.go index 6f4795716..5e6a4eb51 100644 --- a/plugins/device/rest.go +++ b/plugins/device/rest.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" deviceapi "github.com/gluster/glusterd2/plugins/device/api" @@ -39,7 +39,7 @@ func deviceAddHandler(w http.ResponseWriter, r *http.Request) { req.ProvisionerType = api.ProvisionerTypeLvm } - txn, err := transaction.NewTxnWithLocks(ctx, peerID) + txn, err := oldtransaction.NewTxnWithLocks(ctx, peerID) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -71,7 +71,7 @@ func deviceAddHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = []uuid.UUID{peerInfo.ID} - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "prepare-device", Nodes: txn.Nodes, @@ -181,7 +181,7 @@ func deviceEditHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, peerID+device) + txn, err := oldtransaction.NewTxnWithLocks(ctx, peerID+device) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) diff --git a/plugins/device/transaction.go b/plugins/device/transaction.go index 22711554c..53b055443 100644 --- a/plugins/device/transaction.go +++ b/plugins/device/transaction.go @@ -3,7 +3,7 @@ package device import ( "os" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/fsutils" "github.com/gluster/glusterd2/pkg/lvmutils" @@ -13,7 +13,7 @@ import ( "github.com/pborman/uuid" ) -func txnPrepareDevice(c transaction.TxnCtx) error { +func txnPrepareDevice(c oldtransaction.TxnCtx) error { var req deviceapi.AddDeviceReq if err := c.Get("req", &req); err != nil { c.Logger().WithError(err).WithField("key", "req").Error("Failed to get key from transaction context") @@ -25,7 +25,7 @@ func txnPrepareDevice(c transaction.TxnCtx) error { return txnPrepareDeviceLvm(req, c) } -func txnPrepareDeviceLvm(req deviceapi.AddDeviceReq, c transaction.TxnCtx) error { +func txnPrepareDeviceLvm(req deviceapi.AddDeviceReq, c oldtransaction.TxnCtx) error { var peerID uuid.UUID if err := c.Get("peerid", &peerID); err != nil { c.Logger().WithError(err).WithField("key", "peerid").Error("Failed to get key from transaction context") @@ -72,7 +72,7 @@ func txnPrepareDeviceLvm(req deviceapi.AddDeviceReq, c transaction.TxnCtx) error return nil } -func txnPrepareDeviceLoop(req deviceapi.AddDeviceReq, c transaction.TxnCtx) error { +func txnPrepareDeviceLoop(req deviceapi.AddDeviceReq, c oldtransaction.TxnCtx) error { var peerID uuid.UUID if err := c.Get("peerid", &peerID); err != nil { c.Logger().WithError(err).WithField("key", "peerid").Error("Failed to get key from transaction context") diff --git a/plugins/events/rest.go b/plugins/events/rest.go index 44c1d1026..337e9217b 100644 --- a/plugins/events/rest.go +++ b/plugins/events/rest.go @@ -5,9 +5,9 @@ import ( gd2events "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/errors" eventsapi "github.com/gluster/glusterd2/plugins/events/api" ) @@ -126,7 +126,7 @@ func eventsListHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, events) } -func checkConnection(c transaction.TxnCtx) error { +func checkConnection(c oldtransaction.TxnCtx) error { var req eventsapi.Webhook if err := c.Get("req", &req); err != nil { @@ -139,12 +139,12 @@ func checkConnection(c transaction.TxnCtx) error { func registerWebhookTestStepFuncs() { var sfs = []struct { name string - sf transaction.StepFunc + sf oldtransaction.StepFunc }{ {"webhook-test.checkConnection", checkConnection}, } for _, sf := range sfs { - transaction.RegisterStepFunc(sf.sf, sf.name) + oldtransaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -170,10 +170,10 @@ func webhookTestHandler(w http.ResponseWriter, r *http.Request) { return } - txn := transaction.NewTxn(ctx) + txn := oldtransaction.NewTxn(ctx) defer txn.Done() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "webhook-test.checkConnection", Nodes: allNodes, diff --git a/plugins/georeplication/init.go b/plugins/georeplication/init.go index 82e6ce236..c415c8dc0 100644 --- a/plugins/georeplication/init.go +++ b/plugins/georeplication/init.go @@ -1,8 +1,8 @@ package georeplication import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" georepapi "github.com/gluster/glusterd2/plugins/georeplication/api" ) @@ -130,15 +130,15 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - transaction.RegisterStepFunc(txnGeorepCreate, "georeplication-create.Commit") - transaction.RegisterStepFunc(txnGeorepStart, "georeplication-start.Commit") - transaction.RegisterStepFunc(txnGeorepStop, "georeplication-stop.Commit") - transaction.RegisterStepFunc(txnGeorepDelete, "georeplication-delete.Commit") - transaction.RegisterStepFunc(txnGeorepPause, "georeplication-pause.Commit") - transaction.RegisterStepFunc(txnGeorepResume, "georeplication-resume.Commit") - transaction.RegisterStepFunc(txnGeorepStatus, "georeplication-status.Commit") - transaction.RegisterStepFunc(txnGeorepConfigSet, "georeplication-configset.Commit") - transaction.RegisterStepFunc(txnGeorepConfigFilegen, "georeplication-configfilegen.Commit") - transaction.RegisterStepFunc(txnSSHKeysGenerate, "georeplication-ssh-keygen.Commit") - transaction.RegisterStepFunc(txnSSHKeysPush, "georeplication-ssh-keypush.Commit") + oldtransaction.RegisterStepFunc(txnGeorepCreate, "georeplication-create.Commit") + oldtransaction.RegisterStepFunc(txnGeorepStart, "georeplication-start.Commit") + oldtransaction.RegisterStepFunc(txnGeorepStop, "georeplication-stop.Commit") + oldtransaction.RegisterStepFunc(txnGeorepDelete, "georeplication-delete.Commit") + oldtransaction.RegisterStepFunc(txnGeorepPause, "georeplication-pause.Commit") + oldtransaction.RegisterStepFunc(txnGeorepResume, "georeplication-resume.Commit") + oldtransaction.RegisterStepFunc(txnGeorepStatus, "georeplication-status.Commit") + oldtransaction.RegisterStepFunc(txnGeorepConfigSet, "georeplication-configset.Commit") + oldtransaction.RegisterStepFunc(txnGeorepConfigFilegen, "georeplication-configfilegen.Commit") + oldtransaction.RegisterStepFunc(txnSSHKeysGenerate, "georeplication-ssh-keygen.Commit") + oldtransaction.RegisterStepFunc(txnSSHKeysPush, "georeplication-ssh-keypush.Commit") } diff --git a/plugins/georeplication/rest.go b/plugins/georeplication/rest.go index 50a9dc887..22f95851b 100644 --- a/plugins/georeplication/rest.go +++ b/plugins/georeplication/rest.go @@ -11,8 +11,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" "github.com/gluster/glusterd2/pkg/utils" @@ -110,7 +110,7 @@ func georepCreateHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, req.MasterVol) + txn, err := oldtransaction.NewTxnWithLocks(ctx, req.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -188,7 +188,7 @@ func georepCreateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "vol-option.UpdateVolinfo", UndoFunc: "vol-option.UpdateVolinfo.Undo", @@ -284,7 +284,7 @@ func georepActionHandler(w http.ResponseWriter, r *http.Request, action actionTy return } - txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -330,7 +330,7 @@ func georepActionHandler(w http.ResponseWriter, r *http.Request, action actionTy return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: doFunc, Nodes: vol.Nodes(), @@ -414,7 +414,7 @@ func georepDeleteHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -431,7 +431,7 @@ func georepDeleteHandler(w http.ResponseWriter, r *http.Request) { } // TODO: Add transaction step to clean xattrs specific to georep session - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "georeplication-delete.Commit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -505,11 +505,11 @@ func georepStatusHandler(w http.ResponseWriter, r *http.Request) { } // Status Transaction - txn := transaction.NewTxn(ctx) + txn := oldtransaction.NewTxn(ctx) defer txn.Done() txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "georeplication-status.Commit", Nodes: txn.Nodes, @@ -749,7 +749,7 @@ func georepConfigSetHandler(w http.ResponseWriter, r *http.Request) { } } - txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -780,7 +780,7 @@ func georepConfigSetHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "georeplication-configset.Commit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -895,7 +895,7 @@ func georepConfigResetHandler(w http.ResponseWriter, r *http.Request) { restartRequired = false } - txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -915,7 +915,7 @@ func georepConfigResetHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "georeplication-configset.Commit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -989,7 +989,7 @@ func georepSSHKeyGenerateHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -1006,7 +1006,7 @@ func georepSSHKeyGenerateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "georeplication-ssh-keygen.Commit", Nodes: txn.Nodes, @@ -1064,7 +1064,7 @@ func georepSSHKeyPushHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -1088,7 +1088,7 @@ func georepSSHKeyPushHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "georeplication-ssh-keypush.Commit", Nodes: txn.Nodes, diff --git a/plugins/georeplication/transactions.go b/plugins/georeplication/transactions.go index 46db09824..285c98ee3 100644 --- a/plugins/georeplication/transactions.go +++ b/plugins/georeplication/transactions.go @@ -12,7 +12,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/utils" @@ -27,7 +27,7 @@ const ( gsyncdStatusTxnKey string = "gsyncdstatuses" ) -func txnGeorepCreate(c transaction.TxnCtx) error { +func txnGeorepCreate(c oldtransaction.TxnCtx) error { var sessioninfo georepapi.GeorepSession if err := c.Get("geosession", &sessioninfo); err != nil { return err @@ -44,7 +44,7 @@ func txnGeorepCreate(c transaction.TxnCtx) error { return nil } -func gsyncdAction(c transaction.TxnCtx, action actionType) error { +func gsyncdAction(c oldtransaction.TxnCtx, action actionType) error { var masterid string var remoteid string if err := c.Get("mastervolid", &masterid); err != nil { @@ -91,15 +91,15 @@ func gsyncdAction(c transaction.TxnCtx, action actionType) error { return err } -func txnGeorepStart(c transaction.TxnCtx) error { +func txnGeorepStart(c oldtransaction.TxnCtx) error { return gsyncdAction(c, actionStart) } -func txnGeorepStop(c transaction.TxnCtx) error { +func txnGeorepStop(c oldtransaction.TxnCtx) error { return gsyncdAction(c, actionStop) } -func txnGeorepDelete(c transaction.TxnCtx) error { +func txnGeorepDelete(c oldtransaction.TxnCtx) error { var masterid string var remoteid string if err := c.Get("mastervolid", &masterid); err != nil { @@ -125,15 +125,15 @@ func txnGeorepDelete(c transaction.TxnCtx) error { return nil } -func txnGeorepPause(c transaction.TxnCtx) error { +func txnGeorepPause(c oldtransaction.TxnCtx) error { return gsyncdAction(c, actionPause) } -func txnGeorepResume(c transaction.TxnCtx) error { +func txnGeorepResume(c oldtransaction.TxnCtx) error { return gsyncdAction(c, actionResume) } -func txnGeorepStatus(c transaction.TxnCtx) error { +func txnGeorepStatus(c oldtransaction.TxnCtx) error { var masterid string var remoteid string var err error @@ -185,7 +185,7 @@ func txnGeorepStatus(c transaction.TxnCtx) error { return nil } -func aggregateGsyncdStatus(ctx transaction.TxnCtx, nodes []uuid.UUID) (*map[string]georepapi.GeorepWorker, error) { +func aggregateGsyncdStatus(ctx oldtransaction.TxnCtx, nodes []uuid.UUID) (*map[string]georepapi.GeorepWorker, error) { var workersStatuses = make(map[string]georepapi.GeorepWorker) // Loop over each node on which txn was run. @@ -206,7 +206,7 @@ func aggregateGsyncdStatus(ctx transaction.TxnCtx, nodes []uuid.UUID) (*map[stri return &workersStatuses, nil } -func txnGeorepConfigSet(c transaction.TxnCtx) error { +func txnGeorepConfigSet(c oldtransaction.TxnCtx) error { var masterid string var remoteid string var session georepapi.GeorepSession @@ -300,7 +300,7 @@ func configFileGenerate(session *georepapi.GeorepSession) error { return ioutil.WriteFile(configFile, []byte(strings.Join(confdata, "\n")), 0644) } -func txnGeorepConfigFilegen(c transaction.TxnCtx) error { +func txnGeorepConfigFilegen(c oldtransaction.TxnCtx) error { var masterid string var remoteid string var session georepapi.GeorepSession @@ -341,7 +341,7 @@ func txnGeorepConfigFilegen(c transaction.TxnCtx) error { return nil } -func txnSSHKeysGenerate(c transaction.TxnCtx) error { +func txnSSHKeysGenerate(c oldtransaction.TxnCtx) error { var volname string var err error var args []string @@ -402,7 +402,7 @@ func txnSSHKeysGenerate(c transaction.TxnCtx) error { return err } -func txnSSHKeysPush(c transaction.TxnCtx) error { +func txnSSHKeysPush(c oldtransaction.TxnCtx) error { var err error var sshkeys []georepapi.GeorepSSHPublicKey var user string diff --git a/plugins/glustershd/init.go b/plugins/glustershd/init.go index 5c7fa9b32..92de478d3 100644 --- a/plugins/glustershd/init.go +++ b/plugins/glustershd/init.go @@ -1,8 +1,8 @@ package glustershd import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" glustershdapi "github.com/gluster/glusterd2/plugins/glustershd/api" ) @@ -52,5 +52,5 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - transaction.RegisterStepFunc(txnSelfHeal, "selfheal.Heal") + oldtransaction.RegisterStepFunc(txnSelfHeal, "selfheal.Heal") } diff --git a/plugins/glustershd/rest.go b/plugins/glustershd/rest.go index 26ffd8622..2f4546c8e 100644 --- a/plugins/glustershd/rest.go +++ b/plugins/glustershd/rest.go @@ -11,9 +11,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" gderrors "github.com/gluster/glusterd2/pkg/errors" glustershdapi "github.com/gluster/glusterd2/plugins/glustershd/api" @@ -135,7 +135,7 @@ func selfhealInfoHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -214,7 +214,7 @@ func selfHealHandler(w http.ResponseWriter, r *http.Request) { return } } - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -252,7 +252,7 @@ func selfHealHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "selfheal.Heal", Nodes: volinfo.Nodes(), diff --git a/plugins/glustershd/transactions.go b/plugins/glustershd/transactions.go index 29be28d65..921c039e4 100644 --- a/plugins/glustershd/transactions.go +++ b/plugins/glustershd/transactions.go @@ -8,8 +8,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" ) @@ -61,7 +61,7 @@ func selectHxlatorsWithBricks(volinfo *volume.Volinfo, healType int) map[string] return reqDict } -func txnSelfHeal(c transaction.TxnCtx) error { +func txnSelfHeal(c oldtransaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { diff --git a/plugins/rebalance/eventnotify.go b/plugins/rebalance/eventnotify.go index fd5aeab8e..609636e7b 100644 --- a/plugins/rebalance/eventnotify.go +++ b/plugins/rebalance/eventnotify.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/volume" rebalanceapi "github.com/gluster/glusterd2/plugins/rebalance/api" @@ -34,7 +34,7 @@ func HandleEventNotify(status map[string]string) error { var rebalinfo *rebalanceapi.RebalInfo var rebalNodeStatus rebalanceapi.RebalNodeStatus - txn, err := transaction.NewTxnWithLocks(context.TODO(), volname) + txn, err := oldtransaction.NewTxnWithLocks(context.TODO(), volname) if err != nil { log.WithError(err).Error("Locking failed. Unable to update store") return err diff --git a/plugins/rebalance/init.go b/plugins/rebalance/init.go index 24339324f..c4c6b2bc5 100644 --- a/plugins/rebalance/init.go +++ b/plugins/rebalance/init.go @@ -1,8 +1,8 @@ package rebalance import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" rebalanceapi "github.com/gluster/glusterd2/plugins/rebalance/api" ) @@ -47,8 +47,8 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - transaction.RegisterStepFunc(txnRebalanceStart, "rebalance-start") - transaction.RegisterStepFunc(txnRebalanceStop, "rebalance-stop") - transaction.RegisterStepFunc(txnRebalanceStatus, "rebalance-status") - transaction.RegisterStepFunc(txnRebalanceStoreDetails, "rebalance-store") + oldtransaction.RegisterStepFunc(txnRebalanceStart, "rebalance-start") + oldtransaction.RegisterStepFunc(txnRebalanceStop, "rebalance-stop") + oldtransaction.RegisterStepFunc(txnRebalanceStatus, "rebalance-status") + oldtransaction.RegisterStepFunc(txnRebalanceStoreDetails, "rebalance-store") } diff --git a/plugins/rebalance/rest.go b/plugins/rebalance/rest.go index ec82a6102..d351843bb 100644 --- a/plugins/rebalance/rest.go +++ b/plugins/rebalance/rest.go @@ -5,8 +5,8 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" @@ -57,7 +57,7 @@ func rebalanceStartHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -88,7 +88,7 @@ func rebalanceStartHandler(w http.ResponseWriter, r *http.Request) { // Only this node will save the rebalinfo in the store txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "rebalance-start", Nodes: txn.Nodes, @@ -150,7 +150,7 @@ func rebalanceStopHandler(w http.ResponseWriter, r *http.Request) { // collect inputs from url volname := mux.Vars(r)["volname"] - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -179,7 +179,7 @@ func rebalanceStopHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "rebalance-stop", Nodes: txn.Nodes, @@ -227,7 +227,7 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) { // collect inputs from url volname := mux.Vars(r)["volname"] - txn, err := transaction.NewTxnWithLocks(ctx, volname) + txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -261,7 +261,7 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) { // Get the consolidated status from all the nodes txn.Nodes = vol.Nodes() - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "rebalance-status", Nodes: txn.Nodes, @@ -292,7 +292,7 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(r.Context(), w, http.StatusOK, response) } -func createRebalanceStatusResp(ctx transaction.TxnCtx, volinfo *volume.Volinfo) (*rebalanceapi.RebalStatus, error) { +func createRebalanceStatusResp(ctx oldtransaction.TxnCtx, volinfo *volume.Volinfo) (*rebalanceapi.RebalStatus, error) { var ( resp rebalanceapi.RebalStatus tmp rebalanceapi.RebalNodeStatus diff --git a/plugins/rebalance/transaction.go b/plugins/rebalance/transaction.go index 2fe7cb9e5..b70279f97 100644 --- a/plugins/rebalance/transaction.go +++ b/plugins/rebalance/transaction.go @@ -6,8 +6,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" rebalanceapi "github.com/gluster/glusterd2/plugins/rebalance/api" @@ -26,7 +26,7 @@ const ( rebalStatusTxnKey string = "rebalstatus" ) -func txnRebalanceStart(c transaction.TxnCtx) error { +func txnRebalanceStart(c oldtransaction.TxnCtx) error { var rinfo rebalanceapi.RebalInfo err := c.Get("rinfo", &rinfo) @@ -63,7 +63,7 @@ func txnRebalanceStart(c transaction.TxnCtx) error { return nil } -func txnRebalanceStop(c transaction.TxnCtx) error { +func txnRebalanceStop(c oldtransaction.TxnCtx) error { var rebalinfo rebalanceapi.RebalInfo err := c.Get("rinfo", &rebalinfo) if err != nil { @@ -134,7 +134,7 @@ func txnRebalanceStop(c transaction.TxnCtx) error { return nil } -func txnRebalanceStatus(c transaction.TxnCtx) error { +func txnRebalanceStatus(c oldtransaction.TxnCtx) error { var ( rebalinfo rebalanceapi.RebalInfo @@ -228,7 +228,7 @@ func txnRebalanceStatus(c transaction.TxnCtx) error { } -func txnRebalanceStoreDetails(c transaction.TxnCtx) error { +func txnRebalanceStoreDetails(c oldtransaction.TxnCtx) error { var rebalinfo rebalanceapi.RebalInfo err := c.Get("rinfo", &rebalinfo) diff --git a/plugins/tracemgmt/init.go b/plugins/tracemgmt/init.go index 98617bce4..4b190f1ea 100644 --- a/plugins/tracemgmt/init.go +++ b/plugins/tracemgmt/init.go @@ -1,8 +1,8 @@ package tracemgmt import ( + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" - "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" tracemgmtapi "github.com/gluster/glusterd2/plugins/tracemgmt/api" ) @@ -53,10 +53,10 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with Glusterd transaction framework func (p *Plugin) RegisterStepFuncs() { - transaction.RegisterStepFunc(txnTracingValidateConfig, "trace-mgmt.ValidateTraceConfig") - transaction.RegisterStepFunc(txnTracingStoreConfig, "trace-mgmt.StoreTraceConfig") - transaction.RegisterStepFunc(txnTracingUndoStoreConfig, "trace-mgmt.RestoreTraceConfig") - transaction.RegisterStepFunc(txnTracingDeleteStoreConfig, "trace-mgmt.UndoStoreTraceConfig") - transaction.RegisterStepFunc(txnTracingApplyNewConfig, "trace-mgmt.NotifyTraceConfigChange") - transaction.RegisterStepFunc(txnTracingDisable, "trace-mgmt.NotifyTraceDisable") + oldtransaction.RegisterStepFunc(txnTracingValidateConfig, "trace-mgmt.ValidateTraceConfig") + oldtransaction.RegisterStepFunc(txnTracingStoreConfig, "trace-mgmt.StoreTraceConfig") + oldtransaction.RegisterStepFunc(txnTracingUndoStoreConfig, "trace-mgmt.RestoreTraceConfig") + oldtransaction.RegisterStepFunc(txnTracingDeleteStoreConfig, "trace-mgmt.UndoStoreTraceConfig") + oldtransaction.RegisterStepFunc(txnTracingApplyNewConfig, "trace-mgmt.NotifyTraceConfigChange") + oldtransaction.RegisterStepFunc(txnTracingDisable, "trace-mgmt.NotifyTraceDisable") } diff --git a/plugins/tracemgmt/rest.go b/plugins/tracemgmt/rest.go index 67e994766..40c89d513 100644 --- a/plugins/tracemgmt/rest.go +++ b/plugins/tracemgmt/rest.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - "github.com/gluster/glusterd2/glusterd2/transaction" transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" "github.com/gluster/glusterd2/pkg/errors" tracemgmtapi "github.com/gluster/glusterd2/plugins/tracemgmt/api" @@ -54,7 +54,7 @@ func tracingEnableHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "trace-mgmt.ValidateTraceConfig", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -162,7 +162,7 @@ func tracingUpdateHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "trace-mgmt.ValidateTraceConfig", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -220,7 +220,7 @@ func tracingDisableHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*transaction.Step{ + txn.Steps = []*oldtransaction.Step{ { DoFunc: "trace-mgmt.UndoStoreTraceConfig", Nodes: []uuid.UUID{gdctx.MyUUID}, diff --git a/plugins/tracemgmt/transactions.go b/plugins/tracemgmt/transactions.go index 5923d696a..1c04e39d1 100644 --- a/plugins/tracemgmt/transactions.go +++ b/plugins/tracemgmt/transactions.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/pkg/tracing" tracemgmtapi "github.com/gluster/glusterd2/plugins/tracemgmt/api" @@ -16,7 +16,7 @@ import ( ) // Transaction step that validates the trace info passed -func txnTracingValidateConfig(c transaction.TxnCtx) error { +func txnTracingValidateConfig(c oldtransaction.TxnCtx) error { var req tracemgmtapi.SetupTracingReq if err := c.Get("req", &req); err != nil { return err @@ -60,7 +60,7 @@ func txnTracingValidateConfig(c transaction.TxnCtx) error { // storeTraceConfig uses the passed context key to get // trace config and updates it into the store. -func storeTraceConfig(c transaction.TxnCtx, key string) error { +func storeTraceConfig(c oldtransaction.TxnCtx, key string) error { var traceConfig tracemgmtapi.JaegerConfigInfo if err := c.Get(key, &traceConfig); err != nil { return err @@ -71,26 +71,26 @@ func storeTraceConfig(c transaction.TxnCtx, key string) error { } // Transaction step that stores the trace config -func txnTracingStoreConfig(c transaction.TxnCtx) error { +func txnTracingStoreConfig(c oldtransaction.TxnCtx) error { err := storeTraceConfig(c, "traceconfig") return err } // Transaction step that reverts the trace config -func txnTracingUndoStoreConfig(c transaction.TxnCtx) error { +func txnTracingUndoStoreConfig(c oldtransaction.TxnCtx) error { err := storeTraceConfig(c, "oldtraceconfig") return err } // Transaction step that deletes the trace config -func txnTracingDeleteStoreConfig(c transaction.TxnCtx) error { +func txnTracingDeleteStoreConfig(c oldtransaction.TxnCtx) error { err := traceutils.DeleteTraceConfig() return err } // Tranasaction step that reads trace config info from the store and updates // the in-memory trace config. -func txnTracingApplyNewConfig(c transaction.TxnCtx) error { +func txnTracingApplyNewConfig(c oldtransaction.TxnCtx) error { var traceConfig tracemgmtapi.JaegerConfigInfo if err := c.Get("traceconfig", &traceConfig); err != nil { return err @@ -138,7 +138,7 @@ func txnTracingApplyNewConfig(c transaction.TxnCtx) error { } // Transaction step that disables tracing and resets the tracing config. -func txnTracingDisable(c transaction.TxnCtx) error { +func txnTracingDisable(c oldtransaction.TxnCtx) error { // Disable tracing trace.ApplyConfig(trace.Config{DefaultSampler: trace.NeverSample()}) From 64badd8a181445a9edbf196be0ad6e9b639af5ad Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 10:53:17 +0530 Subject: [PATCH 2/7] Rename glusterd2/transactionv2 to glusterd2/transaction --- glusterd2/commands/peers/peer-rpc-svc.go | 4 ++-- glusterd2/commands/volumes/volume-create.go | 2 +- glusterd2/commands/volumes/volume-delete.go | 2 +- glusterd2/commands/volumes/volume-start.go | 2 +- glusterd2/commands/volumes/volume-stop.go | 2 +- glusterd2/main.go | 4 ++-- .../cleanuphandler/cleanup_handler.go | 2 +- glusterd2/{transactionv2 => transaction}/engine.go | 0 glusterd2/{transactionv2 => transaction}/errors.go | 0 glusterd2/{transactionv2 => transaction}/executor.go | 0 glusterd2/{transactionv2 => transaction}/steprunner.go | 0 glusterd2/{transactionv2 => transaction}/steptracing.go | 0 .../{transactionv2 => transaction}/tracingexecutor.go | 0 glusterd2/{transactionv2 => transaction}/transaction.go | 0 glusterd2/{transactionv2 => transaction}/txnmanager.go | 0 glusterd2/{transactionv2 => transaction}/types.go | 0 glusterd2/{transactionv2 => transaction}/utils.go | 0 plugins/tracemgmt/rest.go | 8 ++++---- 18 files changed, 13 insertions(+), 13 deletions(-) rename glusterd2/{transactionv2 => transaction}/cleanuphandler/cleanup_handler.go (98%) rename glusterd2/{transactionv2 => transaction}/engine.go (100%) rename glusterd2/{transactionv2 => transaction}/errors.go (100%) rename glusterd2/{transactionv2 => transaction}/executor.go (100%) rename glusterd2/{transactionv2 => transaction}/steprunner.go (100%) rename glusterd2/{transactionv2 => transaction}/steptracing.go (100%) rename glusterd2/{transactionv2 => transaction}/tracingexecutor.go (100%) rename glusterd2/{transactionv2 => transaction}/transaction.go (100%) rename glusterd2/{transactionv2 => transaction}/txnmanager.go (100%) rename glusterd2/{transactionv2 => transaction}/types.go (100%) rename glusterd2/{transactionv2 => transaction}/utils.go (100%) diff --git a/glusterd2/commands/peers/peer-rpc-svc.go b/glusterd2/commands/peers/peer-rpc-svc.go index d37f3b734..40a9f50ca 100644 --- a/glusterd2/commands/peers/peer-rpc-svc.go +++ b/glusterd2/commands/peers/peer-rpc-svc.go @@ -8,8 +8,8 @@ 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/transaction" + "github.com/gluster/glusterd2/glusterd2/transaction/cleanuphandler" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/utils" diff --git a/glusterd2/commands/volumes/volume-create.go b/glusterd2/commands/volumes/volume-create.go index 3d30dd09f..da0f9d351 100644 --- a/glusterd2/commands/volumes/volume-create.go +++ b/glusterd2/commands/volumes/volume-create.go @@ -12,7 +12,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" + transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" diff --git a/glusterd2/commands/volumes/volume-delete.go b/glusterd2/commands/volumes/volume-delete.go index 1beb98573..46314b8ec 100644 --- a/glusterd2/commands/volumes/volume-delete.go +++ b/glusterd2/commands/volumes/volume-delete.go @@ -8,7 +8,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" + transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gorilla/mux" diff --git a/glusterd2/commands/volumes/volume-start.go b/glusterd2/commands/volumes/volume-start.go index 533b5ee40..3f946cdbd 100644 --- a/glusterd2/commands/volumes/volume-start.go +++ b/glusterd2/commands/volumes/volume-start.go @@ -10,7 +10,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" + transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" diff --git a/glusterd2/commands/volumes/volume-stop.go b/glusterd2/commands/volumes/volume-stop.go index 6cd8ff8e4..86c6e8fe4 100644 --- a/glusterd2/commands/volumes/volume-stop.go +++ b/glusterd2/commands/volumes/volume-stop.go @@ -11,7 +11,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" + transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" diff --git a/glusterd2/main.go b/glusterd2/main.go index 60f97e4af..931e6e5bd 100644 --- a/glusterd2/main.go +++ b/glusterd2/main.go @@ -17,8 +17,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/pmap" "github.com/gluster/glusterd2/glusterd2/servers" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transactionv2" - "github.com/gluster/glusterd2/glusterd2/transactionv2/cleanuphandler" + "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/transaction/cleanuphandler" gdutils "github.com/gluster/glusterd2/glusterd2/utils" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/xlator" diff --git a/glusterd2/transactionv2/cleanuphandler/cleanup_handler.go b/glusterd2/transaction/cleanuphandler/cleanup_handler.go similarity index 98% rename from glusterd2/transactionv2/cleanuphandler/cleanup_handler.go rename to glusterd2/transaction/cleanuphandler/cleanup_handler.go index 56799245c..5863bc697 100644 --- a/glusterd2/transactionv2/cleanuphandler/cleanup_handler.go +++ b/glusterd2/transaction/cleanuphandler/cleanup_handler.go @@ -8,7 +8,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/store" - "github.com/gluster/glusterd2/glusterd2/transactionv2" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" diff --git a/glusterd2/transactionv2/engine.go b/glusterd2/transaction/engine.go similarity index 100% rename from glusterd2/transactionv2/engine.go rename to glusterd2/transaction/engine.go diff --git a/glusterd2/transactionv2/errors.go b/glusterd2/transaction/errors.go similarity index 100% rename from glusterd2/transactionv2/errors.go rename to glusterd2/transaction/errors.go diff --git a/glusterd2/transactionv2/executor.go b/glusterd2/transaction/executor.go similarity index 100% rename from glusterd2/transactionv2/executor.go rename to glusterd2/transaction/executor.go diff --git a/glusterd2/transactionv2/steprunner.go b/glusterd2/transaction/steprunner.go similarity index 100% rename from glusterd2/transactionv2/steprunner.go rename to glusterd2/transaction/steprunner.go diff --git a/glusterd2/transactionv2/steptracing.go b/glusterd2/transaction/steptracing.go similarity index 100% rename from glusterd2/transactionv2/steptracing.go rename to glusterd2/transaction/steptracing.go diff --git a/glusterd2/transactionv2/tracingexecutor.go b/glusterd2/transaction/tracingexecutor.go similarity index 100% rename from glusterd2/transactionv2/tracingexecutor.go rename to glusterd2/transaction/tracingexecutor.go diff --git a/glusterd2/transactionv2/transaction.go b/glusterd2/transaction/transaction.go similarity index 100% rename from glusterd2/transactionv2/transaction.go rename to glusterd2/transaction/transaction.go diff --git a/glusterd2/transactionv2/txnmanager.go b/glusterd2/transaction/txnmanager.go similarity index 100% rename from glusterd2/transactionv2/txnmanager.go rename to glusterd2/transaction/txnmanager.go diff --git a/glusterd2/transactionv2/types.go b/glusterd2/transaction/types.go similarity index 100% rename from glusterd2/transactionv2/types.go rename to glusterd2/transaction/types.go diff --git a/glusterd2/transactionv2/utils.go b/glusterd2/transaction/utils.go similarity index 100% rename from glusterd2/transactionv2/utils.go rename to glusterd2/transaction/utils.go diff --git a/plugins/tracemgmt/rest.go b/plugins/tracemgmt/rest.go index 40c89d513..6e75aba56 100644 --- a/plugins/tracemgmt/rest.go +++ b/plugins/tracemgmt/rest.go @@ -7,7 +7,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transactionv2" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/errors" tracemgmtapi "github.com/gluster/glusterd2/plugins/tracemgmt/api" "github.com/gluster/glusterd2/plugins/tracemgmt/traceutils" @@ -34,7 +34,7 @@ func tracingEnableHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transactionv2.NewTxnWithLocks(ctx, gdctx.MyClusterID.String()) + txn, err := transaction.NewTxnWithLocks(ctx, gdctx.MyClusterID.String()) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -124,7 +124,7 @@ func tracingUpdateHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transactionv2.NewTxnWithLocks(ctx, gdctx.MyClusterID.String()) + txn, err := transaction.NewTxnWithLocks(ctx, gdctx.MyClusterID.String()) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -206,7 +206,7 @@ func tracingDisableHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := transactionv2.NewTxnWithLocks(ctx, gdctx.MyClusterID.String()) + txn, err := transaction.NewTxnWithLocks(ctx, gdctx.MyClusterID.String()) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) From b9756b24b9c41ffb22398dfc93c3f5590c56875f Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 13:59:06 +0530 Subject: [PATCH 3/7] Move in missing pieces to glusterd2/transaction ... and remove all usage of glusterd2/oldtransaction from glusterd2/transaction. --- glusterd2/transaction/context.go | 232 +++++++++++++++++++++++++++ glusterd2/transaction/lock.go | 92 +++++++++++ glusterd2/transaction/registry.go | 43 +++++ glusterd2/transaction/step.go | 45 ++++++ glusterd2/transaction/steprunner.go | 15 +- glusterd2/transaction/steptracing.go | 6 +- glusterd2/transaction/transaction.go | 44 ++--- glusterd2/transaction/txnmanager.go | 11 +- 8 files changed, 448 insertions(+), 40 deletions(-) create mode 100644 glusterd2/transaction/context.go create mode 100644 glusterd2/transaction/lock.go create mode 100644 glusterd2/transaction/registry.go create mode 100644 glusterd2/transaction/step.go diff --git a/glusterd2/transaction/context.go b/glusterd2/transaction/context.go new file mode 100644 index 000000000..cde79dc00 --- /dev/null +++ b/glusterd2/transaction/context.go @@ -0,0 +1,232 @@ +package transaction + +import ( + "context" + "encoding/json" + "errors" + "reflect" + + "github.com/gluster/glusterd2/glusterd2/store" + + "github.com/coreos/etcd/clientv3" + "github.com/pborman/uuid" + log "github.com/sirupsen/logrus" +) + +// TxnCtx is used to carry contextual information across the lifetime of a transaction +type TxnCtx interface { + // Set attaches the given key with value to the context. It updates value if key exists already. + Set(key string, value interface{}) error + // SetNodeResult is similar to Set but prefixes the key with node UUID specified. + SetNodeResult(peerID uuid.UUID, key string, value interface{}) error + // Get gets the value for the given key. Returns an error if the key is not present + Get(key string, value interface{}) error + // GetNodeResult is similar to Get but prefixes the key with node UUID specified. + GetNodeResult(peerID uuid.UUID, key string, value interface{}) error + // GetTxnReqID gets the reqID string saved in the transaction. + GetTxnReqID() string + // Delete deletes the key and value + Delete(key string) error + // Logger returns the Logrus logger associated with the context + Logger() log.FieldLogger + + // Commit writes all locally cached keys and values into the store using + // a single etcd transaction. This is for internal use by the txn framework + // and hence isn't exported. + Commit() error + + // SyncCache synchronizes the locally cached keys and values from the store + SyncCache() error +} + +// Tctx represents structure for transaction context +type Tctx struct { + config *TxnCtxConfig // this will be marshalled and sent on wire + logger log.FieldLogger + readSet map[string][]byte // cached responses from store + readCacheDirty bool + writeSet map[string]string // to be written to store +} + +// TxnCtxConfig is marshalled and sent on wire and is used to reconstruct Tctx +// on receiver's end. +type TxnCtxConfig struct { + LogFields log.Fields + StorePrefix string +} + +func newCtx(config *TxnCtxConfig) *Tctx { + return &Tctx{ + config: config, + logger: log.StandardLogger().WithFields(config.LogFields), + readSet: make(map[string][]byte), + writeSet: make(map[string]string), + readCacheDirty: true, + } +} + +// NewCtx returns a transaction context from given config +func NewCtx(config *TxnCtxConfig) *Tctx { + return newCtx(config) +} + +// Set attaches the given key-value pair to the context. +// If the key exists, the value will be updated. +func (c *Tctx) Set(key string, value interface{}) error { + + b, err := json.Marshal(value) + if err != nil { + c.logger.WithError(err).WithField("key", key).Error("failed to marshal value") + return err + } + + storeKey := c.config.StorePrefix + key + + // Update the read cache to serve future local Get()s for this key from cache + c.readSet[storeKey] = b + + // Update write cache, the contents of which will be committed to store later + c.writeSet[storeKey] = string(b) + + return nil +} + +// SyncCache synchronizes the locally cached keys and values from the store +func (c *Tctx) SyncCache() error { + resp, err := store.Get(context.TODO(), c.config.StorePrefix, clientv3.WithPrefix()) + if err != nil { + return err + } + + for _, kv := range resp.Kvs { + c.readSet[string(kv.Key)] = kv.Value + } + return nil +} + +// Commit writes all locally cached keys and values into the store using +// a single etcd transaction. +func (c *Tctx) Commit() error { + + if len(c.writeSet) == 0 { + return nil + } + + var putOps []clientv3.Op + for key, value := range c.writeSet { + putOps = append(putOps, clientv3.OpPut(key, value)) + } + + ctx, cancel := context.WithTimeout(context.Background(), etcdTxnTimeout) + txn, err := store.Txn(ctx). + If(). + Then(putOps...). + Else(). + Commit() + cancel() + + if err != nil || !txn.Succeeded { + msg := "etcd txn to store txn context keys failed" + if err == nil { + // if txn.Succeeded = false + err = errors.New(msg) + } + c.logger.WithError(err).WithField("keys", + reflect.ValueOf(c.writeSet).MapKeys()).Error(msg) + return err + } + + expTxn.Add("txn_ctx_store_commit", 1) + + c.writeSet = make(map[string]string) + c.readCacheDirty = true + + return nil +} + +// SetNodeResult is similar to Set but prefixes the key with the node UUID +// specified. This function can be used by nodes to store results of +// transaction steps. +func (c *Tctx) SetNodeResult(peerID uuid.UUID, key string, value interface{}) error { + storeKey := peerID.String() + "/" + key + return c.Set(storeKey, value) +} + +// Get gets the value for the given key if available. +// Returns error if not found. +func (c *Tctx) Get(key string, value interface{}) error { + + // cache all keys and values from the store on the first call to Get + if c.readCacheDirty { + if err := c.SyncCache(); err != nil { + c.logger.WithError(err).WithField("key", key).Error("failed to get key from transaction context") + return err + } + c.readCacheDirty = false + } + + // return cached key + storeKey := c.config.StorePrefix + key + if data, ok := c.readSet[storeKey]; ok { + if err := json.Unmarshal(data, value); err != nil { + c.logger.WithError(err).WithField("key", storeKey).Error("failed to unmarshall value") + } + } else { + return errors.New("key not found") + } + + return nil +} + +// GetNodeResult is similar to Get but prefixes the key with node UUID +// specified. This function can be used by the transaction initiator node to +// fetch results of transaction step run on remote nodes. +func (c *Tctx) GetNodeResult(peerID uuid.UUID, key string, value interface{}) error { + storeKey := peerID.String() + "/" + key + return c.Get(storeKey, value) +} + +// GetTxnReqID gets the reqID string saved within the txnCtxConfig. +func (c *Tctx) GetTxnReqID() string { + return c.config.LogFields["reqid"].(string) +} + +// Delete deletes the key and attached value +func (c *Tctx) Delete(key string) error { + + storeKey := c.config.StorePrefix + key + + delete(c.readSet, storeKey) + delete(c.writeSet, storeKey) + + // TODO: Optimize this by doing it as part of etcd txn in commit() + if _, err := store.Delete(context.TODO(), storeKey); err != nil { + c.logger.WithError(err).WithField("key", storeKey).Error( + "failed to delete key") + return err + } + expTxn.Add("txn_ctx_store_delete", 1) + return nil +} + +// Logger returns the Logrus logger associated with the context +func (c *Tctx) Logger() log.FieldLogger { + return c.logger +} + +// MarshalJSON implements the json.Marshaler interface +func (c *Tctx) MarshalJSON() ([]byte, error) { + return json.Marshal(c.config) +} + +// UnmarshalJSON implements the json.Unmarshaler interface +func (c *Tctx) UnmarshalJSON(d []byte) error { + + if err := json.Unmarshal(d, &c.config); err != nil { + return err + } + + *c = *(newCtx(c.config)) + + return nil +} diff --git a/glusterd2/transaction/lock.go b/glusterd2/transaction/lock.go new file mode 100644 index 000000000..85c60c1ad --- /dev/null +++ b/glusterd2/transaction/lock.go @@ -0,0 +1,92 @@ +package transaction + +import ( + "context" + "errors" + "time" + + "github.com/gluster/glusterd2/glusterd2/store" + + "github.com/coreos/etcd/clientv3/concurrency" + log "github.com/sirupsen/logrus" +) + +const ( + lockPrefix = "locks/" + lockObtainTimeout = 5 * time.Second + lockTTL = 10 +) + +var ( + // ErrLockTimeout is the error returned when lock could not be obtained + // and the request timed out + ErrLockTimeout = errors.New("could not obtain lock: another conflicting transaction may be in progress") + // ErrLockExists is returned when a lock already exists within the transaction + ErrLockExists = errors.New("existing lock found for given lock ID") +) + +// Locks are the collection of cluster wide transaction lock +type Locks map[string]*concurrency.Mutex + +func (l Locks) lock(lockID string) error { + var logger = log.WithField("lockID", lockID) + + // Ensure that no prior lock exists for the given lockID in this transaction + if _, ok := l[lockID]; ok { + return ErrLockExists + } + + logger.Debug("attempting to obtain lock") + + key := lockPrefix + lockID + s, err := concurrency.NewSession(store.Store.NamespaceClient, concurrency.WithTTL(lockTTL)) + if err != nil { + return err + } + + locker := concurrency.NewMutex(s, key) + + ctx, cancel := context.WithTimeout(store.Store.Ctx(), lockObtainTimeout) + defer cancel() + + err = locker.Lock(ctx) + switch err { + case nil: + logger.Debug("lock obtained") + // Attach lock to the transaction + l[lockID] = locker + + case context.DeadlineExceeded: + logger.Debug("timeout: failed to obtain lock") + // Propagate this all the way back to the client as a HTTP 409 response + err = ErrLockTimeout + + default: + logger.WithError(err).Error("failed to obtain lock") + } + + return err +} + +// Lock obtains a cluster wide transaction lock on the given lockID/lockIDs, +// and attaches the obtained locks to the transaction +func (l Locks) Lock(lockID string, lockIDs ...string) error { + if err := l.lock(lockID); err != nil { + return err + } + for _, id := range lockIDs { + if err := l.lock(id); err != nil { + return err + } + } + return nil +} + +// UnLock releases all cluster wide obtained locks +func (l Locks) UnLock(ctx context.Context) { + for lockID, locker := range l { + if err := locker.Unlock(ctx); err == nil { + delete(l, lockID) + } + } +} diff --git a/glusterd2/transaction/registry.go b/glusterd2/transaction/registry.go new file mode 100644 index 000000000..e06254a9d --- /dev/null +++ b/glusterd2/transaction/registry.go @@ -0,0 +1,43 @@ +package transaction + +// The StepFunc registry registers StepFunc's to be used by transaction framework + +import ( + "sync" + + log "github.com/sirupsen/logrus" +) + +var sfRegistry = struct { + sync.RWMutex + sfMap map[string]StepFunc +}{} + +func registerStepFunc(s StepFunc, name string) { + if sfRegistry.sfMap == nil { + sfRegistry.sfMap = make(map[string]StepFunc) + } + + if _, ok := sfRegistry.sfMap[name]; ok { + log.WithField("stepname", name).Warning("step with provided name exists in registry and will be overwritten") + } + + sfRegistry.sfMap[name] = s +} + +//RegisterStepFunc registers the given StepFunc in the registry +func RegisterStepFunc(s StepFunc, name string) { + sfRegistry.Lock() + defer sfRegistry.Unlock() + + registerStepFunc(s, name) +} + +//getStepFunc returns named step if found. +func getStepFunc(name string) (StepFunc, bool) { + sfRegistry.RLock() + defer sfRegistry.RUnlock() + + s, ok := sfRegistry.sfMap[name] + return s, ok +} diff --git a/glusterd2/transaction/step.go b/glusterd2/transaction/step.go new file mode 100644 index 000000000..a1e2f5de9 --- /dev/null +++ b/glusterd2/transaction/step.go @@ -0,0 +1,45 @@ +package transaction + +import ( + "context" + "errors" + + "github.com/pborman/uuid" +) + +// StepFunc is the function that is supposed to be run during a transaction step +type StepFunc func(TxnCtx) error + +// Step is a combination of a StepFunc and a list of nodes the step is supposed to be run on +// +// DoFunc and UndoFunc are names of StepFuncs registered in the registry +// DoFunc performs does the action +// UndoFunc undoes anything done by DoFunc +type Step struct { + DoFunc string + UndoFunc string + Nodes []uuid.UUID + Skip bool + Sync bool +} + +var ( + // ErrStepFuncNotFound is returned if the stepfunc isn't found. + ErrStepFuncNotFound = errors.New("stepFunc was not found") +) + +// RunStepFuncLocally runs a step func on local node +func RunStepFuncLocally(origCtx context.Context, stepName string, ctx TxnCtx) error { + stepFunc, ok := getStepFunc(stepName) + if !ok { + return ErrStepFuncNotFound + } + + if err := stepFunc(ctx); err != nil { + return err + } + + // if step function executes successfully, commit the + // results to the store + return ctx.Commit() +} diff --git a/glusterd2/transaction/steprunner.go b/glusterd2/transaction/steprunner.go index 97c4fc571..b68d54ee0 100644 --- a/glusterd2/transaction/steprunner.go +++ b/glusterd2/transaction/steprunner.go @@ -5,7 +5,6 @@ import ( "time" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" "github.com/pborman/uuid" @@ -13,8 +12,8 @@ import ( // StepManager is an interface for running a step and also rollback step on local node type StepManager interface { - RunStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error - RollBackStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error + RunStep(ctx context.Context, step *Step, txnCtx TxnCtx) error + RollBackStep(ctx context.Context, step *Step, txnCtx TxnCtx) error SyncStep(ctx context.Context, stepIndex int, txn *Txn) error } @@ -30,7 +29,7 @@ func newStepManager() StepManager { } } -func (sm *stepManager) shouldRunStep(step *oldtransaction.Step) bool { +func (sm *stepManager) shouldRunStep(step *Step) bool { if step.Skip { return false } @@ -46,9 +45,9 @@ func (sm *stepManager) shouldRunStep(step *oldtransaction.Step) bool { // runStep synchronises the locally cached keys and values from the store // before running the step function on node -func (sm *stepManager) runStep(ctx context.Context, stepName string, txnCtx oldtransaction.TxnCtx) error { +func (sm *stepManager) runStep(ctx context.Context, stepName string, txnCtx TxnCtx) error { txnCtx.SyncCache() - return oldtransaction.RunStepFuncLocally(ctx, stepName, txnCtx) + return RunStepFuncLocally(ctx, stepName, txnCtx) } // isPrevStepsExecutedOnNode reports that all previous steps @@ -92,7 +91,7 @@ func (sm *stepManager) SyncStep(ctx context.Context, syncStepIndex int, txn *Txn } // RollBackStep will rollback a given step on local node -func (sm *stepManager) RollBackStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error { +func (sm *stepManager) RollBackStep(ctx context.Context, step *Step, txnCtx TxnCtx) error { if !sm.shouldRunStep(step) { txnCtx.Logger().WithField("step", step.UndoFunc).Debug("peer is excluded in running this step") return nil @@ -106,7 +105,7 @@ func (sm *stepManager) RollBackStep(ctx context.Context, step *oldtransaction.St } // RunStepRunStep will execute the step on local node -func (sm *stepManager) RunStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) error { +func (sm *stepManager) RunStep(ctx context.Context, step *Step, txnCtx TxnCtx) error { if !sm.shouldRunStep(step) { txnCtx.Logger().WithField("step", step.DoFunc).Debug("peer is excluded in running this step") return nil diff --git a/glusterd2/transaction/steptracing.go b/glusterd2/transaction/steptracing.go index c04fd03d1..d1a356326 100644 --- a/glusterd2/transaction/steptracing.go +++ b/glusterd2/transaction/steptracing.go @@ -4,8 +4,6 @@ import ( "context" "fmt" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" - "go.opencensus.io/trace" ) @@ -18,7 +16,7 @@ type tracingManager struct { } // RunStep is a middleware which creates tracing span for step.DoFunc -func (t *tracingManager) RunStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) (err error) { +func (t *tracingManager) RunStep(ctx context.Context, step *Step, txnCtx TxnCtx) (err error) { spanName := fmt.Sprintf("RunStep/%s", step.DoFunc) ctx, span := trace.StartSpan(ctx, spanName) defer span.End() @@ -37,7 +35,7 @@ func (t *tracingManager) RunStep(ctx context.Context, step *oldtransaction.Step, } // RollBackStep is a middleware which creates tracing span for step.UndoFunc -func (t *tracingManager) RollBackStep(ctx context.Context, step *oldtransaction.Step, txnCtx oldtransaction.TxnCtx) (err error) { +func (t *tracingManager) RollBackStep(ctx context.Context, step *Step, txnCtx TxnCtx) (err error) { spanName := fmt.Sprintf("RollBackStep/%s", step.UndoFunc) ctx, span := trace.StartSpan(ctx, spanName) defer span.End() diff --git a/glusterd2/transaction/transaction.go b/glusterd2/transaction/transaction.go index 34a5bc5de..fbd211bc8 100644 --- a/glusterd2/transaction/transaction.go +++ b/glusterd2/transaction/transaction.go @@ -9,7 +9,6 @@ import ( "time" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" "github.com/coreos/etcd/clientv3" @@ -23,23 +22,27 @@ const ( txnTimeOut = time.Minute * 3 ) +var ( + expTxn *expvar.Map +) + // Txn is a set of steps type Txn struct { - locks oldtransaction.Locks + locks Locks // Nodes is the union of the all the TxnStep.Nodes and is implicitly // set in Txn.Do(). This list is used to determine liveness of the // nodes before running the transaction steps. - Nodes []uuid.UUID `json:"nodes"` - StorePrefix string `json:"store_prefix"` - ID uuid.UUID `json:"id"` - ReqID uuid.UUID `json:"req_id"` - Ctx oldtransaction.TxnCtx `json:"ctx"` - Steps []*oldtransaction.Step `json:"steps"` - DontCheckAlive bool `json:"dont_check_alive"` - DisableRollback bool `json:"disable_rollback"` - StartTime time.Time `json:"start_time"` - TxnSpanCtx trace.SpanContext `json:"txn_span_ctx"` + Nodes []uuid.UUID `json:"nodes"` + StorePrefix string `json:"store_prefix"` + ID uuid.UUID `json:"id"` + ReqID uuid.UUID `json:"req_id"` + Ctx TxnCtx `json:"ctx"` + Steps []*Step `json:"steps"` + DontCheckAlive bool `json:"dont_check_alive"` + DisableRollback bool `json:"disable_rollback"` + StartTime time.Time `json:"start_time"` + TxnSpanCtx trace.SpanContext `json:"txn_span_ctx"` success chan struct{} error chan error @@ -53,16 +56,16 @@ func NewTxn(ctx context.Context) *Txn { t.ID = uuid.NewRandom() t.ReqID = gdctx.GetReqID(ctx) - t.locks = oldtransaction.Locks{} + t.locks = Locks{} t.StorePrefix = txnPrefix + t.ID.String() + "/" - config := &oldtransaction.TxnCtxConfig{ + config := &TxnCtxConfig{ LogFields: log.Fields{ "txnid": t.ID.String(), "reqid": t.ReqID.String(), }, StorePrefix: t.StorePrefix, } - t.Ctx = oldtransaction.NewCtx(config) + t.Ctx = NewCtx(config) spanCtx := trace.FromContext(ctx) t.TxnSpanCtx = spanCtx.SpanContext() t.Ctx.Logger().Debug("new transaction created") @@ -72,14 +75,14 @@ func NewTxn(ctx context.Context) *Txn { // NewTxnWithLocks returns an empty Txn with locks obtained on given lockIDs func NewTxnWithLocks(ctx context.Context, lockIDs ...string) (*Txn, error) { t := NewTxn(ctx) - t.locks = oldtransaction.Locks{} + t.locks = Locks{} err := t.acquireClusterLocks(lockIDs...) return t, err } func (t *Txn) acquireClusterLocks(lockIDs ...string) error { if t.locks == nil { - t.locks = oldtransaction.Locks{} + t.locks = Locks{} } for _, id := range lockIDs { @@ -283,11 +286,8 @@ func FilterNonFailedTxn(txns []*Txn) []*Txn { } func init() { - expVar := expvar.Get("txn") - if expVar == nil { - expVar = expvar.NewMap("txn") - } - expVar.(*expvar.Map).Set("engine_config", expvar.Func(func() interface{} { + expTxn = expvar.NewMap("txn") + expTxn.Set("engine_config", expvar.Func(func() interface{} { return map[string]interface{}{ "txn_timeout_second": txnTimeOut.Seconds(), "txn_sync_timeout_second": txnSyncTimeout.Seconds(), diff --git a/glusterd2/transaction/txnmanager.go b/glusterd2/transaction/txnmanager.go index 9407467bd..46e3caf64 100644 --- a/glusterd2/transaction/txnmanager.go +++ b/glusterd2/transaction/txnmanager.go @@ -10,7 +10,6 @@ import ( "sync" "time" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" "github.com/coreos/etcd/clientv3" @@ -186,7 +185,7 @@ func (tm *txnManager) watchRespToTxns(resp clientv3.WatchResponse) (txns []*Txn) continue } - txn := &Txn{Ctx: new(oldtransaction.Tctx)} + txn := &Txn{Ctx: new(Tctx)} if err := json.Unmarshal(event.Kv.Value, txn); err != nil { continue } @@ -220,7 +219,7 @@ func (tm *txnManager) GetTxnByUUID(id uuid.UUID) (*Txn, error) { kv := resp.Kvs[0] - txn := &Txn{Ctx: new(oldtransaction.Tctx)} + txn := &Txn{Ctx: new(Tctx)} if err := json.Unmarshal(kv.Value, txn); err != nil { return nil, err } @@ -239,7 +238,7 @@ func (tm *txnManager) GetTxns() (txns []*Txn) { continue } - txn := &Txn{Ctx: new(oldtransaction.Tctx)} + txn := &Txn{Ctx: new(Tctx)} if err := json.Unmarshal(kv.Value, txn); err != nil { continue } @@ -252,7 +251,7 @@ func (tm *txnManager) GetTxns() (txns []*Txn) { func (tm *txnManager) UpDateTxnStatus(status TxnStatus, txnID uuid.UUID, nodeIDs ...uuid.UUID) error { var ( ctx, cancel = context.WithTimeout(context.Background(), etcdTxnTimeout) - clusterLock = oldtransaction.Locks{} + clusterLock = Locks{} putOps []clientv3.Op ) @@ -284,7 +283,7 @@ func (tm *txnManager) GetTxnStatus(txnID uuid.UUID, nodeID uuid.UUID) (TxnStatus var ( ctx, cancel = context.WithCancel(context.Background()) key = tm.getStoreKey(txnID.String(), nodeID.String(), TxnStatusPrefix) - clusterLock = oldtransaction.Locks{} + clusterLock = Locks{} ) defer cancel() From f406a1cf8bac60f9856fd9b590272b443405d62a Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 14:00:52 +0530 Subject: [PATCH 4/7] Remove references to oldtransaction in glusterd2/commands --- .../commands/options/setclusteroptions.go | 4 +-- glusterd2/commands/peers/editpeer.go | 12 ++++---- glusterd2/commands/snapshot/common.go | 8 ++--- .../commands/snapshot/snapshot-activate.go | 18 +++++------ glusterd2/commands/snapshot/snapshot-clone.go | 22 +++++++------- .../commands/snapshot/snapshot-create.go | 28 ++++++++--------- .../commands/snapshot/snapshot-deactivate.go | 18 +++++------ .../commands/snapshot/snapshot-delete.go | 14 ++++----- .../commands/snapshot/snapshot-restore.go | 20 ++++++------- .../commands/snapshot/snapshot-status.go | 12 ++++---- .../commands/volumes/brick-replace-txn.go | 8 ++--- glusterd2/commands/volumes/brick-replace.go | 10 +++---- glusterd2/commands/volumes/bricks-status.go | 12 ++++---- glusterd2/commands/volumes/common.go | 20 ++++++------- .../commands/volumes/volume-create-txn.go | 6 ++-- glusterd2/commands/volumes/volume-create.go | 11 ++++--- glusterd2/commands/volumes/volume-delete.go | 13 ++++---- glusterd2/commands/volumes/volume-edit.go | 4 +-- .../commands/volumes/volume-expand-txn.go | 12 ++++---- glusterd2/commands/volumes/volume-expand.go | 10 +++---- glusterd2/commands/volumes/volume-option.go | 30 +++++++++---------- glusterd2/commands/volumes/volume-profile.go | 10 +++---- glusterd2/commands/volumes/volume-reset.go | 10 +++---- .../commands/volumes/volume-smartvol-txn.go | 16 +++++----- glusterd2/commands/volumes/volume-start.go | 15 +++++----- .../commands/volumes/volume-statedump.go | 10 +++---- glusterd2/commands/volumes/volume-stop.go | 13 ++++---- 27 files changed, 181 insertions(+), 185 deletions(-) diff --git a/glusterd2/commands/options/setclusteroptions.go b/glusterd2/commands/options/setclusteroptions.go index 41ba0ca5b..cb2772478 100644 --- a/glusterd2/commands/options/setclusteroptions.go +++ b/glusterd2/commands/options/setclusteroptions.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/options" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" ) @@ -24,7 +24,7 @@ func setClusterOptionsHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, lockKey) + txn, err := transaction.NewTxnWithLocks(ctx, lockKey) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) diff --git a/glusterd2/commands/peers/editpeer.go b/glusterd2/commands/peers/editpeer.go index 0af7ee669..56a9d9855 100644 --- a/glusterd2/commands/peers/editpeer.go +++ b/glusterd2/commands/peers/editpeer.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -41,7 +41,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) { } } - txn, err := oldtransaction.NewTxnWithLocks(ctx, peerID) + txn, err := transaction.NewTxnWithLocks(ctx, peerID) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -49,7 +49,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) { } defer txn.Done() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "peer-edit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -85,7 +85,7 @@ func editPeer(w http.ResponseWriter, r *http.Request) { } -func txnPeerEdit(c oldtransaction.TxnCtx) error { +func txnPeerEdit(c transaction.TxnCtx) error { var peerID string if err := c.Get("peerid", &peerID); err != nil { c.Logger().WithError(err).WithField("key", "peerID").Error("Failed to get key from transaction context") @@ -134,12 +134,12 @@ func txnPeerEdit(c oldtransaction.TxnCtx) error { func registerPeerEditStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"peer-edit", txnPeerEdit}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } diff --git a/glusterd2/commands/snapshot/common.go b/glusterd2/commands/snapshot/common.go index 800badcc2..d73fd5805 100644 --- a/glusterd2/commands/snapshot/common.go +++ b/glusterd2/commands/snapshot/common.go @@ -1,22 +1,22 @@ package snapshotcommands import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" ) // undoStoreSnapshot revert back snapinfo and to generate client volfile -func undoStoreSnapshot(c oldtransaction.TxnCtx) error { +func undoStoreSnapshot(c transaction.TxnCtx) error { return storeSnapinfo(c, "oldsnapinfo") } // StoreSnapahot uses to store the snapinfo and to generate client volfile -func storeSnapshot(c oldtransaction.TxnCtx) error { +func storeSnapshot(c transaction.TxnCtx) error { return storeSnapinfo(c, "snapinfo") } // storeSnapInfo uses to store the snapinfo based on key and to generate client volfile -func storeSnapinfo(c oldtransaction.TxnCtx, key string) error { +func storeSnapinfo(c transaction.TxnCtx, key string) error { var snapinfo snapshot.Snapinfo if err := c.Get(key, &snapinfo); err != nil { diff --git a/glusterd2/commands/snapshot/snapshot-activate.go b/glusterd2/commands/snapshot/snapshot-activate.go index f2bc71205..6ccce5bd5 100644 --- a/glusterd2/commands/snapshot/snapshot-activate.go +++ b/glusterd2/commands/snapshot/snapshot-activate.go @@ -7,9 +7,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -19,7 +19,7 @@ import ( log "github.com/sirupsen/logrus" ) -func activateSnapshot(c oldtransaction.TxnCtx) error { +func activateSnapshot(c transaction.TxnCtx) error { var snapinfo snapshot.Snapinfo activate := true @@ -53,7 +53,7 @@ func activateSnapshot(c oldtransaction.TxnCtx) error { return err } -func rollbackActivateSnapshot(c oldtransaction.TxnCtx) error { +func rollbackActivateSnapshot(c transaction.TxnCtx) error { activate := false var snapinfo snapshot.Snapinfo var brickinfos []brick.Brickinfo @@ -85,10 +85,10 @@ func rollbackActivateSnapshot(c oldtransaction.TxnCtx) error { } func registerSnapActivateStepFuncs() { - oldtransaction.RegisterStepFunc(activateSnapshot, "snap-activate.Commit") - oldtransaction.RegisterStepFunc(rollbackActivateSnapshot, "snap-activate.Undo") - oldtransaction.RegisterStepFunc(storeSnapshot, "snap-activate.StoreSnapshot") - oldtransaction.RegisterStepFunc(undoStoreSnapshot, "snap-activate.UndoStoreSnapshot") + transaction.RegisterStepFunc(activateSnapshot, "snap-activate.Commit") + transaction.RegisterStepFunc(rollbackActivateSnapshot, "snap-activate.Undo") + transaction.RegisterStepFunc(storeSnapshot, "snap-activate.StoreSnapshot") + transaction.RegisterStepFunc(undoStoreSnapshot, "snap-activate.UndoStoreSnapshot") } @@ -99,7 +99,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) { snapname := mux.Vars(r)["snapname"] - txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname) + txn, err := transaction.NewTxnWithLocks(ctx, snapname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -142,7 +142,7 @@ func snapshotActivateHandler(w http.ResponseWriter, r *http.Request) { //Populating Nodes neeed not be under lock, because snapshot is a read only config txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-activate.Commit", UndoFunc: "snap-activate.Undo", diff --git a/glusterd2/commands/snapshot/snapshot-clone.go b/glusterd2/commands/snapshot/snapshot-clone.go index acc8c0f9c..9b9719567 100644 --- a/glusterd2/commands/snapshot/snapshot-clone.go +++ b/glusterd2/commands/snapshot/snapshot-clone.go @@ -6,9 +6,9 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -20,7 +20,7 @@ import ( config "github.com/spf13/viper" ) -func undoSnapshotClone(c oldtransaction.TxnCtx) error { +func undoSnapshotClone(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -38,7 +38,7 @@ func undoSnapshotClone(c oldtransaction.TxnCtx) error { return nil } -func undoStoreSnapshotClone(c oldtransaction.TxnCtx) error { +func undoStoreSnapshotClone(c transaction.TxnCtx) error { var ( vol volume.Volinfo err error @@ -52,7 +52,7 @@ func undoStoreSnapshotClone(c oldtransaction.TxnCtx) error { return err } -func storeSnapshotClone(c oldtransaction.TxnCtx) error { +func storeSnapshotClone(c transaction.TxnCtx) error { var vol volume.Volinfo if err := c.Get("volinfo", &vol); err != nil { return err @@ -65,7 +65,7 @@ func storeSnapshotClone(c oldtransaction.TxnCtx) error { return nil } -func takeSnapshotClone(c oldtransaction.TxnCtx) error { +func takeSnapshotClone(c transaction.TxnCtx) error { var snapname string var newVol volume.Volinfo @@ -135,7 +135,7 @@ func populateCloneBrickMountData(volinfo *volume.Volinfo, name string) (map[stri return nodeData, nil } -func validateSnapClone(c oldtransaction.TxnCtx) error { +func validateSnapClone(c transaction.TxnCtx) error { var ( statusStr []string err error @@ -190,7 +190,7 @@ func validateSnapClone(c oldtransaction.TxnCtx) error { return nil } -func createCloneVolinfo(c oldtransaction.TxnCtx) error { +func createCloneVolinfo(c transaction.TxnCtx) error { var clonename, snapname string nodeData := make(map[string]snapshot.BrickMountData) @@ -253,7 +253,7 @@ func snapshotCloneBrickCreate(cloneName, brickDirSuffix string, subvolNumber, br func registerSnapCloneStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"snap-clone.Validate", validateSnapClone}, {"snap-clone.CreateCloneVolinfo", createCloneVolinfo}, @@ -263,7 +263,7 @@ func registerSnapCloneStepFuncs() { {"snap-clone.UndoStoreSnapshotOnClone", undoStoreSnapshotClone}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -288,7 +288,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, req.CloneName, snapname) + txn, err := transaction.NewTxnWithLocks(ctx, req.CloneName, snapname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -316,7 +316,7 @@ func snapshotCloneHandler(w http.ResponseWriter, r *http.Request) { return } txn.Nodes = snapVol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-clone.Validate", Nodes: txn.Nodes, diff --git a/glusterd2/commands/snapshot/snapshot-create.go b/glusterd2/commands/snapshot/snapshot-create.go index 8fbba00cb..4c69b5fbd 100644 --- a/glusterd2/commands/snapshot/snapshot-create.go +++ b/glusterd2/commands/snapshot/snapshot-create.go @@ -21,10 +21,10 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" @@ -102,7 +102,7 @@ func barrierActivateDeactivateFunc(volinfo *volume.Volinfo, option string, origi } return nil } -func deactivateBarrier(c oldtransaction.TxnCtx) error { +func deactivateBarrier(c transaction.TxnCtx) error { var barrierOp string var snapInfo snapshot.Snapinfo if err := c.Get("barrier-enabled", &barrierOp); err != nil { @@ -136,7 +136,7 @@ func deactivateBarrier(c oldtransaction.TxnCtx) error { } -func activateBarrier(c oldtransaction.TxnCtx) error { +func activateBarrier(c transaction.TxnCtx) error { var barrierOp string var snapInfo snapshot.Snapinfo if err := c.Get("barrier-enabled", &barrierOp); err != nil { @@ -171,7 +171,7 @@ func activateBarrier(c oldtransaction.TxnCtx) error { return err } -func undoBrickSnapshots(c oldtransaction.TxnCtx) error { +func undoBrickSnapshots(c transaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -189,7 +189,7 @@ func undoBrickSnapshots(c oldtransaction.TxnCtx) error { return nil } -func undoStoreSnapshotOnCreate(c oldtransaction.TxnCtx) error { +func undoStoreSnapshotOnCreate(c transaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -208,7 +208,7 @@ func undoStoreSnapshotOnCreate(c oldtransaction.TxnCtx) error { } // storeSnapshot uses to store the volinfo and to generate client volfile -func storeSnapshotCreate(c oldtransaction.TxnCtx) error { +func storeSnapshotCreate(c transaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -316,7 +316,7 @@ func populateSnapBrickMountData(volinfo *volume.Volinfo, snapName string) (map[s return nodeData, nil } -func validateSnapCreate(c oldtransaction.TxnCtx) error { +func validateSnapCreate(c transaction.TxnCtx) error { var ( statusStr []string err error @@ -455,7 +455,7 @@ func brickSnapshot(errCh chan error, wg *sync.WaitGroup, snapBrick, b brick.Bric return } -func takeSnapshots(c oldtransaction.TxnCtx) error { +func takeSnapshots(c transaction.TxnCtx) error { var snapInfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapInfo); err != nil { @@ -517,7 +517,7 @@ func createSnapSubvols(newVolinfo, origVolinfo *volume.Volinfo, nodeData map[str return nil } -func createSnapinfo(c oldtransaction.TxnCtx) error { +func createSnapinfo(c transaction.TxnCtx) error { var data txnData ignoreOps := map[string]string{ "features/quota": "off", @@ -646,7 +646,7 @@ func snapshotBrickCreate(snapName, volName, brickDirSuffix string, subvolNumber, return brickPath } -func validateOriginNodeSnapCreate(c oldtransaction.TxnCtx) error { +func validateOriginNodeSnapCreate(c transaction.TxnCtx) error { var data txnData if err := c.Get("data", &data); err != nil { @@ -690,7 +690,7 @@ func validateOriginNodeSnapCreate(c oldtransaction.TxnCtx) error { func registerSnapCreateStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"snap-create.Validate", validateSnapCreate}, {"snap-create.CreateSnapinfo", createSnapinfo}, @@ -702,7 +702,7 @@ func registerSnapCreateStepFuncs() { {"snap-create.UndoStoreSnapshotOnCreate", undoStoreSnapshotOnCreate}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -732,7 +732,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, req.VolName, req.SnapName) + txn, err := transaction.NewTxnWithLocks(ctx, req.VolName, req.SnapName) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -763,7 +763,7 @@ func snapshotCreateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-create.Validate", Nodes: txn.Nodes, diff --git a/glusterd2/commands/snapshot/snapshot-deactivate.go b/glusterd2/commands/snapshot/snapshot-deactivate.go index 1cb68738f..5fa9095f9 100644 --- a/glusterd2/commands/snapshot/snapshot-deactivate.go +++ b/glusterd2/commands/snapshot/snapshot-deactivate.go @@ -5,9 +5,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -18,7 +18,7 @@ import ( log "github.com/sirupsen/logrus" ) -func deactivateSnapshot(c oldtransaction.TxnCtx) error { +func deactivateSnapshot(c transaction.TxnCtx) error { var snapinfo snapshot.Snapinfo if err := c.Get("oldsnapinfo", &snapinfo); err != nil { @@ -71,7 +71,7 @@ func deactivateSnapshot(c oldtransaction.TxnCtx) error { } -func rollbackDeactivateSnapshot(c oldtransaction.TxnCtx) error { +func rollbackDeactivateSnapshot(c transaction.TxnCtx) error { activate := true var snapinfo snapshot.Snapinfo var brickinfos []brick.Brickinfo @@ -102,10 +102,10 @@ func rollbackDeactivateSnapshot(c oldtransaction.TxnCtx) error { } func registerSnapDeactivateStepFuncs() { - oldtransaction.RegisterStepFunc(deactivateSnapshot, "snap-deactivate.Commit") - oldtransaction.RegisterStepFunc(rollbackDeactivateSnapshot, "snap-deactivate.Undo") - oldtransaction.RegisterStepFunc(storeSnapshot, "snap-deactivate.StoreSnapshot") - oldtransaction.RegisterStepFunc(undoStoreSnapshot, "snap-deactivate.UndoStoreSnapshot") + transaction.RegisterStepFunc(deactivateSnapshot, "snap-deactivate.Commit") + transaction.RegisterStepFunc(rollbackDeactivateSnapshot, "snap-deactivate.Undo") + transaction.RegisterStepFunc(storeSnapshot, "snap-deactivate.StoreSnapshot") + transaction.RegisterStepFunc(undoStoreSnapshot, "snap-deactivate.UndoStoreSnapshot") } @@ -116,7 +116,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) { snapname := mux.Vars(r)["snapname"] - txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname) + txn, err := transaction.NewTxnWithLocks(ctx, snapname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -138,7 +138,7 @@ func snapshotDeactivateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-deactivate.Commit", UndoFunc: "snap-deactivate.Undo", diff --git a/glusterd2/commands/snapshot/snapshot-delete.go b/glusterd2/commands/snapshot/snapshot-delete.go index d4c0593ae..dbca0ab36 100644 --- a/glusterd2/commands/snapshot/snapshot-delete.go +++ b/glusterd2/commands/snapshot/snapshot-delete.go @@ -8,9 +8,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/lvmutils" @@ -49,7 +49,7 @@ func snapshotBrickDelete(errCh chan error, wg *sync.WaitGroup, snapVol volume.Vo return } -func snapshotDelete(c oldtransaction.TxnCtx) error { +func snapshotDelete(c transaction.TxnCtx) error { var snapinfo snapshot.Snapinfo if err := c.Get("snapinfo", &snapinfo); err != nil { return err @@ -81,7 +81,7 @@ func snapshotDelete(c oldtransaction.TxnCtx) error { return err } -func snapshotDeleteStore(c oldtransaction.TxnCtx) error { +func snapshotDeleteStore(c transaction.TxnCtx) error { var ( snapinfo snapshot.Snapinfo @@ -105,7 +105,7 @@ snapshot if something fails. func registerSnapDeleteStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"snap-delete.Commit", snapshotDelete}, {"snap-delete.Store", snapshotDeleteStore}, @@ -116,7 +116,7 @@ func registerSnapDeleteStepFuncs() { */ } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -136,7 +136,7 @@ func snapshotDeleteHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) + txn, err := transaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -153,7 +153,7 @@ func snapshotDeleteHandler(w http.ResponseWriter, r *http.Request) { } volinfo := &snapinfo.SnapVolinfo - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-delete.Commit", Nodes: volinfo.Nodes(), diff --git a/glusterd2/commands/snapshot/snapshot-restore.go b/glusterd2/commands/snapshot/snapshot-restore.go index b255ff46e..fd4dc5573 100644 --- a/glusterd2/commands/snapshot/snapshot-restore.go +++ b/glusterd2/commands/snapshot/snapshot-restore.go @@ -7,9 +7,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" @@ -22,7 +22,7 @@ import ( const volumeIDXattrKey = "trusted.glusterfs.volume-id" -func snapRestore(c oldtransaction.TxnCtx) error { +func snapRestore(c transaction.TxnCtx) error { var snapname string if err := c.Get("snapname", &snapname); err != nil { return err @@ -91,7 +91,7 @@ func remountBrick(b brick.Brickinfo, volinfo *volume.Volinfo, mtab []*volume.Mnt } -func undoSnapStore(c oldtransaction.TxnCtx) error { +func undoSnapStore(c transaction.TxnCtx) error { var snapInfo snapshot.Snapinfo var volinfo volume.Volinfo @@ -126,7 +126,7 @@ func undoSnapStore(c oldtransaction.TxnCtx) error { return nil } -func undoSnapRestore(c oldtransaction.TxnCtx) error { +func undoSnapRestore(c transaction.TxnCtx) error { var snapname string if err := c.Get("snapname", &snapname); err != nil { return err @@ -242,7 +242,7 @@ func createRestoreVolinfo(snapinfo *snapshot.Snapinfo, vol *volume.Volinfo) volu return newVol } -func storeSnapRestore(c oldtransaction.TxnCtx) error { +func storeSnapRestore(c transaction.TxnCtx) error { var snapname string if err := c.Get("snapname", &snapname); err != nil { return err @@ -287,7 +287,7 @@ func storeSnapRestore(c oldtransaction.TxnCtx) error { return nil } -func cleanParentBricks(c oldtransaction.TxnCtx) error { +func cleanParentBricks(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -301,7 +301,7 @@ func cleanParentBricks(c oldtransaction.TxnCtx) error { func registerSnapRestoreStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"snap-restore.Commit", snapRestore}, {"snap-restore.UndoCommit", undoSnapRestore}, @@ -310,7 +310,7 @@ func registerSnapRestoreStepFuncs() { {"snap-restore.CleanBricks", cleanParentBricks}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -326,7 +326,7 @@ func snapshotRestoreHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) + txn, err := transaction.NewTxnWithLocks(ctx, snapname, snapinfo.ParentVolume) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -356,7 +356,7 @@ func snapshotRestoreHandler(w http.ResponseWriter, r *http.Request) { } bricksAutoProvisioned := vol.IsAutoProvisioned() || vol.IsSnapshotProvisioned() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-restore.Commit", UndoFunc: "snap-restore.UndoCommit", diff --git a/glusterd2/commands/snapshot/snapshot-status.go b/glusterd2/commands/snapshot/snapshot-status.go index fcaf6a661..6fcf0d1ef 100644 --- a/glusterd2/commands/snapshot/snapshot-status.go +++ b/glusterd2/commands/snapshot/snapshot-status.go @@ -5,9 +5,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/snapshot" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" @@ -48,7 +48,7 @@ func createSnapshotStatusResp(brickStatuses []brick.Brickstatus) []*api.SnapBric } -func snapshotStatus(ctx oldtransaction.TxnCtx) error { +func snapshotStatus(ctx transaction.TxnCtx) error { var snapname string if err := ctx.Get("snapname", &snapname); err != nil { ctx.Logger().WithError(err).Error("Failed to get key from transaction context.") @@ -77,7 +77,7 @@ func snapshotStatus(ctx oldtransaction.TxnCtx) error { } func registerSnapshotStatusStepFuncs() { - oldtransaction.RegisterStepFunc(snapshotStatus, "snap-status.Check") + transaction.RegisterStepFunc(snapshotStatus, "snap-status.Check") } func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPError(ctx, w, http.StatusBadRequest, errors.ErrSnapNotActivated) return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, vol.Name) + txn, err := transaction.NewTxnWithLocks(ctx, vol.Name) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -106,7 +106,7 @@ func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { } defer txn.Done() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "snap-status.Check", Nodes: vol.Nodes(), @@ -128,7 +128,7 @@ func snapshotStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, resp) } -func createSnapshotStatusesResp(ctx oldtransaction.TxnCtx, snap *snapshot.Snapinfo) *api.SnapStatusResp { +func createSnapshotStatusesResp(ctx transaction.TxnCtx, snap *snapshot.Snapinfo) *api.SnapStatusResp { // bmap is a map of brick statuses keyed by brick ID diff --git a/glusterd2/commands/volumes/brick-replace-txn.go b/glusterd2/commands/volumes/brick-replace-txn.go index 6757eefbc..3d194a0d9 100644 --- a/glusterd2/commands/volumes/brick-replace-txn.go +++ b/glusterd2/commands/volumes/brick-replace-txn.go @@ -2,12 +2,12 @@ package volumecommands import ( "github.com/gluster/glusterd2/glusterd2/brick" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" ) -func prepareBricks(c oldtransaction.TxnCtx) error { +func prepareBricks(c transaction.TxnCtx) error { var volInfo volume.Volinfo if err := c.Get("volinfo", &volInfo); err != nil { return err @@ -22,7 +22,7 @@ func prepareBricks(c oldtransaction.TxnCtx) error { return PrepareBrickLvm(req, c) } -func replaceVolinfo(c oldtransaction.TxnCtx) error { +func replaceVolinfo(c transaction.TxnCtx) error { var newBrick api.BrickReq var err error if err = c.Get("newBrick", &newBrick); err != nil { @@ -93,7 +93,7 @@ func replaceVolinfo(c oldtransaction.TxnCtx) error { return err } -func startBrick(c oldtransaction.TxnCtx) error { +func startBrick(c transaction.TxnCtx) error { var newBrickInfo []brick.Brickinfo if err := c.Get("bricks", newBrickInfo); err != nil { diff --git a/glusterd2/commands/volumes/brick-replace.go b/glusterd2/commands/volumes/brick-replace.go index 3429467cb..507bf33fe 100644 --- a/glusterd2/commands/volumes/brick-replace.go +++ b/glusterd2/commands/volumes/brick-replace.go @@ -6,9 +6,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/bricksplanner" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -20,14 +20,14 @@ import ( func registerReplaceBrickStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"brick-replace.PrepareBricks", prepareBricks}, {"brick-replace.ReplaceVolinfo", replaceVolinfo}, {"brick-replace.StartBrick", startBrick}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -146,7 +146,7 @@ LOOP: } allPeerIDs := vol.Nodes() nodes := []uuid.UUID{peerID} - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -154,7 +154,7 @@ LOOP: } defer txn.Done() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "brick-replace.PrepareBricks", Nodes: nodes, diff --git a/glusterd2/commands/volumes/bricks-status.go b/glusterd2/commands/volumes/bricks-status.go index 6c987b0a1..0bf20a9b4 100644 --- a/glusterd2/commands/volumes/bricks-status.go +++ b/glusterd2/commands/volumes/bricks-status.go @@ -5,8 +5,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gorilla/mux" @@ -17,10 +17,10 @@ const ( ) func registerBricksStatusStepFuncs() { - oldtransaction.RegisterStepFunc(bricksStatus, "bricks-status.Check") + transaction.RegisterStepFunc(bricksStatus, "bricks-status.Check") } -func bricksStatus(ctx oldtransaction.TxnCtx) error { +func bricksStatus(ctx transaction.TxnCtx) error { var volname string if err := ctx.Get("volname", &volname); err != nil { ctx.Logger().WithError(err).Error("Failed to get key from transaction context.") @@ -57,9 +57,9 @@ func volumeBricksStatusHandler(w http.ResponseWriter, r *http.Request) { return } - txn := oldtransaction.NewTxn(ctx) + txn := transaction.NewTxn(ctx) defer txn.Done() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "bricks-status.Check", Nodes: vol.Nodes(), @@ -89,7 +89,7 @@ func volumeBricksStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, result) } -func createBricksStatusResp(ctx oldtransaction.TxnCtx, vol *volume.Volinfo) (*api.BricksStatusResp, error) { +func createBricksStatusResp(ctx transaction.TxnCtx, vol *volume.Volinfo) (*api.BricksStatusResp, error) { // bmap is a map of brick statuses keyed by brick ID bmap := make(map[string]api.BrickStatus) diff --git a/glusterd2/commands/volumes/common.go b/glusterd2/commands/volumes/common.go index fe6977b6b..bf2eafca1 100644 --- a/glusterd2/commands/volumes/common.go +++ b/glusterd2/commands/volumes/common.go @@ -13,10 +13,10 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/options" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc" "github.com/gluster/glusterd2/glusterd2/store" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" @@ -169,7 +169,7 @@ func expandGroupOptionsReset(reqOpts []string) ([]string, error) { return options, nil } -func notifyVolfileChange(c oldtransaction.TxnCtx) error { +func notifyVolfileChange(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -186,7 +186,7 @@ func notifyVolfileChange(c oldtransaction.TxnCtx) error { } // This txn step is used in volume create and in volume expand -func validateBricks(c oldtransaction.TxnCtx) error { +func validateBricks(c transaction.TxnCtx) error { var err error @@ -228,7 +228,7 @@ func validateBricks(c oldtransaction.TxnCtx) error { } // This txn step is used in volume create, replace brick and in volume expand -func initBricks(c oldtransaction.TxnCtx) error { +func initBricks(c transaction.TxnCtx) error { var err error @@ -274,7 +274,7 @@ func initBricks(c oldtransaction.TxnCtx) error { } // This txn step is used in volume create and in volume expand -func undoInitBricks(c oldtransaction.TxnCtx) error { +func undoInitBricks(c transaction.TxnCtx) error { var bricks []brick.Brickinfo if err := c.Get("bricks", &bricks); err != nil { @@ -296,12 +296,12 @@ func undoInitBricks(c oldtransaction.TxnCtx) error { } // StoreVolume uses to store the volinfo and to generate client volfile -func storeVolume(c oldtransaction.TxnCtx) error { +func storeVolume(c transaction.TxnCtx) error { return storeVolInfo(c, "volinfo") } // storeVolInfo uses to store the volinfo based on key and to generate client volfile -func storeVolInfo(c oldtransaction.TxnCtx, key string) error { +func storeVolInfo(c transaction.TxnCtx, key string) error { var volinfo volume.Volinfo if err := c.Get(key, &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -319,7 +319,7 @@ func storeVolInfo(c oldtransaction.TxnCtx, key string) error { } // undoStoreVolume revert back volinfo and to generate client volfile -func undoStoreVolume(c oldtransaction.TxnCtx) error { +func undoStoreVolume(c transaction.TxnCtx) error { return storeVolInfo(c, "oldvolinfo") } @@ -401,7 +401,7 @@ func isActionStepRequired(opt map[string]string, volinfo *volume.Volinfo) bool { return false } -func txnDeleteBrickVolfiles(c oldtransaction.TxnCtx) error { +func txnDeleteBrickVolfiles(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -420,7 +420,7 @@ func txnDeleteBrickVolfiles(c oldtransaction.TxnCtx) error { return nil } -func txnGenerateBrickVolfiles(c oldtransaction.TxnCtx) error { +func txnGenerateBrickVolfiles(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { return err diff --git a/glusterd2/commands/volumes/volume-create-txn.go b/glusterd2/commands/volumes/volume-create-txn.go index 6c25015f3..5dd325a20 100644 --- a/glusterd2/commands/volumes/volume-create-txn.go +++ b/glusterd2/commands/volumes/volume-create-txn.go @@ -6,14 +6,14 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/brick" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/pborman/uuid" ) -func undoStoreVolumeOnCreate(c oldtransaction.TxnCtx) error { +func undoStoreVolumeOnCreate(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -178,7 +178,7 @@ func newVolinfo(req *api.VolCreateReq) (*volume.Volinfo, error) { return volinfo, nil } -func createVolinfo(c oldtransaction.TxnCtx) error { +func createVolinfo(c transaction.TxnCtx) error { var req api.VolCreateReq if err := c.Get("req", &req); err != nil { diff --git a/glusterd2/commands/volumes/volume-create.go b/glusterd2/commands/volumes/volume-create.go index da0f9d351..5f51c7a95 100644 --- a/glusterd2/commands/volumes/volume-create.go +++ b/glusterd2/commands/volumes/volume-create.go @@ -10,9 +10,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/bricksplanner" "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -84,7 +83,7 @@ func checkDupBrickEntryVolCreate(req api.VolCreateReq) error { func registerVolCreateStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"vol-create.CreateVolinfo", createVolinfo}, {"vol-create.ValidateBricks", validateBricks}, @@ -96,7 +95,7 @@ func registerVolCreateStepFuncs() { {"vol-create.UndoPrepareBricks", txnUndoPrepareBricks}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -199,7 +198,7 @@ func CreateVolume(ctx context.Context, req api.VolCreateReq) (status int, err er return http.StatusBadRequest, err } - txn, err := transactionv2.NewTxnWithLocks(ctx, req.Name) + txn, err := transaction.NewTxnWithLocks(ctx, req.Name) if err != nil { return restutils.ErrToStatusCode(err) } @@ -209,7 +208,7 @@ func CreateVolume(ctx context.Context, req api.VolCreateReq) (status int, err er return http.StatusBadRequest, gderrors.ErrVolExists } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-create.PrepareBricks", UndoFunc: "vol-create.UndoPrepareBricks", diff --git a/glusterd2/commands/volumes/volume-delete.go b/glusterd2/commands/volumes/volume-delete.go index 46314b8ec..ad62a820e 100644 --- a/glusterd2/commands/volumes/volume-delete.go +++ b/glusterd2/commands/volumes/volume-delete.go @@ -6,9 +6,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gorilla/mux" @@ -17,7 +16,7 @@ import ( "go.opencensus.io/trace" ) -func deleteVolume(c oldtransaction.TxnCtx) error { +func deleteVolume(c transaction.TxnCtx) error { var ( volinfo volume.Volinfo @@ -32,8 +31,8 @@ func deleteVolume(c oldtransaction.TxnCtx) error { } func registerVolDeleteStepFuncs() { - oldtransaction.RegisterStepFunc(deleteVolume, "vol-delete.Store") - oldtransaction.RegisterStepFunc(txnCleanBricks, "vol-delete.CleanBricks") + transaction.RegisterStepFunc(deleteVolume, "vol-delete.Store") + transaction.RegisterStepFunc(txnCleanBricks, "vol-delete.CleanBricks") } func volumeDeleteHandler(w http.ResponseWriter, r *http.Request) { @@ -45,7 +44,7 @@ func volumeDeleteHandler(w http.ResponseWriter, r *http.Request) { ctx, span := trace.StartSpan(ctx, "/volumeDeleteHandler") defer span.End() - txn, err := transactionv2.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -73,7 +72,7 @@ func volumeDeleteHandler(w http.ResponseWriter, r *http.Request) { } bricksAutoProvisioned := volinfo.IsAutoProvisioned() || volinfo.IsSnapshotProvisioned() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-delete.CleanBricks", Nodes: volinfo.Nodes(), diff --git a/glusterd2/commands/volumes/volume-edit.go b/glusterd2/commands/volumes/volume-edit.go index 51403fd31..4a3c7a415 100644 --- a/glusterd2/commands/volumes/volume-edit.go +++ b/glusterd2/commands/volumes/volume-edit.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" @@ -29,7 +29,7 @@ func volumeEditHandler(w http.ResponseWriter, r *http.Request) { } //Lock on Volume Name - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) diff --git a/glusterd2/commands/volumes/volume-expand-txn.go b/glusterd2/commands/volumes/volume-expand-txn.go index 700cbed0d..e024da377 100644 --- a/glusterd2/commands/volumes/volume-expand-txn.go +++ b/glusterd2/commands/volumes/volume-expand-txn.go @@ -9,7 +9,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/brickmux" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/lvmutils" @@ -19,7 +19,7 @@ import ( log "github.com/sirupsen/logrus" ) -func expandValidatePrepare(c oldtransaction.TxnCtx) error { +func expandValidatePrepare(c transaction.TxnCtx) error { var req api.VolExpandReq if err := c.Get("req", &req); err != nil { @@ -97,7 +97,7 @@ func expandValidatePrepare(c oldtransaction.TxnCtx) error { return err } -func startBricksOnExpand(c oldtransaction.TxnCtx) error { +func startBricksOnExpand(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -163,7 +163,7 @@ func startBricksOnExpand(c oldtransaction.TxnCtx) error { return nil } -func undoStartBricksOnExpand(c oldtransaction.TxnCtx) error { +func undoStartBricksOnExpand(c transaction.TxnCtx) error { var newBricks []brick.Brickinfo if err := c.Get("bricks", &newBricks); err != nil { @@ -196,7 +196,7 @@ func undoStartBricksOnExpand(c oldtransaction.TxnCtx) error { return nil } -func updateVolinfoOnExpand(c oldtransaction.TxnCtx) error { +func updateVolinfoOnExpand(c transaction.TxnCtx) error { var newBricks []brick.Brickinfo if err := c.Get("bricks", &newBricks); err != nil { @@ -294,7 +294,7 @@ func updateVolinfoOnExpand(c oldtransaction.TxnCtx) error { return nil } -func resizeLVM(c oldtransaction.TxnCtx) error { +func resizeLVM(c transaction.TxnCtx) error { var req api.VolExpandReq if err := c.Get("req", &req); err != nil { return err diff --git a/glusterd2/commands/volumes/volume-expand.go b/glusterd2/commands/volumes/volume-expand.go index ce56f685c..b638ca7f7 100644 --- a/glusterd2/commands/volumes/volume-expand.go +++ b/glusterd2/commands/volumes/volume-expand.go @@ -6,9 +6,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" @@ -23,7 +23,7 @@ import ( func registerVolExpandStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"vol-expand.ValidateAndPrepare", expandValidatePrepare}, {"vol-expand.ValidateBricks", validateBricks}, @@ -38,7 +38,7 @@ func registerVolExpandStepFuncs() { {"vol-expand.LvmResize", resizeLVM}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -84,7 +84,7 @@ func volumeExpandHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -163,7 +163,7 @@ func volumeExpandHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = allNodes - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ // TODO: This is a lot of steps. We can combine a few if we // do not re-use the same step functions across multiple // volume operations. diff --git a/glusterd2/commands/volumes/volume-option.go b/glusterd2/commands/volumes/volume-option.go index 851369783..3dc4b8fff 100644 --- a/glusterd2/commands/volumes/volume-option.go +++ b/glusterd2/commands/volumes/volume-option.go @@ -5,10 +5,10 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/options" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" "github.com/gluster/glusterd2/pkg/api" @@ -20,7 +20,7 @@ import ( "go.opencensus.io/trace" ) -func optionSetValidate(c oldtransaction.TxnCtx) error { +func optionSetValidate(c transaction.TxnCtx) error { var req api.VolOptionReq if err := c.Get("req", &req); err != nil { @@ -69,42 +69,42 @@ const ( txnUndo ) -func xlatorActionDoSet(c oldtransaction.TxnCtx) error { +func xlatorActionDoSet(c transaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeSet) } -func xlatorActionUndoSet(c oldtransaction.TxnCtx) error { +func xlatorActionUndoSet(c transaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeSet) } -func xlatorActionDoReset(c oldtransaction.TxnCtx) error { +func xlatorActionDoReset(c transaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeReset) } -func xlatorActionUndoReset(c oldtransaction.TxnCtx) error { +func xlatorActionUndoReset(c transaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeReset) } -func xlatorActionDoVolumeStart(c oldtransaction.TxnCtx) error { +func xlatorActionDoVolumeStart(c transaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeStart) } -func xlatorActionUndoVolumeStart(c oldtransaction.TxnCtx) error { +func xlatorActionUndoVolumeStart(c transaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeStart) } -func xlatorActionDoVolumeStop(c oldtransaction.TxnCtx) error { +func xlatorActionDoVolumeStop(c transaction.TxnCtx) error { return xlatorAction(c, txnDo, xlator.VolumeStop) } -func xlatorActionUndoVolumeStop(c oldtransaction.TxnCtx) error { +func xlatorActionUndoVolumeStop(c transaction.TxnCtx) error { return xlatorAction(c, txnUndo, xlator.VolumeStop) } // This function can be reused when volume reset operation is implemented. // However, volume reset can be also be treated logically as volume set but // with the value set to default value. -func xlatorAction(c oldtransaction.TxnCtx, txnOp txnOpType, volOp xlator.VolumeOpType) error { +func xlatorAction(c transaction.TxnCtx, txnOp txnOpType, volOp xlator.VolumeOpType) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -176,7 +176,7 @@ func xlatorAction(c oldtransaction.TxnCtx, txnOp txnOpType, volOp xlator.VolumeO func registerVolOptionStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"vol-option.Validate", optionSetValidate}, {"vol-option.XlatorActionDoSet", xlatorActionDoSet}, @@ -188,7 +188,7 @@ func registerVolOptionStepFuncs() { {"vol-option.GenerateBrickvolfiles.Undo", txnDeleteBrickVolfiles}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -211,7 +211,7 @@ func volumeOptionsHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -237,7 +237,7 @@ func volumeOptionsHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-option.Validate", Nodes: []uuid.UUID{gdctx.MyUUID}, diff --git a/glusterd2/commands/volumes/volume-profile.go b/glusterd2/commands/volumes/volume-profile.go index ece959ec3..dd2a3bf81 100644 --- a/glusterd2/commands/volumes/volume-profile.go +++ b/glusterd2/commands/volumes/volume-profile.go @@ -10,9 +10,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gorilla/mux" @@ -26,7 +26,7 @@ const ( ) func registerVolProfileStepFuncs() { - oldtransaction.RegisterStepFunc(txnVolumeProfile, "volume.Profile") + transaction.RegisterStepFunc(txnVolumeProfile, "volume.Profile") } func volumeProfileHandler(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func volumeProfileHandler(w http.ResponseWriter, r *http.Request) { volname := mux.Vars(r)["volname"] option := mux.Vars(r)["option"] - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -61,7 +61,7 @@ func volumeProfileHandler(w http.ResponseWriter, r *http.Request) { } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "volume.Profile", Nodes: volinfo.Nodes(), @@ -217,7 +217,7 @@ func decodeIntervalKey(key string) (string, string) { return fop, k } -func txnVolumeProfile(c oldtransaction.TxnCtx) error { +func txnVolumeProfile(c transaction.TxnCtx) error { var volinfo volume.Volinfo var nodeProfileInfo []map[string]string if err := c.Get("volinfo", &volinfo); err != nil { diff --git a/glusterd2/commands/volumes/volume-reset.go b/glusterd2/commands/volumes/volume-reset.go index 5d7855557..fa707dc49 100644 --- a/glusterd2/commands/volumes/volume-reset.go +++ b/glusterd2/commands/volumes/volume-reset.go @@ -5,9 +5,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" "github.com/gluster/glusterd2/pkg/api" @@ -20,13 +20,13 @@ import ( func registerVolOptionResetStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"vol-option.XlatorActionDoReset", xlatorActionDoReset}, {"vol-option.XlatorActionUndoReset", xlatorActionUndoReset}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -55,7 +55,7 @@ func volumeResetHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -156,7 +156,7 @@ func volumeResetHandler(w http.ResponseWriter, r *http.Request) { opt[key] = "" } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-option.XlatorActionDoReset", UndoFunc: "vol-option.XlatorActionUndoReset", diff --git a/glusterd2/commands/volumes/volume-smartvol-txn.go b/glusterd2/commands/volumes/volume-smartvol-txn.go index 10a749cca..da27d1f9e 100644 --- a/glusterd2/commands/volumes/volume-smartvol-txn.go +++ b/glusterd2/commands/volumes/volume-smartvol-txn.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/fsutils" @@ -16,7 +16,7 @@ import ( log "github.com/sirupsen/logrus" ) -func txnPrepareBricks(c oldtransaction.TxnCtx) error { +func txnPrepareBricks(c transaction.TxnCtx) error { var req api.VolCreateReq if err := c.Get("req", &req); err != nil { c.Logger().WithError(err).WithField("key", "req").Error("failed to get key from store") @@ -41,7 +41,7 @@ func txnPrepareBricks(c oldtransaction.TxnCtx) error { } // PrepareBrickLvm prepares(Creates thin pool, creates LV, mounts etc.) a single brick -func PrepareBrickLvm(b api.BrickReq, c oldtransaction.TxnCtx) error { +func PrepareBrickLvm(b api.BrickReq, c transaction.TxnCtx) error { if b.PeerID != gdctx.MyUUID.String() { return nil } @@ -128,7 +128,7 @@ func PrepareBrickLvm(b api.BrickReq, c oldtransaction.TxnCtx) error { return nil } -func txnUndoPrepareBricks(c oldtransaction.TxnCtx) error { +func txnUndoPrepareBricks(c transaction.TxnCtx) error { var req api.VolCreateReq if err := c.Get("req", &req); err != nil { c.Logger().WithError(err).WithField("key", "req").Error("failed to get key from store") @@ -140,7 +140,7 @@ func txnUndoPrepareBricks(c oldtransaction.TxnCtx) error { return txnUndoPrepareBricksLvm(req, c) } -func txnUndoPrepareBricksLvm(req api.VolCreateReq, c oldtransaction.TxnCtx) error { +func txnUndoPrepareBricksLvm(req api.VolCreateReq, c transaction.TxnCtx) error { for _, sv := range req.Subvols { for _, b := range sv.Bricks { @@ -191,7 +191,7 @@ func txnUndoPrepareBricksLvm(req api.VolCreateReq, c oldtransaction.TxnCtx) erro } // PrepareBrickLoop prepares a single brick -func PrepareBrickLoop(b api.BrickReq, c oldtransaction.TxnCtx) error { +func PrepareBrickLoop(b api.BrickReq, c transaction.TxnCtx) error { if b.PeerID != gdctx.MyUUID.String() { return nil } @@ -277,7 +277,7 @@ func PrepareBrickLoop(b api.BrickReq, c oldtransaction.TxnCtx) error { return nil } -func txnUndoPrepareBricksLoop(req api.VolCreateReq, c oldtransaction.TxnCtx) error { +func txnUndoPrepareBricksLoop(req api.VolCreateReq, c transaction.TxnCtx) error { for _, sv := range req.Subvols { for _, b := range sv.Bricks { @@ -321,7 +321,7 @@ func txnUndoPrepareBricksLoop(req api.VolCreateReq, c oldtransaction.TxnCtx) err return nil } -func txnCleanBricks(c oldtransaction.TxnCtx) error { +func txnCleanBricks(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( diff --git a/glusterd2/commands/volumes/volume-start.go b/glusterd2/commands/volumes/volume-start.go index 3f946cdbd..e289eb3d9 100644 --- a/glusterd2/commands/volumes/volume-start.go +++ b/glusterd2/commands/volumes/volume-start.go @@ -8,9 +8,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brickmux" "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -22,7 +21,7 @@ import ( "go.opencensus.io/trace" ) -func startAllBricks(c oldtransaction.TxnCtx) error { +func startAllBricks(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -81,7 +80,7 @@ func startAllBricks(c oldtransaction.TxnCtx) error { return nil } -func stopAllBricks(c oldtransaction.TxnCtx) error { +func stopAllBricks(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -111,7 +110,7 @@ func stopAllBricks(c oldtransaction.TxnCtx) error { func registerVolStartStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"vol-start.StartBricks", startAllBricks}, {"vol-start.StartBricksUndo", stopAllBricks}, @@ -121,7 +120,7 @@ func registerVolStartStepFuncs() { {"vol-start.UpdateVolinfo.Undo", undoStoreVolume}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -156,7 +155,7 @@ func StartVolume(ctx context.Context, volname string, req api.VolumeStartReq) (v ctx, span := trace.StartSpan(ctx, "/volumeStartHandler") defer span.End() - txn, err := transactionv2.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) return nil, status, err @@ -173,7 +172,7 @@ func StartVolume(ctx context.Context, volname string, req api.VolumeStartReq) (v return nil, http.StatusBadRequest, errors.ErrVolAlreadyStarted } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-start.StartBricks", UndoFunc: "vol-start.StartBricksUndo", diff --git a/glusterd2/commands/volumes/volume-statedump.go b/glusterd2/commands/volumes/volume-statedump.go index 1de5df0f7..2010144dd 100644 --- a/glusterd2/commands/volumes/volume-statedump.go +++ b/glusterd2/commands/volumes/volume-statedump.go @@ -7,9 +7,9 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" @@ -37,7 +37,7 @@ func validateVolStatedumpReq(req *api.VolStatedumpReq) error { return nil } -func takeStatedump(c oldtransaction.TxnCtx) error { +func takeStatedump(c transaction.TxnCtx) error { var req api.VolStatedumpReq if err := c.Get("req", &req); err != nil { @@ -83,7 +83,7 @@ func takeStatedump(c oldtransaction.TxnCtx) error { } func registerVolStatedumpFuncs() { - oldtransaction.RegisterStepFunc(takeStatedump, "vol-statedump.TakeStatedump") + transaction.RegisterStepFunc(takeStatedump, "vol-statedump.TakeStatedump") } func volumeStatedumpHandler(w http.ResponseWriter, r *http.Request) { @@ -103,7 +103,7 @@ func volumeStatedumpHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -123,7 +123,7 @@ func volumeStatedumpHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-statedump.TakeStatedump", Nodes: volinfo.Nodes(), diff --git a/glusterd2/commands/volumes/volume-stop.go b/glusterd2/commands/volumes/volume-stop.go index 86c6e8fe4..99cf160fa 100644 --- a/glusterd2/commands/volumes/volume-stop.go +++ b/glusterd2/commands/volumes/volume-stop.go @@ -9,9 +9,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" - transactionv2 "github.com/gluster/glusterd2/glusterd2/transaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" @@ -23,7 +22,7 @@ import ( "go.opencensus.io/trace" ) -func stopBricks(c oldtransaction.TxnCtx) error { +func stopBricks(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { @@ -101,7 +100,7 @@ func stopBricks(c oldtransaction.TxnCtx) error { func registerVolStopStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"vol-stop.StopBricks", stopBricks}, {"vol-stop.XlatorActionDoVolumeStop", xlatorActionDoVolumeStop}, @@ -110,7 +109,7 @@ func registerVolStopStepFuncs() { {"vol-stop.UpdateVolinfo.Undo", undoStoreVolume}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -124,7 +123,7 @@ func volumeStopHandler(w http.ResponseWriter, r *http.Request) { logger := gdctx.GetReqLogger(ctx) volname := mux.Vars(r)["volname"] - txn, err := transactionv2.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -149,7 +148,7 @@ func volumeStopHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-stop.StopBricks", Nodes: volinfo.Nodes(), From b8686b34d7e6160663c38be1a59e6b65c95efc05 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 14:05:04 +0530 Subject: [PATCH 5/7] Remove references to oldtransaction in plugins --- plugins/bitrot/init.go | 10 +++--- plugins/bitrot/rest.go | 20 +++++------ plugins/bitrot/transactions.go | 8 ++--- .../gluster-virtblock/gluster_virtblock.go | 6 ++-- .../blockvolume/hostvol/hostvol_manager.go | 4 +-- plugins/blockvolume/hostvol/utils.go | 4 +-- plugins/device/deviceutils/store-utils.go | 6 ++-- plugins/device/init.go | 4 +-- plugins/device/rest.go | 8 ++--- plugins/device/transaction.go | 8 ++--- plugins/events/rest.go | 12 +++---- plugins/georeplication/init.go | 24 ++++++------- plugins/georeplication/rest.go | 34 +++++++++---------- plugins/georeplication/transactions.go | 28 +++++++-------- plugins/glustershd/init.go | 4 +-- plugins/glustershd/rest.go | 8 ++--- plugins/glustershd/transactions.go | 4 +-- plugins/rebalance/eventnotify.go | 4 +-- plugins/rebalance/init.go | 10 +++--- plugins/rebalance/rest.go | 16 ++++----- plugins/rebalance/transaction.go | 10 +++--- plugins/tracemgmt/init.go | 14 ++++---- plugins/tracemgmt/rest.go | 7 ++-- plugins/tracemgmt/transactions.go | 16 ++++----- 24 files changed, 134 insertions(+), 135 deletions(-) diff --git a/plugins/bitrot/init.go b/plugins/bitrot/init.go index bf5a984ec..38f3d5df3 100644 --- a/plugins/bitrot/init.go +++ b/plugins/bitrot/init.go @@ -1,8 +1,8 @@ package bitrot import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" + "github.com/gluster/glusterd2/glusterd2/transaction" ) const name = "bitrot" @@ -49,9 +49,9 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - oldtransaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-enable.Commit") - oldtransaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-disable.Commit") - oldtransaction.RegisterStepFunc(txnBitrotScrubOndemand, "bitrot-scrubondemand.Commit") - oldtransaction.RegisterStepFunc(txnBitrotScrubStatus, "bitrot-scrubstatus.Commit") + transaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-enable.Commit") + transaction.RegisterStepFunc(txnBitrotEnableDisable, "bitrot-disable.Commit") + transaction.RegisterStepFunc(txnBitrotScrubOndemand, "bitrot-scrubondemand.Commit") + transaction.RegisterStepFunc(txnBitrotScrubStatus, "bitrot-scrubstatus.Commit") return } diff --git a/plugins/bitrot/rest.go b/plugins/bitrot/rest.go index 84d0c39cc..e7542e94c 100644 --- a/plugins/bitrot/rest.go +++ b/plugins/bitrot/rest.go @@ -5,8 +5,8 @@ import ( "strconv" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/glusterd2/xlator" "github.com/gluster/glusterd2/pkg/errors" @@ -23,7 +23,7 @@ func bitrotEnableHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -68,7 +68,7 @@ func bitrotEnableHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = volinfo.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-option.UpdateVolinfo", UndoFunc: "vol-option.UpdateVolinfo.Undo", @@ -107,7 +107,7 @@ func bitrotDisableHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -140,7 +140,7 @@ func bitrotDisableHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = volinfo.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-option.UpdateVolinfo", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -173,7 +173,7 @@ func bitrotScrubOndemandHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -202,7 +202,7 @@ func bitrotScrubOndemandHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = volinfo.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "bitrot-scrubondemand.Commit", Nodes: txn.Nodes, @@ -229,7 +229,7 @@ func bitrotScrubStatusHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -264,7 +264,7 @@ func bitrotScrubStatusHandler(w http.ResponseWriter, r *http.Request) { txn.DisableRollback = true txn.Nodes = volinfo.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "bitrot-scrubstatus.Commit", Nodes: txn.Nodes, @@ -293,7 +293,7 @@ func bitrotScrubStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, result) } -func createScrubStatusResp(ctx oldtransaction.TxnCtx, volinfo *volume.Volinfo) (*bitrotapi.ScrubStatus, error) { +func createScrubStatusResp(ctx transaction.TxnCtx, volinfo *volume.Volinfo) (*bitrotapi.ScrubStatus, error) { var resp bitrotapi.ScrubStatus var exists bool diff --git a/plugins/bitrot/transactions.go b/plugins/bitrot/transactions.go index b4db53d05..d5c3775b4 100644 --- a/plugins/bitrot/transactions.go +++ b/plugins/bitrot/transactions.go @@ -7,8 +7,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" @@ -101,7 +101,7 @@ func ManageScrubd(logger log.FieldLogger, volinfo *volume.Volinfo) error { return nil } -func txnBitrotEnableDisable(c oldtransaction.TxnCtx) error { +func txnBitrotEnableDisable(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { c.Logger().WithError(err).WithField( @@ -129,7 +129,7 @@ Err: return err } -func txnBitrotScrubOndemand(c oldtransaction.TxnCtx) error { +func txnBitrotScrubOndemand(c transaction.TxnCtx) error { var volname string if err := c.Get("volname", &volname); err != nil { @@ -176,7 +176,7 @@ func txnBitrotScrubOndemand(c oldtransaction.TxnCtx) error { return nil } -func txnBitrotScrubStatus(c oldtransaction.TxnCtx) error { +func txnBitrotScrubStatus(c transaction.TxnCtx) error { var volname string if err := c.Get("volname", &volname); err != nil { diff --git a/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go b/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go index 73d732694..4cca4830c 100644 --- a/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go +++ b/plugins/blockvolume/blockprovider/gluster-virtblock/gluster_virtblock.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" "github.com/gluster/glusterd2/pkg/utils" @@ -75,7 +75,7 @@ func mountHost(g *GlusterVirtBlk, hostVolume string) (string, error) { func (g *GlusterVirtBlk) CreateBlockVolume(name string, size uint64, hostVolume string, options ...blockprovider.BlockVolOption) (blockprovider.BlockVolume, error) { var ( blockVolOpts = &blockprovider.BlockVolumeOptions{} - clusterLocks = oldtransaction.Locks{} + clusterLocks = transaction.Locks{} ) blockVolOpts.ApplyOpts(options...) @@ -145,7 +145,7 @@ func (g *GlusterVirtBlk) CreateBlockVolume(name string, size uint64, hostVolume func (g *GlusterVirtBlk) DeleteBlockVolume(name string, options ...blockprovider.BlockVolOption) error { var ( blockVolOpts = &blockprovider.BlockVolumeOptions{} - clusterLocks = oldtransaction.Locks{} + clusterLocks = transaction.Locks{} ) blockVolOpts.ApplyOpts(options...) diff --git a/plugins/blockvolume/hostvol/hostvol_manager.go b/plugins/blockvolume/hostvol/hostvol_manager.go index 42532d269..46b6a2e16 100644 --- a/plugins/blockvolume/hostvol/hostvol_manager.go +++ b/plugins/blockvolume/hostvol/hostvol_manager.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/plugins/blockvolume/api" @@ -58,7 +58,7 @@ func (g *GlusterVolManager) GetHostingVolumesInUse() []*volume.Volinfo { func (g *GlusterVolManager) GetOrCreateHostingVolume(name string, minSizeLimit uint64, hostVolumeInfo *api.HostVolumeInfo) (*volume.Volinfo, error) { var ( volInfo *volume.Volinfo - clusterLocks = oldtransaction.Locks{} + clusterLocks = transaction.Locks{} ) if err := clusterLocks.Lock(path.Join(globalLockID, name)); err != nil { diff --git a/plugins/blockvolume/hostvol/utils.go b/plugins/blockvolume/hostvol/utils.go index f205c76eb..6f258896d 100644 --- a/plugins/blockvolume/hostvol/utils.go +++ b/plugins/blockvolume/hostvol/utils.go @@ -11,7 +11,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/commands/volumes" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/size" @@ -92,7 +92,7 @@ func CreateAndStartHostingVolume(req *api.VolCreateReq) (*volume.Volinfo, error) // f := func(a, b uint64) uint64{return a +b } func ResizeBlockHostingVolume(volName string, blockSize interface{}, resizeFunc func(blockHostingAvailableSize, blockSize uint64) uint64) error { var ( - clusterLocks = oldtransaction.Locks{} + clusterLocks = transaction.Locks{} ) if err := clusterLocks.Lock(volName); err != nil { diff --git a/plugins/device/deviceutils/store-utils.go b/plugins/device/deviceutils/store-utils.go index 1c13438ca..750b5cd2b 100644 --- a/plugins/device/deviceutils/store-utils.go +++ b/plugins/device/deviceutils/store-utils.go @@ -6,8 +6,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/store" + "github.com/gluster/glusterd2/glusterd2/transaction" gderrors "github.com/gluster/glusterd2/pkg/errors" "github.com/gluster/glusterd2/pkg/lvmutils" deviceapi "github.com/gluster/glusterd2/plugins/device/api" @@ -117,7 +117,7 @@ func UpdateDeviceFreeSize(peerID, device string) error { // AddDeviceFreeSize updates device available size func AddDeviceFreeSize(peerID, device string, size uint64) error { - clusterLocks := oldtransaction.Locks{} + clusterLocks := transaction.Locks{} if err := clusterLocks.Lock(peerID + device); err != nil { return err } @@ -135,7 +135,7 @@ func AddDeviceFreeSize(peerID, device string, size uint64) error { // ReduceDeviceFreeSize updates device available size func ReduceDeviceFreeSize(peerID, device string, size uint64) error { - clusterLocks := oldtransaction.Locks{} + clusterLocks := transaction.Locks{} if err := clusterLocks.Lock(peerID + device); err != nil { return err } diff --git a/plugins/device/init.go b/plugins/device/init.go index dea5388ef..3c2628193 100644 --- a/plugins/device/init.go +++ b/plugins/device/init.go @@ -1,8 +1,8 @@ package device import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" deviceapi "github.com/gluster/glusterd2/plugins/device/api" ) @@ -61,5 +61,5 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - oldtransaction.RegisterStepFunc(txnPrepareDevice, "prepare-device") + transaction.RegisterStepFunc(txnPrepareDevice, "prepare-device") } diff --git a/plugins/device/rest.go b/plugins/device/rest.go index 5e6a4eb51..6f4795716 100644 --- a/plugins/device/rest.go +++ b/plugins/device/rest.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/errors" deviceapi "github.com/gluster/glusterd2/plugins/device/api" @@ -39,7 +39,7 @@ func deviceAddHandler(w http.ResponseWriter, r *http.Request) { req.ProvisionerType = api.ProvisionerTypeLvm } - txn, err := oldtransaction.NewTxnWithLocks(ctx, peerID) + txn, err := transaction.NewTxnWithLocks(ctx, peerID) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -71,7 +71,7 @@ func deviceAddHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = []uuid.UUID{peerInfo.ID} - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "prepare-device", Nodes: txn.Nodes, @@ -181,7 +181,7 @@ func deviceEditHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, peerID+device) + txn, err := transaction.NewTxnWithLocks(ctx, peerID+device) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) diff --git a/plugins/device/transaction.go b/plugins/device/transaction.go index 53b055443..22711554c 100644 --- a/plugins/device/transaction.go +++ b/plugins/device/transaction.go @@ -3,7 +3,7 @@ package device import ( "os" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/fsutils" "github.com/gluster/glusterd2/pkg/lvmutils" @@ -13,7 +13,7 @@ import ( "github.com/pborman/uuid" ) -func txnPrepareDevice(c oldtransaction.TxnCtx) error { +func txnPrepareDevice(c transaction.TxnCtx) error { var req deviceapi.AddDeviceReq if err := c.Get("req", &req); err != nil { c.Logger().WithError(err).WithField("key", "req").Error("Failed to get key from transaction context") @@ -25,7 +25,7 @@ func txnPrepareDevice(c oldtransaction.TxnCtx) error { return txnPrepareDeviceLvm(req, c) } -func txnPrepareDeviceLvm(req deviceapi.AddDeviceReq, c oldtransaction.TxnCtx) error { +func txnPrepareDeviceLvm(req deviceapi.AddDeviceReq, c transaction.TxnCtx) error { var peerID uuid.UUID if err := c.Get("peerid", &peerID); err != nil { c.Logger().WithError(err).WithField("key", "peerid").Error("Failed to get key from transaction context") @@ -72,7 +72,7 @@ func txnPrepareDeviceLvm(req deviceapi.AddDeviceReq, c oldtransaction.TxnCtx) er return nil } -func txnPrepareDeviceLoop(req deviceapi.AddDeviceReq, c oldtransaction.TxnCtx) error { +func txnPrepareDeviceLoop(req deviceapi.AddDeviceReq, c transaction.TxnCtx) error { var peerID uuid.UUID if err := c.Get("peerid", &peerID); err != nil { c.Logger().WithError(err).WithField("key", "peerid").Error("Failed to get key from transaction context") diff --git a/plugins/events/rest.go b/plugins/events/rest.go index 337e9217b..44c1d1026 100644 --- a/plugins/events/rest.go +++ b/plugins/events/rest.go @@ -5,9 +5,9 @@ import ( gd2events "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/errors" eventsapi "github.com/gluster/glusterd2/plugins/events/api" ) @@ -126,7 +126,7 @@ func eventsListHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(ctx, w, http.StatusOK, events) } -func checkConnection(c oldtransaction.TxnCtx) error { +func checkConnection(c transaction.TxnCtx) error { var req eventsapi.Webhook if err := c.Get("req", &req); err != nil { @@ -139,12 +139,12 @@ func checkConnection(c oldtransaction.TxnCtx) error { func registerWebhookTestStepFuncs() { var sfs = []struct { name string - sf oldtransaction.StepFunc + sf transaction.StepFunc }{ {"webhook-test.checkConnection", checkConnection}, } for _, sf := range sfs { - oldtransaction.RegisterStepFunc(sf.sf, sf.name) + transaction.RegisterStepFunc(sf.sf, sf.name) } } @@ -170,10 +170,10 @@ func webhookTestHandler(w http.ResponseWriter, r *http.Request) { return } - txn := oldtransaction.NewTxn(ctx) + txn := transaction.NewTxn(ctx) defer txn.Done() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "webhook-test.checkConnection", Nodes: allNodes, diff --git a/plugins/georeplication/init.go b/plugins/georeplication/init.go index c415c8dc0..82e6ce236 100644 --- a/plugins/georeplication/init.go +++ b/plugins/georeplication/init.go @@ -1,8 +1,8 @@ package georeplication import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" georepapi "github.com/gluster/glusterd2/plugins/georeplication/api" ) @@ -130,15 +130,15 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - oldtransaction.RegisterStepFunc(txnGeorepCreate, "georeplication-create.Commit") - oldtransaction.RegisterStepFunc(txnGeorepStart, "georeplication-start.Commit") - oldtransaction.RegisterStepFunc(txnGeorepStop, "georeplication-stop.Commit") - oldtransaction.RegisterStepFunc(txnGeorepDelete, "georeplication-delete.Commit") - oldtransaction.RegisterStepFunc(txnGeorepPause, "georeplication-pause.Commit") - oldtransaction.RegisterStepFunc(txnGeorepResume, "georeplication-resume.Commit") - oldtransaction.RegisterStepFunc(txnGeorepStatus, "georeplication-status.Commit") - oldtransaction.RegisterStepFunc(txnGeorepConfigSet, "georeplication-configset.Commit") - oldtransaction.RegisterStepFunc(txnGeorepConfigFilegen, "georeplication-configfilegen.Commit") - oldtransaction.RegisterStepFunc(txnSSHKeysGenerate, "georeplication-ssh-keygen.Commit") - oldtransaction.RegisterStepFunc(txnSSHKeysPush, "georeplication-ssh-keypush.Commit") + transaction.RegisterStepFunc(txnGeorepCreate, "georeplication-create.Commit") + transaction.RegisterStepFunc(txnGeorepStart, "georeplication-start.Commit") + transaction.RegisterStepFunc(txnGeorepStop, "georeplication-stop.Commit") + transaction.RegisterStepFunc(txnGeorepDelete, "georeplication-delete.Commit") + transaction.RegisterStepFunc(txnGeorepPause, "georeplication-pause.Commit") + transaction.RegisterStepFunc(txnGeorepResume, "georeplication-resume.Commit") + transaction.RegisterStepFunc(txnGeorepStatus, "georeplication-status.Commit") + transaction.RegisterStepFunc(txnGeorepConfigSet, "georeplication-configset.Commit") + transaction.RegisterStepFunc(txnGeorepConfigFilegen, "georeplication-configfilegen.Commit") + transaction.RegisterStepFunc(txnSSHKeysGenerate, "georeplication-ssh-keygen.Commit") + transaction.RegisterStepFunc(txnSSHKeysPush, "georeplication-ssh-keypush.Commit") } diff --git a/plugins/georeplication/rest.go b/plugins/georeplication/rest.go index 22f95851b..50a9dc887 100644 --- a/plugins/georeplication/rest.go +++ b/plugins/georeplication/rest.go @@ -11,8 +11,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" "github.com/gluster/glusterd2/pkg/utils" @@ -110,7 +110,7 @@ func georepCreateHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, req.MasterVol) + txn, err := transaction.NewTxnWithLocks(ctx, req.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -188,7 +188,7 @@ func georepCreateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "vol-option.UpdateVolinfo", UndoFunc: "vol-option.UpdateVolinfo.Undo", @@ -284,7 +284,7 @@ func georepActionHandler(w http.ResponseWriter, r *http.Request, action actionTy return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -330,7 +330,7 @@ func georepActionHandler(w http.ResponseWriter, r *http.Request, action actionTy return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: doFunc, Nodes: vol.Nodes(), @@ -414,7 +414,7 @@ func georepDeleteHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -431,7 +431,7 @@ func georepDeleteHandler(w http.ResponseWriter, r *http.Request) { } // TODO: Add transaction step to clean xattrs specific to georep session - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "georeplication-delete.Commit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -505,11 +505,11 @@ func georepStatusHandler(w http.ResponseWriter, r *http.Request) { } // Status Transaction - txn := oldtransaction.NewTxn(ctx) + txn := transaction.NewTxn(ctx) defer txn.Done() txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "georeplication-status.Commit", Nodes: txn.Nodes, @@ -749,7 +749,7 @@ func georepConfigSetHandler(w http.ResponseWriter, r *http.Request) { } } - txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -780,7 +780,7 @@ func georepConfigSetHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "georeplication-configset.Commit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -895,7 +895,7 @@ func georepConfigResetHandler(w http.ResponseWriter, r *http.Request) { restartRequired = false } - txn, err := oldtransaction.NewTxnWithLocks(ctx, geoSession.MasterVol) + txn, err := transaction.NewTxnWithLocks(ctx, geoSession.MasterVol) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -915,7 +915,7 @@ func georepConfigResetHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "georeplication-configset.Commit", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -989,7 +989,7 @@ func georepSSHKeyGenerateHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -1006,7 +1006,7 @@ func georepSSHKeyGenerateHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "georeplication-ssh-keygen.Commit", Nodes: txn.Nodes, @@ -1064,7 +1064,7 @@ func georepSSHKeyPushHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -1088,7 +1088,7 @@ func georepSSHKeyPushHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "georeplication-ssh-keypush.Commit", Nodes: txn.Nodes, diff --git a/plugins/georeplication/transactions.go b/plugins/georeplication/transactions.go index 285c98ee3..46db09824 100644 --- a/plugins/georeplication/transactions.go +++ b/plugins/georeplication/transactions.go @@ -12,7 +12,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/utils" @@ -27,7 +27,7 @@ const ( gsyncdStatusTxnKey string = "gsyncdstatuses" ) -func txnGeorepCreate(c oldtransaction.TxnCtx) error { +func txnGeorepCreate(c transaction.TxnCtx) error { var sessioninfo georepapi.GeorepSession if err := c.Get("geosession", &sessioninfo); err != nil { return err @@ -44,7 +44,7 @@ func txnGeorepCreate(c oldtransaction.TxnCtx) error { return nil } -func gsyncdAction(c oldtransaction.TxnCtx, action actionType) error { +func gsyncdAction(c transaction.TxnCtx, action actionType) error { var masterid string var remoteid string if err := c.Get("mastervolid", &masterid); err != nil { @@ -91,15 +91,15 @@ func gsyncdAction(c oldtransaction.TxnCtx, action actionType) error { return err } -func txnGeorepStart(c oldtransaction.TxnCtx) error { +func txnGeorepStart(c transaction.TxnCtx) error { return gsyncdAction(c, actionStart) } -func txnGeorepStop(c oldtransaction.TxnCtx) error { +func txnGeorepStop(c transaction.TxnCtx) error { return gsyncdAction(c, actionStop) } -func txnGeorepDelete(c oldtransaction.TxnCtx) error { +func txnGeorepDelete(c transaction.TxnCtx) error { var masterid string var remoteid string if err := c.Get("mastervolid", &masterid); err != nil { @@ -125,15 +125,15 @@ func txnGeorepDelete(c oldtransaction.TxnCtx) error { return nil } -func txnGeorepPause(c oldtransaction.TxnCtx) error { +func txnGeorepPause(c transaction.TxnCtx) error { return gsyncdAction(c, actionPause) } -func txnGeorepResume(c oldtransaction.TxnCtx) error { +func txnGeorepResume(c transaction.TxnCtx) error { return gsyncdAction(c, actionResume) } -func txnGeorepStatus(c oldtransaction.TxnCtx) error { +func txnGeorepStatus(c transaction.TxnCtx) error { var masterid string var remoteid string var err error @@ -185,7 +185,7 @@ func txnGeorepStatus(c oldtransaction.TxnCtx) error { return nil } -func aggregateGsyncdStatus(ctx oldtransaction.TxnCtx, nodes []uuid.UUID) (*map[string]georepapi.GeorepWorker, error) { +func aggregateGsyncdStatus(ctx transaction.TxnCtx, nodes []uuid.UUID) (*map[string]georepapi.GeorepWorker, error) { var workersStatuses = make(map[string]georepapi.GeorepWorker) // Loop over each node on which txn was run. @@ -206,7 +206,7 @@ func aggregateGsyncdStatus(ctx oldtransaction.TxnCtx, nodes []uuid.UUID) (*map[s return &workersStatuses, nil } -func txnGeorepConfigSet(c oldtransaction.TxnCtx) error { +func txnGeorepConfigSet(c transaction.TxnCtx) error { var masterid string var remoteid string var session georepapi.GeorepSession @@ -300,7 +300,7 @@ func configFileGenerate(session *georepapi.GeorepSession) error { return ioutil.WriteFile(configFile, []byte(strings.Join(confdata, "\n")), 0644) } -func txnGeorepConfigFilegen(c oldtransaction.TxnCtx) error { +func txnGeorepConfigFilegen(c transaction.TxnCtx) error { var masterid string var remoteid string var session georepapi.GeorepSession @@ -341,7 +341,7 @@ func txnGeorepConfigFilegen(c oldtransaction.TxnCtx) error { return nil } -func txnSSHKeysGenerate(c oldtransaction.TxnCtx) error { +func txnSSHKeysGenerate(c transaction.TxnCtx) error { var volname string var err error var args []string @@ -402,7 +402,7 @@ func txnSSHKeysGenerate(c oldtransaction.TxnCtx) error { return err } -func txnSSHKeysPush(c oldtransaction.TxnCtx) error { +func txnSSHKeysPush(c transaction.TxnCtx) error { var err error var sshkeys []georepapi.GeorepSSHPublicKey var user string diff --git a/plugins/glustershd/init.go b/plugins/glustershd/init.go index 92de478d3..5c7fa9b32 100644 --- a/plugins/glustershd/init.go +++ b/plugins/glustershd/init.go @@ -1,8 +1,8 @@ package glustershd import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" glustershdapi "github.com/gluster/glusterd2/plugins/glustershd/api" ) @@ -52,5 +52,5 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - oldtransaction.RegisterStepFunc(txnSelfHeal, "selfheal.Heal") + transaction.RegisterStepFunc(txnSelfHeal, "selfheal.Heal") } diff --git a/plugins/glustershd/rest.go b/plugins/glustershd/rest.go index 2f4546c8e..26ffd8622 100644 --- a/plugins/glustershd/rest.go +++ b/plugins/glustershd/rest.go @@ -11,9 +11,9 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" gderrors "github.com/gluster/glusterd2/pkg/errors" glustershdapi "github.com/gluster/glusterd2/plugins/glustershd/api" @@ -135,7 +135,7 @@ func selfhealInfoHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := gdctx.GetReqLogger(ctx) - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -214,7 +214,7 @@ func selfHealHandler(w http.ResponseWriter, r *http.Request) { return } } - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -252,7 +252,7 @@ func selfHealHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "selfheal.Heal", Nodes: volinfo.Nodes(), diff --git a/plugins/glustershd/transactions.go b/plugins/glustershd/transactions.go index 921c039e4..29be28d65 100644 --- a/plugins/glustershd/transactions.go +++ b/plugins/glustershd/transactions.go @@ -8,8 +8,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" ) @@ -61,7 +61,7 @@ func selectHxlatorsWithBricks(volinfo *volume.Volinfo, healType int) map[string] return reqDict } -func txnSelfHeal(c oldtransaction.TxnCtx) error { +func txnSelfHeal(c transaction.TxnCtx) error { var volinfo volume.Volinfo if err := c.Get("volinfo", &volinfo); err != nil { diff --git a/plugins/rebalance/eventnotify.go b/plugins/rebalance/eventnotify.go index 609636e7b..fd5aeab8e 100644 --- a/plugins/rebalance/eventnotify.go +++ b/plugins/rebalance/eventnotify.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" rebalanceapi "github.com/gluster/glusterd2/plugins/rebalance/api" @@ -34,7 +34,7 @@ func HandleEventNotify(status map[string]string) error { var rebalinfo *rebalanceapi.RebalInfo var rebalNodeStatus rebalanceapi.RebalNodeStatus - txn, err := oldtransaction.NewTxnWithLocks(context.TODO(), volname) + txn, err := transaction.NewTxnWithLocks(context.TODO(), volname) if err != nil { log.WithError(err).Error("Locking failed. Unable to update store") return err diff --git a/plugins/rebalance/init.go b/plugins/rebalance/init.go index c4c6b2bc5..24339324f 100644 --- a/plugins/rebalance/init.go +++ b/plugins/rebalance/init.go @@ -1,8 +1,8 @@ package rebalance import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" rebalanceapi "github.com/gluster/glusterd2/plugins/rebalance/api" ) @@ -47,8 +47,8 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with // Glusterd Transaction framework func (p *Plugin) RegisterStepFuncs() { - oldtransaction.RegisterStepFunc(txnRebalanceStart, "rebalance-start") - oldtransaction.RegisterStepFunc(txnRebalanceStop, "rebalance-stop") - oldtransaction.RegisterStepFunc(txnRebalanceStatus, "rebalance-status") - oldtransaction.RegisterStepFunc(txnRebalanceStoreDetails, "rebalance-store") + transaction.RegisterStepFunc(txnRebalanceStart, "rebalance-start") + transaction.RegisterStepFunc(txnRebalanceStop, "rebalance-stop") + transaction.RegisterStepFunc(txnRebalanceStatus, "rebalance-status") + transaction.RegisterStepFunc(txnRebalanceStoreDetails, "rebalance-store") } diff --git a/plugins/rebalance/rest.go b/plugins/rebalance/rest.go index d351843bb..ec82a6102 100644 --- a/plugins/rebalance/rest.go +++ b/plugins/rebalance/rest.go @@ -5,8 +5,8 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volume" "github.com/gluster/glusterd2/pkg/errors" @@ -57,7 +57,7 @@ func rebalanceStartHandler(w http.ResponseWriter, r *http.Request) { return } - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -88,7 +88,7 @@ func rebalanceStartHandler(w http.ResponseWriter, r *http.Request) { // Only this node will save the rebalinfo in the store txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "rebalance-start", Nodes: txn.Nodes, @@ -150,7 +150,7 @@ func rebalanceStopHandler(w http.ResponseWriter, r *http.Request) { // collect inputs from url volname := mux.Vars(r)["volname"] - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -179,7 +179,7 @@ func rebalanceStopHandler(w http.ResponseWriter, r *http.Request) { } txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "rebalance-stop", Nodes: txn.Nodes, @@ -227,7 +227,7 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) { // collect inputs from url volname := mux.Vars(r)["volname"] - txn, err := oldtransaction.NewTxnWithLocks(ctx, volname) + txn, err := transaction.NewTxnWithLocks(ctx, volname) if err != nil { status, err := restutils.ErrToStatusCode(err) restutils.SendHTTPError(ctx, w, status, err) @@ -261,7 +261,7 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) { // Get the consolidated status from all the nodes txn.Nodes = vol.Nodes() - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "rebalance-status", Nodes: txn.Nodes, @@ -292,7 +292,7 @@ func rebalanceStatusHandler(w http.ResponseWriter, r *http.Request) { restutils.SendHTTPResponse(r.Context(), w, http.StatusOK, response) } -func createRebalanceStatusResp(ctx oldtransaction.TxnCtx, volinfo *volume.Volinfo) (*rebalanceapi.RebalStatus, error) { +func createRebalanceStatusResp(ctx transaction.TxnCtx, volinfo *volume.Volinfo) (*rebalanceapi.RebalStatus, error) { var ( resp rebalanceapi.RebalStatus tmp rebalanceapi.RebalNodeStatus diff --git a/plugins/rebalance/transaction.go b/plugins/rebalance/transaction.go index b70279f97..2fe7cb9e5 100644 --- a/plugins/rebalance/transaction.go +++ b/plugins/rebalance/transaction.go @@ -6,8 +6,8 @@ import ( "github.com/gluster/glusterd2/glusterd2/brick" "github.com/gluster/glusterd2/glusterd2/daemon" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/sunrpc/dict" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/glusterd2/volgen" "github.com/gluster/glusterd2/glusterd2/volume" rebalanceapi "github.com/gluster/glusterd2/plugins/rebalance/api" @@ -26,7 +26,7 @@ const ( rebalStatusTxnKey string = "rebalstatus" ) -func txnRebalanceStart(c oldtransaction.TxnCtx) error { +func txnRebalanceStart(c transaction.TxnCtx) error { var rinfo rebalanceapi.RebalInfo err := c.Get("rinfo", &rinfo) @@ -63,7 +63,7 @@ func txnRebalanceStart(c oldtransaction.TxnCtx) error { return nil } -func txnRebalanceStop(c oldtransaction.TxnCtx) error { +func txnRebalanceStop(c transaction.TxnCtx) error { var rebalinfo rebalanceapi.RebalInfo err := c.Get("rinfo", &rebalinfo) if err != nil { @@ -134,7 +134,7 @@ func txnRebalanceStop(c oldtransaction.TxnCtx) error { return nil } -func txnRebalanceStatus(c oldtransaction.TxnCtx) error { +func txnRebalanceStatus(c transaction.TxnCtx) error { var ( rebalinfo rebalanceapi.RebalInfo @@ -228,7 +228,7 @@ func txnRebalanceStatus(c oldtransaction.TxnCtx) error { } -func txnRebalanceStoreDetails(c oldtransaction.TxnCtx) error { +func txnRebalanceStoreDetails(c transaction.TxnCtx) error { var rebalinfo rebalanceapi.RebalInfo err := c.Get("rinfo", &rebalinfo) diff --git a/plugins/tracemgmt/init.go b/plugins/tracemgmt/init.go index 4b190f1ea..98617bce4 100644 --- a/plugins/tracemgmt/init.go +++ b/plugins/tracemgmt/init.go @@ -1,8 +1,8 @@ package tracemgmt import ( - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/servers/rest/route" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/utils" tracemgmtapi "github.com/gluster/glusterd2/plugins/tracemgmt/api" ) @@ -53,10 +53,10 @@ func (p *Plugin) RestRoutes() route.Routes { // RegisterStepFuncs registers transaction step functions with Glusterd transaction framework func (p *Plugin) RegisterStepFuncs() { - oldtransaction.RegisterStepFunc(txnTracingValidateConfig, "trace-mgmt.ValidateTraceConfig") - oldtransaction.RegisterStepFunc(txnTracingStoreConfig, "trace-mgmt.StoreTraceConfig") - oldtransaction.RegisterStepFunc(txnTracingUndoStoreConfig, "trace-mgmt.RestoreTraceConfig") - oldtransaction.RegisterStepFunc(txnTracingDeleteStoreConfig, "trace-mgmt.UndoStoreTraceConfig") - oldtransaction.RegisterStepFunc(txnTracingApplyNewConfig, "trace-mgmt.NotifyTraceConfigChange") - oldtransaction.RegisterStepFunc(txnTracingDisable, "trace-mgmt.NotifyTraceDisable") + transaction.RegisterStepFunc(txnTracingValidateConfig, "trace-mgmt.ValidateTraceConfig") + transaction.RegisterStepFunc(txnTracingStoreConfig, "trace-mgmt.StoreTraceConfig") + transaction.RegisterStepFunc(txnTracingUndoStoreConfig, "trace-mgmt.RestoreTraceConfig") + transaction.RegisterStepFunc(txnTracingDeleteStoreConfig, "trace-mgmt.UndoStoreTraceConfig") + transaction.RegisterStepFunc(txnTracingApplyNewConfig, "trace-mgmt.NotifyTraceConfigChange") + transaction.RegisterStepFunc(txnTracingDisable, "trace-mgmt.NotifyTraceDisable") } diff --git a/plugins/tracemgmt/rest.go b/plugins/tracemgmt/rest.go index 6e75aba56..995ed94b3 100644 --- a/plugins/tracemgmt/rest.go +++ b/plugins/tracemgmt/rest.go @@ -4,7 +4,6 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" "github.com/gluster/glusterd2/glusterd2/peer" restutils "github.com/gluster/glusterd2/glusterd2/servers/rest/utils" "github.com/gluster/glusterd2/glusterd2/transaction" @@ -54,7 +53,7 @@ func tracingEnableHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "trace-mgmt.ValidateTraceConfig", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -162,7 +161,7 @@ func tracingUpdateHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "trace-mgmt.ValidateTraceConfig", Nodes: []uuid.UUID{gdctx.MyUUID}, @@ -220,7 +219,7 @@ func tracingDisableHandler(w http.ResponseWriter, r *http.Request) { return } - txn.Steps = []*oldtransaction.Step{ + txn.Steps = []*transaction.Step{ { DoFunc: "trace-mgmt.UndoStoreTraceConfig", Nodes: []uuid.UUID{gdctx.MyUUID}, diff --git a/plugins/tracemgmt/transactions.go b/plugins/tracemgmt/transactions.go index 1c04e39d1..5923d696a 100644 --- a/plugins/tracemgmt/transactions.go +++ b/plugins/tracemgmt/transactions.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/tracing" tracemgmtapi "github.com/gluster/glusterd2/plugins/tracemgmt/api" @@ -16,7 +16,7 @@ import ( ) // Transaction step that validates the trace info passed -func txnTracingValidateConfig(c oldtransaction.TxnCtx) error { +func txnTracingValidateConfig(c transaction.TxnCtx) error { var req tracemgmtapi.SetupTracingReq if err := c.Get("req", &req); err != nil { return err @@ -60,7 +60,7 @@ func txnTracingValidateConfig(c oldtransaction.TxnCtx) error { // storeTraceConfig uses the passed context key to get // trace config and updates it into the store. -func storeTraceConfig(c oldtransaction.TxnCtx, key string) error { +func storeTraceConfig(c transaction.TxnCtx, key string) error { var traceConfig tracemgmtapi.JaegerConfigInfo if err := c.Get(key, &traceConfig); err != nil { return err @@ -71,26 +71,26 @@ func storeTraceConfig(c oldtransaction.TxnCtx, key string) error { } // Transaction step that stores the trace config -func txnTracingStoreConfig(c oldtransaction.TxnCtx) error { +func txnTracingStoreConfig(c transaction.TxnCtx) error { err := storeTraceConfig(c, "traceconfig") return err } // Transaction step that reverts the trace config -func txnTracingUndoStoreConfig(c oldtransaction.TxnCtx) error { +func txnTracingUndoStoreConfig(c transaction.TxnCtx) error { err := storeTraceConfig(c, "oldtraceconfig") return err } // Transaction step that deletes the trace config -func txnTracingDeleteStoreConfig(c oldtransaction.TxnCtx) error { +func txnTracingDeleteStoreConfig(c transaction.TxnCtx) error { err := traceutils.DeleteTraceConfig() return err } // Tranasaction step that reads trace config info from the store and updates // the in-memory trace config. -func txnTracingApplyNewConfig(c oldtransaction.TxnCtx) error { +func txnTracingApplyNewConfig(c transaction.TxnCtx) error { var traceConfig tracemgmtapi.JaegerConfigInfo if err := c.Get("traceconfig", &traceConfig); err != nil { return err @@ -138,7 +138,7 @@ func txnTracingApplyNewConfig(c oldtransaction.TxnCtx) error { } // Transaction step that disables tracing and resets the tracing config. -func txnTracingDisable(c oldtransaction.TxnCtx) error { +func txnTracingDisable(c transaction.TxnCtx) error { // Disable tracing trace.ApplyConfig(trace.Config{DefaultSampler: trace.NeverSample()}) From c6f0c803f63a4105f70aef6a27e27922bd986af1 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 14:08:21 +0530 Subject: [PATCH 6/7] Remove references to oldtransaction in glusterd2/servers --- glusterd2/servers/rest/utils/utils.go | 4 ++-- glusterd2/servers/sunrpc/callback.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/glusterd2/servers/rest/utils/utils.go b/glusterd2/servers/rest/utils/utils.go index f394f0928..8eea0e697 100644 --- a/glusterd2/servers/rest/utils/utils.go +++ b/glusterd2/servers/rest/utils/utils.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/api" gderrors "github.com/gluster/glusterd2/pkg/errors" ) @@ -100,7 +100,7 @@ func ErrToStatusCode(err error) (int, error) { statuscode = http.StatusNotFound case gderrors.ErrSnapNotFound: statuscode = http.StatusNotFound - case oldtransaction.ErrLockTimeout: + case transaction.ErrLockTimeout: statuscode = http.StatusConflict default: statuscode = http.StatusInternalServerError diff --git a/glusterd2/servers/sunrpc/callback.go b/glusterd2/servers/sunrpc/callback.go index 63b26a4c0..706f12f4f 100644 --- a/glusterd2/servers/sunrpc/callback.go +++ b/glusterd2/servers/sunrpc/callback.go @@ -5,7 +5,7 @@ import ( "net" "sync/atomic" - "github.com/gluster/glusterd2/glusterd2/oldtransaction" + "github.com/gluster/glusterd2/glusterd2/transaction" "github.com/gluster/glusterd2/pkg/sunrpc" "github.com/gluster/glusterd2/pkg/utils" @@ -90,7 +90,7 @@ const ( gfCbkStatedump = 9 ) -func fetchNotify(t oldtransaction.TxnCtx, op fetchOp) { +func fetchNotify(t transaction.TxnCtx, op fetchOp) { clientsList.RLock() defer clientsList.RUnlock() @@ -114,13 +114,13 @@ func fetchNotify(t oldtransaction.TxnCtx, op fetchOp) { // FetchSpecNotify notifies all clients connected to glusterd that the volfile // has changed and the clients should fetch the new volfile. -func FetchSpecNotify(t oldtransaction.TxnCtx) { +func FetchSpecNotify(t transaction.TxnCtx) { fetchNotify(t, gfCbkFetchSpec) } // FetchSnapNotify notifies all clients connected to glusterd that a snapshot // has been created or modified. -func FetchSnapNotify(t oldtransaction.TxnCtx) { +func FetchSnapNotify(t transaction.TxnCtx) { fetchNotify(t, gfCbkGetSnaps) } From 2eccd21e98aa453379521fbcfc8bda4ed88dfcdc Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Fri, 22 Feb 2019 14:08:57 +0530 Subject: [PATCH 7/7] Remove glusterd2/oldtransaction --- glusterd2/oldtransaction/context.go | 235 ------------------ glusterd2/oldtransaction/context_mock.go | 62 ----- glusterd2/oldtransaction/lock.go | 217 ---------------- glusterd2/oldtransaction/registry.go | 43 ---- glusterd2/oldtransaction/rpc-client.go | 78 ------ glusterd2/oldtransaction/rpc-service.go | 79 ------ glusterd2/oldtransaction/step.go | 180 -------------- .../oldtransaction/transaction-rpc.pb.go | 205 --------------- .../oldtransaction/transaction-rpc.proto | 16 -- glusterd2/oldtransaction/transaction.go | 194 --------------- 10 files changed, 1309 deletions(-) delete mode 100644 glusterd2/oldtransaction/context.go delete mode 100644 glusterd2/oldtransaction/context_mock.go delete mode 100644 glusterd2/oldtransaction/lock.go delete mode 100644 glusterd2/oldtransaction/registry.go delete mode 100644 glusterd2/oldtransaction/rpc-client.go delete mode 100644 glusterd2/oldtransaction/rpc-service.go delete mode 100644 glusterd2/oldtransaction/step.go delete mode 100644 glusterd2/oldtransaction/transaction-rpc.pb.go delete mode 100644 glusterd2/oldtransaction/transaction-rpc.proto delete mode 100644 glusterd2/oldtransaction/transaction.go diff --git a/glusterd2/oldtransaction/context.go b/glusterd2/oldtransaction/context.go deleted file mode 100644 index 2c2f56705..000000000 --- a/glusterd2/oldtransaction/context.go +++ /dev/null @@ -1,235 +0,0 @@ -package oldtransaction - -import ( - "context" - "encoding/json" - "errors" - "reflect" - "time" - - "github.com/gluster/glusterd2/glusterd2/store" - - "github.com/coreos/etcd/clientv3" - "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" -) - -const etcdTxnTimeout = 10 - -// TxnCtx is used to carry contextual information across the lifetime of a transaction -type TxnCtx interface { - // Set attaches the given key with value to the context. It updates value if key exists already. - Set(key string, value interface{}) error - // SetNodeResult is similar to Set but prefixes the key with node UUID specified. - SetNodeResult(peerID uuid.UUID, key string, value interface{}) error - // Get gets the value for the given key. Returns an error if the key is not present - Get(key string, value interface{}) error - // GetNodeResult is similar to Get but prefixes the key with node UUID specified. - GetNodeResult(peerID uuid.UUID, key string, value interface{}) error - // GetTxnReqID gets the reqID string saved in the transaction. - GetTxnReqID() string - // Delete deletes the key and value - Delete(key string) error - // Logger returns the Logrus logger associated with the context - Logger() log.FieldLogger - - // Commit writes all locally cached keys and values into the store using - // a single etcd transaction. This is for internal use by the txn framework - // and hence isn't exported. - Commit() error - - // SyncCache synchronizes the locally cached keys and values from the store - SyncCache() error -} - -// Tctx represents structure for transaction context -type Tctx struct { - config *TxnCtxConfig // this will be marshalled and sent on wire - logger log.FieldLogger - readSet map[string][]byte // cached responses from store - readCacheDirty bool - writeSet map[string]string // to be written to store -} - -// TxnCtxConfig is marshalled and sent on wire and is used to reconstruct Tctx -// on receiver's end. -type TxnCtxConfig struct { - LogFields log.Fields - StorePrefix string -} - -func newCtx(config *TxnCtxConfig) *Tctx { - return &Tctx{ - config: config, - logger: log.StandardLogger().WithFields(config.LogFields), - readSet: make(map[string][]byte), - writeSet: make(map[string]string), - readCacheDirty: true, - } -} - -// NewCtx returns a transaction context from given config -func NewCtx(config *TxnCtxConfig) *Tctx { - return newCtx(config) -} - -// Set attaches the given key-value pair to the context. -// If the key exists, the value will be updated. -func (c *Tctx) Set(key string, value interface{}) error { - - b, err := json.Marshal(value) - if err != nil { - c.logger.WithError(err).WithField("key", key).Error("failed to marshal value") - return err - } - - storeKey := c.config.StorePrefix + key - - // Update the read cache to serve future local Get()s for this key from cache - c.readSet[storeKey] = b - - // Update write cache, the contents of which will be committed to store later - c.writeSet[storeKey] = string(b) - - return nil -} - -// SyncCache synchronizes the locally cached keys and values from the store -func (c *Tctx) SyncCache() error { - resp, err := store.Get(context.TODO(), c.config.StorePrefix, clientv3.WithPrefix()) - if err != nil { - return err - } - - for _, kv := range resp.Kvs { - c.readSet[string(kv.Key)] = kv.Value - } - return nil -} - -// Commit writes all locally cached keys and values into the store using -// a single etcd transaction. -func (c *Tctx) Commit() error { - - if len(c.writeSet) == 0 { - return nil - } - - var putOps []clientv3.Op - for key, value := range c.writeSet { - putOps = append(putOps, clientv3.OpPut(key, value)) - } - - ctx, cancel := context.WithTimeout(context.Background(), etcdTxnTimeout*time.Second) - txn, err := store.Txn(ctx). - If(). - Then(putOps...). - Else(). - Commit() - cancel() - - if err != nil || !txn.Succeeded { - msg := "etcd txn to store txn context keys failed" - if err == nil { - // if txn.Succeeded = false - err = errors.New(msg) - } - c.logger.WithError(err).WithField("keys", - reflect.ValueOf(c.writeSet).MapKeys()).Error(msg) - return err - } - - expTxn.Add("txn_ctx_store_commit", 1) - - c.writeSet = make(map[string]string) - c.readCacheDirty = true - - return nil -} - -// SetNodeResult is similar to Set but prefixes the key with the node UUID -// specified. This function can be used by nodes to store results of -// transaction steps. -func (c *Tctx) SetNodeResult(peerID uuid.UUID, key string, value interface{}) error { - storeKey := peerID.String() + "/" + key - return c.Set(storeKey, value) -} - -// Get gets the value for the given key if available. -// Returns error if not found. -func (c *Tctx) Get(key string, value interface{}) error { - - // cache all keys and values from the store on the first call to Get - if c.readCacheDirty { - if err := c.SyncCache(); err != nil { - c.logger.WithError(err).WithField("key", key).Error("failed to get key from transaction context") - return err - } - c.readCacheDirty = false - } - - // return cached key - storeKey := c.config.StorePrefix + key - if data, ok := c.readSet[storeKey]; ok { - if err := json.Unmarshal(data, value); err != nil { - c.logger.WithError(err).WithField("key", storeKey).Error("failed to unmarshall value") - } - } else { - return errors.New("key not found") - } - - return nil -} - -// GetNodeResult is similar to Get but prefixes the key with node UUID -// specified. This function can be used by the transaction initiator node to -// fetch results of transaction step run on remote nodes. -func (c *Tctx) GetNodeResult(peerID uuid.UUID, key string, value interface{}) error { - storeKey := peerID.String() + "/" + key - return c.Get(storeKey, value) -} - -// GetTxnReqID gets the reqID string saved within the txnCtxConfig. -func (c *Tctx) GetTxnReqID() string { - return c.config.LogFields["reqid"].(string) -} - -// Delete deletes the key and attached value -func (c *Tctx) Delete(key string) error { - - storeKey := c.config.StorePrefix + key - - delete(c.readSet, storeKey) - delete(c.writeSet, storeKey) - - // TODO: Optimize this by doing it as part of etcd txn in commit() - if _, err := store.Delete(context.TODO(), storeKey); err != nil { - c.logger.WithError(err).WithField("key", storeKey).Error( - "failed to delete key") - return err - } - expTxn.Add("txn_ctx_store_delete", 1) - return nil -} - -// Logger returns the Logrus logger associated with the context -func (c *Tctx) Logger() log.FieldLogger { - return c.logger -} - -// MarshalJSON implements the json.Marshaler interface -func (c *Tctx) MarshalJSON() ([]byte, error) { - return json.Marshal(c.config) -} - -// UnmarshalJSON implements the json.Unmarshaler interface -func (c *Tctx) UnmarshalJSON(d []byte) error { - - if err := json.Unmarshal(d, &c.config); err != nil { - return err - } - - *c = *(newCtx(c.config)) - - return nil -} diff --git a/glusterd2/oldtransaction/context_mock.go b/glusterd2/oldtransaction/context_mock.go deleted file mode 100644 index ef6162109..000000000 --- a/glusterd2/oldtransaction/context_mock.go +++ /dev/null @@ -1,62 +0,0 @@ -package oldtransaction - -import ( - "errors" - "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" -) - -// MockTctx implements a dummy context type that can be used in tests -type MockTctx struct { - data map[string]interface{} -} - -// NewMockCtx returns a new instance of MockTctx -func NewMockCtx() *MockTctx { - return &MockTctx{ - data: make(map[string]interface{}), - } -} - -// Set attaches the given key with value to the context. It updates value if key exists already. -func (m *MockTctx) Set(key string, value interface{}) error { - m.data[key] = value - return nil -} - -// SetNodeResult is similar to Set but prefixes the key with the node UUID specified. -func (m *MockTctx) SetNodeResult(peerID uuid.UUID, key string, value interface{}) error { - storeKey := peerID.String() + "/" + key - return m.Set(storeKey, value) -} - -// Get gets the value for the given key. Returns an error if the key is not present -func (m *MockTctx) Get(key string, value interface{}) error { - _, ok := m.data[key] - if !ok { - return errors.New("key not present") - } - return nil -} - -// GetNodeResult is similar to Get but prefixes the key with node UUID specified. -func (m *MockTctx) GetNodeResult(peerID uuid.UUID, key string, value interface{}) error { - storeKey := peerID.String() + "/" + key - return m.Get(storeKey, value) -} - -// Delete deletes the key and value -func (m *MockTctx) Delete(key string) error { - delete(m.data, key) - return nil -} - -// Logger returns a dummy logger -func (m *MockTctx) Logger() log.FieldLogger { - return log.New() -} - -// Prefix returns the prefix to be used for storing values -func (m MockTctx) Prefix() string { - return "mock" -} diff --git a/glusterd2/oldtransaction/lock.go b/glusterd2/oldtransaction/lock.go deleted file mode 100644 index 0a3059775..000000000 --- a/glusterd2/oldtransaction/lock.go +++ /dev/null @@ -1,217 +0,0 @@ -package oldtransaction - -import ( - "context" - "errors" - "time" - - "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/store" - - "github.com/coreos/etcd/clientv3/concurrency" - "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" -) - -const ( - lockPrefix = "locks/" - lockObtainTimeout = 5 * time.Second - lockTTL = 10 -) - -var ( - // ErrLockTimeout is the error returned when lock could not be obtained - // and the request timed out - ErrLockTimeout = errors.New("could not obtain lock: another conflicting transaction may be in progress") - // ErrLockExists is returned when a lock already exists within the transaction - ErrLockExists = errors.New("existing lock found for given lock ID") -) - -// createLockStepFunc returns the registry IDs of StepFuncs which lock/unlock the given key. -// If existing StepFuncs are not found, new funcs are created and registered. -func createLockStepFunc(key string) (string, string, error) { - lockFuncID := key + ".Lock" - unlockFuncID := key + ".Unlock" - - _, lockFuncFound := getStepFunc(lockFuncID) - _, unlockFuncFound := getStepFunc(unlockFuncID) - - if lockFuncFound && unlockFuncFound { - return lockFuncID, unlockFuncID, nil - } - - key = lockPrefix + key - locker := concurrency.NewMutex(store.Store.Session, key) - - lockFunc := func(c TxnCtx) error { - - ctx, cancel := context.WithTimeout(context.Background(), lockObtainTimeout) - defer cancel() - - c.Logger().WithField("key", key).Debug("attempting to lock") - err := locker.Lock(ctx) - switch err { - case nil: - c.Logger().WithField("key", key).Debug("lock obtained") - case context.DeadlineExceeded: - // Propagate this all the way back to the client as a HTTP 409 response - c.Logger().WithField("key", key).Debug("timeout: failed to obtain lock") - err = ErrLockTimeout - } - - return err - } - RegisterStepFunc(lockFunc, lockFuncID) - - unlockFunc := func(c TxnCtx) error { - - c.Logger().WithField("key", key).Debug("attempting to unlock") - err := locker.Unlock(context.Background()) - if err == nil { - c.Logger().WithField("key", key).Debug("lock unlocked") - } - - return err - } - RegisterStepFunc(unlockFunc, unlockFuncID) - - return lockFuncID, unlockFuncID, nil -} - -// CreateLockSteps returns a lock and an unlock Step which lock/unlock the given key -// TODO: Remove this function -func CreateLockSteps(key string) (*Step, *Step, error) { - lockFunc, unlockFunc, err := createLockStepFunc(key) - if err != nil { - return nil, nil, err - } - - lockStep := &Step{DoFunc: lockFunc, UndoFunc: unlockFunc, Nodes: []uuid.UUID{gdctx.MyUUID}, Skip: false} - unlockStep := &Step{DoFunc: unlockFunc, UndoFunc: "", Nodes: []uuid.UUID{gdctx.MyUUID}, Skip: false} - - return lockStep, unlockStep, nil -} - -// LockUnlockFunc is signature of functions used for distributed locking -// and unlocking. -type LockUnlockFunc func(ctx context.Context) error - -// CreateLockFuncs creates and returns functions for distributed lock and -// unlock. This is similar to CreateLockSteps() but returns normal functions. -// TODO: Remove this function -func CreateLockFuncs(key string) (LockUnlockFunc, LockUnlockFunc) { - - key = lockPrefix + key - locker := concurrency.NewMutex(store.Store.Session, key) - - // TODO: There is an opportunity for refactor here to re-use code - // between CreateLockFunc and CreateLockSteps. This variant doesn't - // have registry either. - - lockFunc := func(ctx context.Context) error { - logger := gdctx.GetReqLogger(ctx) - if logger == nil { - logger = log.StandardLogger() - } - - ctx, cancel := context.WithTimeout(ctx, lockObtainTimeout) - defer cancel() - - logger.WithField("key", key).Debug("attempting to lock") - err := locker.Lock(ctx) - switch err { - case nil: - logger.WithField("key", key).Debug("lock obtained") - case context.DeadlineExceeded: - // Propagate this all the way back to the client as a HTTP 409 response - logger.WithField("key", key).Debug("timeout: failed to obtain lock") - err = ErrLockTimeout - } - - return err - } - - unlockFunc := func(ctx context.Context) error { - logger := gdctx.GetReqLogger(ctx) - if logger == nil { - logger = log.StandardLogger() - } - - logger.WithField("key", key).Debug("attempting to unlock") - if err := locker.Unlock(context.Background()); err != nil { - logger.WithField("key", key).WithError(err).Error("unlock failed") - return err - } - - logger.WithField("key", key).Debug("lock unlocked") - return nil - } - - return lockFunc, unlockFunc -} - -// Locks are the collection of cluster wide transaction lock -type Locks map[string]*concurrency.Mutex - -func (l Locks) lock(lockID string) error { - var logger = log.WithField("lockID", lockID) - - // Ensure that no prior lock exists for the given lockID in this transaction - if _, ok := l[lockID]; ok { - return ErrLockExists - } - - logger.Debug("attempting to obtain lock") - - key := lockPrefix + lockID - s, err := concurrency.NewSession(store.Store.NamespaceClient, concurrency.WithTTL(lockTTL)) - if err != nil { - return err - } - - locker := concurrency.NewMutex(s, key) - - ctx, cancel := context.WithTimeout(store.Store.Ctx(), lockObtainTimeout) - defer cancel() - - err = locker.Lock(ctx) - switch err { - case nil: - logger.Debug("lock obtained") - // Attach lock to the transaction - l[lockID] = locker - - case context.DeadlineExceeded: - logger.Debug("timeout: failed to obtain lock") - // Propagate this all the way back to the client as a HTTP 409 response - err = ErrLockTimeout - - default: - logger.WithError(err).Error("failed to obtain lock") - } - - return err -} - -// Lock obtains a cluster wide transaction lock on the given lockID/lockIDs, -// and attaches the obtained locks to the transaction -func (l Locks) Lock(lockID string, lockIDs ...string) error { - if err := l.lock(lockID); err != nil { - return err - } - for _, id := range lockIDs { - if err := l.lock(id); err != nil { - return err - } - } - return nil -} - -// UnLock releases all cluster wide obtained locks -func (l Locks) UnLock(ctx context.Context) { - for lockID, locker := range l { - if err := locker.Unlock(ctx); err == nil { - delete(l, lockID) - } - } -} diff --git a/glusterd2/oldtransaction/registry.go b/glusterd2/oldtransaction/registry.go deleted file mode 100644 index 589829d74..000000000 --- a/glusterd2/oldtransaction/registry.go +++ /dev/null @@ -1,43 +0,0 @@ -package oldtransaction - -// The StepFunc registry registers StepFunc's to be used by transaction framework - -import ( - "sync" - - log "github.com/sirupsen/logrus" -) - -var sfRegistry = struct { - sync.RWMutex - sfMap map[string]StepFunc -}{} - -func registerStepFunc(s StepFunc, name string) { - if sfRegistry.sfMap == nil { - sfRegistry.sfMap = make(map[string]StepFunc) - } - - if _, ok := sfRegistry.sfMap[name]; ok { - log.WithField("stepname", name).Warning("step with provided name exists in registry and will be overwritten") - } - - sfRegistry.sfMap[name] = s -} - -//RegisterStepFunc registers the given StepFunc in the registry -func RegisterStepFunc(s StepFunc, name string) { - sfRegistry.Lock() - defer sfRegistry.Unlock() - - registerStepFunc(s, name) -} - -//getStepFunc returns named step if found. -func getStepFunc(name string) (StepFunc, bool) { - sfRegistry.RLock() - defer sfRegistry.RUnlock() - - s, ok := sfRegistry.sfMap[name] - return s, ok -} diff --git a/glusterd2/oldtransaction/rpc-client.go b/glusterd2/oldtransaction/rpc-client.go deleted file mode 100644 index e10832c93..000000000 --- a/glusterd2/oldtransaction/rpc-client.go +++ /dev/null @@ -1,78 +0,0 @@ -package oldtransaction - -import ( - "context" - "encoding/json" - "errors" - - "github.com/gluster/glusterd2/glusterd2/peer" - "github.com/gluster/glusterd2/pkg/utils" - - "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" - "go.opencensus.io/plugin/ocgrpc" - "google.golang.org/grpc" -) - -// runStepOn will run the step on the specified node -func runStepOn(origCtx context.Context, step string, node uuid.UUID, c TxnCtx) error { - // TODO: I'm creating connections on demand. This should be changed so that - // we have long term connections. - p, err := peer.GetPeerF(node.String()) - if err != nil { - c.Logger().WithError(err).WithField("peerid", node.String()).Error("peer not found") - return err - } - - logger := c.Logger().WithField("remotepeer", p.ID.String()+"("+p.Name+")") - - var conn *grpc.ClientConn - - remote, err := utils.FormRemotePeerAddress(p.PeerAddresses[0]) - if err != nil { - return err - } - - conn, err = grpc.Dial(remote, - grpc.WithStatsHandler(&ocgrpc.ClientHandler{}), - grpc.WithInsecure(), - ) - if err == nil && conn != nil { - logger.WithFields(log.Fields{ - "remote": remote, - }).Debug("connected to remote") - } - - if conn == nil { - logger.WithError(err).WithField("remote", p.PeerAddresses[0]).Error("failed to grpc.Dial remote") - return err - } - defer conn.Close() - - client := NewTxnSvcClient(conn) - - req := &TxnStepReq{ - StepFunc: step, - } - data, err := json.Marshal(c) - if err != nil { - logger.WithError(err).Error("failed to JSON marshal transaction context") - return err - } - req.Context = data - - var rsp *TxnStepResp - - rsp, err = client.RunStep(origCtx, req) - if err != nil { - logger.WithError(err).WithField("rpc", "TxnSvc.RunStep").Error("failed RPC call") - return err - } - - if rsp.Error != "" { - logger.WithError(errors.New(rsp.Error)).Error("TxnSvc.Runstep failed on peer") - return errors.New(rsp.Error) - } - - return nil -} diff --git a/glusterd2/oldtransaction/rpc-service.go b/glusterd2/oldtransaction/rpc-service.go deleted file mode 100644 index 0a93accbb..000000000 --- a/glusterd2/oldtransaction/rpc-service.go +++ /dev/null @@ -1,79 +0,0 @@ -package oldtransaction - -import ( - "context" - "encoding/json" - "errors" - - "github.com/gluster/glusterd2/glusterd2/servers/peerrpc" - - log "github.com/sirupsen/logrus" - "go.opencensus.io/trace" - "google.golang.org/grpc" -) - -type txnSvc int - -func init() { - peerrpc.Register(new(txnSvc)) -} - -// RunStep handles the incoming request. It executes the requested step and returns the results -func (p *txnSvc) RunStep(rpcCtx context.Context, req *TxnStepReq) (*TxnStepResp, error) { - - var ( - resp TxnStepResp - f StepFunc - err error - ok bool - logger log.FieldLogger - ) - - var ctx Tctx - if err = json.Unmarshal(req.Context, &ctx); err != nil { - log.WithError(err).Error("failed to Unmarshal transaction context") - goto End - } - - logger = ctx.Logger().WithField("stepfunc", req.StepFunc) - logger.Debug("RunStep request received") - - if rpcCtx != nil { - _, span := trace.StartSpan(rpcCtx, req.StepFunc) - reqID := ctx.GetTxnReqID() - span.AddAttributes( - trace.StringAttribute("reqID", reqID), - ) - defer span.End() - } - - f, ok = getStepFunc(req.StepFunc) - if !ok { - err = errors.New("step function not found in registry") - goto End - } - - logger.Debug("executing step function") - if err = f(&ctx); err != nil { - logger.WithError(err).Error("step function failed") - goto End - } - - if err = ctx.Commit(); err != nil { - logger.WithError(err).Error("failed to commit txn context to store") - } - -End: - // Ensure RPC will always send a success reply. Error is stored in - // body of response. - if err != nil { - resp.Error = err.Error() - } - - return &resp, nil -} - -// RegisterService registers txnSvc with the given grpc.Server -func (p *txnSvc) RegisterService(s *grpc.Server) { - RegisterTxnSvcServer(s, p) -} diff --git a/glusterd2/oldtransaction/step.go b/glusterd2/oldtransaction/step.go deleted file mode 100644 index 53b71a0f1..000000000 --- a/glusterd2/oldtransaction/step.go +++ /dev/null @@ -1,180 +0,0 @@ -package oldtransaction - -import ( - "context" - "errors" - "fmt" - "net/http" - - "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/pkg/api" - - "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" - "go.opencensus.io/trace" -) - -// StepFunc is the function that is supposed to be run during a transaction step -type StepFunc func(TxnCtx) error - -// Step is a combination of a StepFunc and a list of nodes the step is supposed to be run on -// -// DoFunc and UndoFunc are names of StepFuncs registered in the registry -// DoFunc performs does the action -// UndoFunc undoes anything done by DoFunc -type Step struct { - DoFunc string - UndoFunc string - Nodes []uuid.UUID - Skip bool - Sync bool -} - -var ( - // ErrStepFuncNotFound is returned if the stepfunc isn't found. - ErrStepFuncNotFound = errors.New("stepFunc was not found") -) - -// do runs the DoFunc on the nodes -func (s *Step) do(origCtx context.Context, ctx TxnCtx) error { - return runStepFuncOnNodes(origCtx, s.DoFunc, ctx, s.Nodes) -} - -// undo runs the UndoFunc on the nodes -func (s *Step) undo(ctx TxnCtx) error { - if s.UndoFunc != "" { - return runStepFuncOnNodes(context.TODO(), s.UndoFunc, ctx, s.Nodes) - } - return nil -} - -// stepPeerResp is response from a single peer that runs a step -type stepPeerResp struct { - PeerID uuid.UUID - Error error -} - -// stepResp contains response from multiple peers that run a step and the type -// implements the `api.ErrorResponse` interface -type stepResp struct { - Step string - Resps []stepPeerResp - errCount int -} - -func (r stepResp) Error() string { - return fmt.Sprintf("Step %s failed on %d nodes", r.Step, r.errCount) -} - -func (r stepResp) Response() api.ErrorResp { - - var apiResp api.ErrorResp - for _, resp := range r.Resps { - if resp.Error == nil { - continue - } - - apiResp.Errors = append(apiResp.Errors, api.HTTPError{ - Code: int(api.ErrTxnStepFailed), - Message: api.ErrorCodeMap[api.ErrTxnStepFailed], - Fields: map[string]string{ - "peer-id": resp.PeerID.String(), - "step": r.Step, - "error": resp.Error.Error()}, - }) - } - - return apiResp -} - -func (r stepResp) Status() int { - return http.StatusInternalServerError -} - -func runStepFuncOnNodes(origCtx context.Context, stepName string, ctx TxnCtx, nodes []uuid.UUID) error { - - respCh := make(chan stepPeerResp, len(nodes)) - defer close(respCh) - - for _, node := range nodes { - go runStepFuncOnNode(origCtx, stepName, ctx, node, respCh) - } - - // Ideally, we have to cancel the pending go-routines on first error - // response received from any of the nodes. But that's really tricky - // to do. Serializing sequentially is the easiest fix but we lose - // concurrency. Instead, we let the do() function run on all nodes. - - resp := stepResp{ - Step: stepName, - Resps: make([]stepPeerResp, len(nodes)), - } - - var peerResp stepPeerResp - for range nodes { - peerResp = <-respCh - if peerResp.Error != nil { - resp.errCount++ - ctx.Logger().WithError(peerResp.Error).WithFields(log.Fields{ - "step": stepName, "node": peerResp.PeerID, - }).Error("Step failed on node.") - } - resp.Resps = append(resp.Resps, peerResp) - } - - if resp.errCount != 0 { - return resp - } - - return nil -} - -func runStepFuncOnNode(origCtx context.Context, stepName string, ctx TxnCtx, node uuid.UUID, respCh chan<- stepPeerResp) { - - ctx.Logger().WithFields(log.Fields{ - "step": stepName, "node": node, - }).Debug("Running step on node.") - - var err error - if uuid.Equal(node, gdctx.MyUUID) { - err = traceStep(RunStepFuncLocally)(origCtx, stepName, ctx) - } else { - // remote node - err = runStepOn(origCtx, stepName, node, ctx) - } - - respCh <- stepPeerResp{node, err} -} - -type runFunc func(origCtx context.Context, stepName string, ctx TxnCtx) error - -func traceStep(f runFunc) runFunc { - return func(origCtx context.Context, stepName string, ctx TxnCtx) error { - if origCtx != nil { - _, span := trace.StartSpan(origCtx, stepName) - reqID := ctx.GetTxnReqID() - span.AddAttributes( - trace.StringAttribute("reqID", reqID), - ) - defer span.End() - } - - return f(origCtx, stepName, ctx) - } -} - -// RunStepFuncLocally runs a step func on local node -func RunStepFuncLocally(origCtx context.Context, stepName string, ctx TxnCtx) error { - stepFunc, ok := getStepFunc(stepName) - if !ok { - return ErrStepFuncNotFound - } - - if err := stepFunc(ctx); err != nil { - return err - } - - // if step function executes successfully, commit the - // results to the store - return ctx.Commit() -} diff --git a/glusterd2/oldtransaction/transaction-rpc.pb.go b/glusterd2/oldtransaction/transaction-rpc.pb.go deleted file mode 100644 index a7aae426c..000000000 --- a/glusterd2/oldtransaction/transaction-rpc.pb.go +++ /dev/null @@ -1,205 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: glusterd2/transaction/transaction-rpc.proto - -package oldtransaction - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type TxnStepReq struct { - StepFunc string `protobuf:"bytes,1,opt,name=StepFunc,proto3" json:"StepFunc,omitempty"` - Context []byte `protobuf:"bytes,2,opt,name=Context,proto3" json:"Context,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TxnStepReq) Reset() { *m = TxnStepReq{} } -func (m *TxnStepReq) String() string { return proto.CompactTextString(m) } -func (*TxnStepReq) ProtoMessage() {} -func (*TxnStepReq) Descriptor() ([]byte, []int) { - return fileDescriptor_8c3c13f7a3182c1a, []int{0} -} - -func (m *TxnStepReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TxnStepReq.Unmarshal(m, b) -} -func (m *TxnStepReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TxnStepReq.Marshal(b, m, deterministic) -} -func (m *TxnStepReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_TxnStepReq.Merge(m, src) -} -func (m *TxnStepReq) XXX_Size() int { - return xxx_messageInfo_TxnStepReq.Size(m) -} -func (m *TxnStepReq) XXX_DiscardUnknown() { - xxx_messageInfo_TxnStepReq.DiscardUnknown(m) -} - -var xxx_messageInfo_TxnStepReq proto.InternalMessageInfo - -func (m *TxnStepReq) GetStepFunc() string { - if m != nil { - return m.StepFunc - } - return "" -} - -func (m *TxnStepReq) GetContext() []byte { - if m != nil { - return m.Context - } - return nil -} - -type TxnStepResp struct { - Error string `protobuf:"bytes,1,opt,name=Error,proto3" json:"Error,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TxnStepResp) Reset() { *m = TxnStepResp{} } -func (m *TxnStepResp) String() string { return proto.CompactTextString(m) } -func (*TxnStepResp) ProtoMessage() {} -func (*TxnStepResp) Descriptor() ([]byte, []int) { - return fileDescriptor_8c3c13f7a3182c1a, []int{1} -} - -func (m *TxnStepResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TxnStepResp.Unmarshal(m, b) -} -func (m *TxnStepResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TxnStepResp.Marshal(b, m, deterministic) -} -func (m *TxnStepResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_TxnStepResp.Merge(m, src) -} -func (m *TxnStepResp) XXX_Size() int { - return xxx_messageInfo_TxnStepResp.Size(m) -} -func (m *TxnStepResp) XXX_DiscardUnknown() { - xxx_messageInfo_TxnStepResp.DiscardUnknown(m) -} - -var xxx_messageInfo_TxnStepResp proto.InternalMessageInfo - -func (m *TxnStepResp) GetError() string { - if m != nil { - return m.Error - } - return "" -} - -func init() { - proto.RegisterType((*TxnStepReq)(nil), "transaction.TxnStepReq") - proto.RegisterType((*TxnStepResp)(nil), "transaction.TxnStepResp") -} - -func init() { - proto.RegisterFile("glusterd2/transaction/transaction-rpc.proto", fileDescriptor_8c3c13f7a3182c1a) -} - -var fileDescriptor_8c3c13f7a3182c1a = []byte{ - // 174 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xcf, 0x29, 0x2d, - 0x2e, 0x49, 0x2d, 0x4a, 0x31, 0xd2, 0x2f, 0x29, 0x4a, 0xcc, 0x2b, 0x4e, 0x4c, 0x2e, 0xc9, 0xcc, - 0xcf, 0x43, 0x66, 0xeb, 0x16, 0x15, 0x24, 0xeb, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x71, 0x23, - 0x09, 0x2b, 0x39, 0x71, 0x71, 0x85, 0x54, 0xe4, 0x05, 0x97, 0xa4, 0x16, 0x04, 0xa5, 0x16, 0x0a, - 0x49, 0x71, 0x71, 0x80, 0x98, 0x6e, 0xa5, 0x79, 0xc9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, - 0x70, 0xbe, 0x90, 0x04, 0x17, 0xbb, 0x73, 0x7e, 0x5e, 0x49, 0x6a, 0x45, 0x89, 0x04, 0x93, 0x02, - 0xa3, 0x06, 0x4f, 0x10, 0x8c, 0xab, 0xa4, 0xcc, 0xc5, 0x0d, 0x37, 0xa3, 0xb8, 0x40, 0x48, 0x84, - 0x8b, 0xd5, 0xb5, 0xa8, 0x28, 0xbf, 0x08, 0x6a, 0x02, 0x84, 0x63, 0xe4, 0xc1, 0xc5, 0x06, 0x52, - 0x54, 0x96, 0x2c, 0x64, 0xc7, 0xc5, 0x1e, 0x54, 0x0a, 0x56, 0x2e, 0x24, 0xae, 0x87, 0xe4, 0x16, - 0x3d, 0x84, 0x43, 0xa4, 0x24, 0xb0, 0x4b, 0x14, 0x17, 0x28, 0x31, 0x24, 0xb1, 0x81, 0xbd, 0x61, - 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x69, 0x42, 0xfa, 0xe6, 0xf5, 0x00, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// TxnSvcClient is the client API for TxnSvc service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type TxnSvcClient interface { - RunStep(ctx context.Context, in *TxnStepReq, opts ...grpc.CallOption) (*TxnStepResp, error) -} - -type txnSvcClient struct { - cc *grpc.ClientConn -} - -func NewTxnSvcClient(cc *grpc.ClientConn) TxnSvcClient { - return &txnSvcClient{cc} -} - -func (c *txnSvcClient) RunStep(ctx context.Context, in *TxnStepReq, opts ...grpc.CallOption) (*TxnStepResp, error) { - out := new(TxnStepResp) - err := c.cc.Invoke(ctx, "/transaction.TxnSvc/RunStep", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// TxnSvcServer is the server API for TxnSvc service. -type TxnSvcServer interface { - RunStep(context.Context, *TxnStepReq) (*TxnStepResp, error) -} - -func RegisterTxnSvcServer(s *grpc.Server, srv TxnSvcServer) { - s.RegisterService(&_TxnSvc_serviceDesc, srv) -} - -func _TxnSvc_RunStep_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TxnStepReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TxnSvcServer).RunStep(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/transaction.TxnSvc/RunStep", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TxnSvcServer).RunStep(ctx, req.(*TxnStepReq)) - } - return interceptor(ctx, in, info, handler) -} - -var _TxnSvc_serviceDesc = grpc.ServiceDesc{ - ServiceName: "transaction.TxnSvc", - HandlerType: (*TxnSvcServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "RunStep", - Handler: _TxnSvc_RunStep_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "glusterd2/transaction/transaction-rpc.proto", -} diff --git a/glusterd2/oldtransaction/transaction-rpc.proto b/glusterd2/oldtransaction/transaction-rpc.proto deleted file mode 100644 index c84fafff2..000000000 --- a/glusterd2/oldtransaction/transaction-rpc.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package transaction; - -message TxnStepReq { - string StepFunc = 1; - bytes Context = 2; // Context JSON encoded TxnCtx -} - -message TxnStepResp { - string Error = 1; -} - -service TxnSvc { - rpc RunStep(TxnStepReq) returns(TxnStepResp) {} -} diff --git a/glusterd2/oldtransaction/transaction.go b/glusterd2/oldtransaction/transaction.go deleted file mode 100644 index d29a90086..000000000 --- a/glusterd2/oldtransaction/transaction.go +++ /dev/null @@ -1,194 +0,0 @@ -// Package transaction implements a distributed transaction handling framework -package oldtransaction - -import ( - "context" - "expvar" - "fmt" - - "github.com/gluster/glusterd2/glusterd2/gdctx" - "github.com/gluster/glusterd2/glusterd2/store" - - "github.com/coreos/etcd/clientv3" - "github.com/coreos/etcd/clientv3/concurrency" - "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" -) - -const ( - txnPrefix = "transaction/" -) - -var expTxn = expvar.NewMap("txn") - -// Txn is a set of steps -type Txn struct { - id uuid.UUID - locks Locks - reqID uuid.UUID - storePrefix string - - Ctx TxnCtx - Steps []*Step - DontCheckAlive bool - DisableRollback bool - // Nodes is the union of the all the TxnStep.Nodes and is implicitly - // set in Txn.Do(). This list is used to determine liveness of the - // nodes before running the transaction steps. - Nodes []uuid.UUID - OrigCtx context.Context -} - -// NewTxn returns an initialized Txn without any steps -func NewTxn(ctx context.Context) *Txn { - t := new(Txn) - - t.id = uuid.NewRandom() - t.reqID = gdctx.GetReqID(ctx) - t.locks = make(map[string]*concurrency.Mutex) - t.storePrefix = txnPrefix + t.id.String() + "/" - config := &TxnCtxConfig{ - LogFields: log.Fields{ - "txnid": t.id.String(), - "reqid": t.reqID.String(), - }, - StorePrefix: t.storePrefix, - } - t.Ctx = newCtx(config) - - t.OrigCtx = ctx - t.Ctx.Logger().Debug("new transaction created") - return t -} - -// NewTxnWithLocks returns an empty Txn with locks obtained on given lockIDs -func NewTxnWithLocks(ctx context.Context, lockIDs ...string) (*Txn, error) { - t := NewTxn(ctx) - - for _, id := range lockIDs { - logger := t.Ctx.Logger().WithField("lockID", id) - logger.Debug("attempting to obtain lock") - - if err := t.locks.Lock(id); err != nil { - logger.WithError(err).Error("failed to obtain lock") - t.Done() - return nil, err - } - - logger.Debug("lock obtained") - } - - return t, nil -} - -// Done releases any obtained locks and cleans up the transaction namespace -// Done must be called after a transaction ends -func (t *Txn) Done() { - // Release obtained locks - for _, locker := range t.locks { - locker.Unlock(context.Background()) - } - - // Wipe txn namespace - if _, err := store.Delete(context.TODO(), t.storePrefix, clientv3.WithPrefix()); err != nil { - t.Ctx.Logger().WithError(err).WithField("key", - t.storePrefix).Error("Failed to remove transaction namespace from store") - } - - expTxn.Add("initiated_txn_in_progress", -1) -} - -func (t *Txn) checkAlive() error { - - if len(t.Nodes) == 0 { - for _, s := range t.Steps { - t.Nodes = append(t.Nodes, s.Nodes...) - } - } - t.Nodes = nodesUnion(t.Nodes) - - for _, node := range t.Nodes { - // TODO: Using prefixed query, get all alive nodes in a single etcd query - if _, online := store.Store.IsNodeAlive(node); !online { - return fmt.Errorf("node %s is probably down", node.String()) - } - } - - return nil -} - -// Do runs the transaction on the cluster -func (t *Txn) Do() error { - if !t.DontCheckAlive { - if err := t.checkAlive(); err != nil { - return err - } - } - - t.Ctx.Logger().Debug("Starting transaction") - expTxn.Add("initiated_txn_in_progress", 1) - - // commit txn.Ctx.Set()s done in REST handlers to the store - if err := t.Ctx.Commit(); err != nil { - return err - } - - for i, s := range t.Steps { - if s.Skip { - continue - } - - if err := s.do(t.OrigCtx, t.Ctx); err != nil { - if t.DontCheckAlive && isNodeUnreachable(err) { - continue - } - expTxn.Add("initiated_txn_failure", 1) - if !t.DisableRollback { - t.Ctx.Logger().WithError(err).Error("Transaction failed, rolling back changes") - t.undo(i) - } - return err - } - } - - expTxn.Add("initiated_txn_success", 1) - return nil -} - -func isNodeUnreachable(err error) bool { - unreachable := true - if s, ok := err.(*stepResp); ok { - for _, e := range s.Resps { - if grpc.Code(e.Error) != codes.Unavailable { - unreachable = false - } - } - } - return unreachable -} - -// undo undoes a transaction and will be automatically called by Perform if any step fails. -// The Steps are undone in the reverse order, from the failed step. -func (t *Txn) undo(n int) { - for i := n; i >= 0; i-- { - if t.Steps[i].Skip { - continue - } - t.Steps[i].undo(t.Ctx) - } -} - -// nodesUnion removes duplicate nodes -func nodesUnion(nodes []uuid.UUID) []uuid.UUID { - for i := 0; i < len(nodes); i++ { - for j := i + 1; j < len(nodes); j++ { - if uuid.Equal(nodes[i], nodes[j]) { - nodes = append(nodes[:j], nodes[j+1:]...) - j-- - } - } - } - return nodes -}