Skip to content

Commit

Permalink
local volume: add options in controller and replica commands
Browse files Browse the repository at this point in the history
Longhorn 3957

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and innobead committed Nov 25, 2022
1 parent 3b1e359 commit f0a9228
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/cmd/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func ControllerCmd() cli.Command {
Hidden: false,
Usage: "In seconds. Timeout between engine and replica(s)",
},
cli.StringFlag{
Name: "data-server-protocol",
Value: "tcp",
Usage: "Specify the data-server protocol. Available options are \"tcp\" and \"unix\"",
},
},
Action: func(c *cli.Context) {
if err := startController(c); err != nil {
Expand Down Expand Up @@ -114,6 +119,8 @@ func startController(c *cli.Context) error {
engineReplicaTimeout = controller.DetermineEngineReplicaTimeout(engineReplicaTimeout)
iscsiTargetRequestTimeout := controller.DetermineIscsiTargetRequestTimeout(engineReplicaTimeout)

dataServerProtocol := c.String("data-server-protocol")

factories := map[string]types.BackendFactory{}
for _, backend := range backends {
switch backend {
Expand All @@ -138,7 +145,7 @@ func startController(c *cli.Context) error {
logrus.Infof("Creating controller %v with iSCSI target request timeout %v and engine to replica(s) timeout %v",
name, iscsiTargetRequestTimeout, engineReplicaTimeout)
control := controller.NewController(name, dynamic.New(factories), frontend, isUpgrade, disableRevCounter, salvageRequested,
iscsiTargetRequestTimeout, engineReplicaTimeout)
iscsiTargetRequestTimeout, engineReplicaTimeout, types.DataServerProtocol(dataServerProtocol))

// need to wait for Shutdown() completion
control.ShutdownWG.Add(1)
Expand Down
18 changes: 16 additions & 2 deletions app/cmd/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/longhorn/longhorn-engine/pkg/backingfile"
"github.com/longhorn/longhorn-engine/pkg/replica"
replicarpc "github.com/longhorn/longhorn-engine/pkg/replica/rpc"
"github.com/longhorn/longhorn-engine/pkg/types"
"github.com/longhorn/longhorn-engine/pkg/util"
diskutil "github.com/longhorn/longhorn-engine/pkg/util/disk"
"github.com/longhorn/longhorn-engine/proto/ptypes"
Expand Down Expand Up @@ -61,6 +62,15 @@ func ReplicaCmd() cli.Command {
Hidden: false,
Usage: "To disable revision counter for every write",
},
cli.StringFlag{
Name: "volume-name",
Value: "",
},
cli.StringFlag{
Name: "data-server-protocol",
Value: "tcp",
Usage: "Specify the data-server protocol. Available options are \"tcp\" and \"unix\"",
},
},
Action: func(c *cli.Context) {
if err := startReplica(c); err != nil {
Expand Down Expand Up @@ -99,7 +109,11 @@ func startReplica(c *cli.Context) error {
}
}

controlAddress, dataAddress, syncAddress, syncPort, err := util.ParseAddresses(address)
volumeName := c.String("volume-name")
dataServerProtocol := c.String("data-server-protocol")

controlAddress, dataAddress, syncAddress, syncPort, err :=
util.GetAddresses(volumeName, address, types.DataServerProtocol(dataServerProtocol))
if err != nil {
return err
}
Expand Down Expand Up @@ -127,7 +141,7 @@ func startReplica(c *cli.Context) error {
}()

go func() {
rpcServer := replicarpc.NewDataServer(dataAddress, s)
rpcServer := replicarpc.NewDataServer(types.DataServerProtocol(dataServerProtocol), dataAddress, s)
logrus.Infof("Listening on data server %s", dataAddress)
err := rpcServer.ListenAndServe()
logrus.Warnf("Replica rest server at %v is down: %v", dataAddress, err)
Expand Down

0 comments on commit f0a9228

Please sign in to comment.