Skip to content

Commit

Permalink
rbd: migration of replication controller server
Browse files Browse the repository at this point in the history
this commit migrates the replication controller server
from internal/rbd and adds it to csi-addons.

Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
  • Loading branch information
riya-singhal31 authored and mergify[bot] committed Jun 23, 2023
1 parent cdaa926 commit dbdb908
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
6 changes: 6 additions & 0 deletions internal/csi-addons/rbd/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ type ReplicationServer struct {
*corerbd.ControllerServer
}

// NewReplicationServer creates a new ReplicationServer which handles
// the Replication Service requests from the CSI-Addons specification.
func NewReplicationServer(c *corerbd.ControllerServer) *ReplicationServer {
return &ReplicationServer{ControllerServer: c}
}

func (rs *ReplicationServer) RegisterService(server grpc.ServiceRegistrar) {
replication.RegisterControllerServer(server, rs)
}
Expand Down
28 changes: 8 additions & 20 deletions internal/rbd/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ import (

// Driver contains the default identity,node and controller struct.
type Driver struct {
cd *csicommon.CSIDriver

cd *csicommon.CSIDriver
ids *rbd.IdentityServer
ns *rbd.NodeServer
cs *rbd.ControllerServer
rs *casrbd.ReplicationServer

// cas is the CSIAddonsServer where CSI-Addons services are handled
cas *csiaddons.CSIAddonsServer
Expand Down Expand Up @@ -66,10 +64,6 @@ func NewControllerServer(d *csicommon.CSIDriver) *rbd.ControllerServer {
}
}

func NewReplicationServer(c *rbd.ControllerServer) *casrbd.ReplicationServer {
return &casrbd.ReplicationServer{ControllerServer: c}
}

// NewNodeServer initialize a node server for rbd CSI driver.
func NewNodeServer(
d *csicommon.CSIDriver,
Expand Down Expand Up @@ -105,12 +99,6 @@ func (r *Driver) Run(conf *util.Config) {
// Create instances of the volume and snapshot journal
rbd.InitJournals(conf.InstanceID)

// configre CSI-Addons server and components
err = r.setupCSIAddonsServer(conf)
if err != nil {
log.FatalLogMsg(err.Error())
}

// Initialize default library driver
r.cd = csicommon.NewCSIDriver(conf.DriverName, util.DriverVersion, conf.NodeID)
if r.cd == nil {
Expand Down Expand Up @@ -175,19 +163,19 @@ func (r *Driver) Run(conf *util.Config) {
r.cs = NewControllerServer(r.cd)
r.cs.ClusterName = conf.ClusterName
r.cs.SetMetadata = conf.SetMetadata
log.WarningLogMsg("replication service running on controller server is deprecated " +
"and replaced by CSI-Addons, see https://github.com/ceph/ceph-csi/issues/3314 for more details")
r.rs = NewReplicationServer(r.cs)
}

// configre CSI-Addons server and components
err = r.setupCSIAddonsServer(conf)
if err != nil {
log.FatalLogMsg(err.Error())
}

s := csicommon.NewNonBlockingGRPCServer()
srv := csicommon.Servers{
IS: r.ids,
CS: r.cs,
NS: r.ns,
// Register the replication controller to expose replication
// operations.
RS: r.rs,
}
s.Start(conf.Endpoint, conf.HistogramOption, srv, conf.EnableGRPCMetrics)
if conf.EnableGRPCMetrics {
Expand Down Expand Up @@ -231,7 +219,7 @@ func (r *Driver) setupCSIAddonsServer(conf *util.Config) error {
fcs := casrbd.NewFenceControllerServer()
r.cas.RegisterService(fcs)

rcs := NewReplicationServer(NewControllerServer(r.cd))
rcs := casrbd.NewReplicationServer(NewControllerServer(r.cd))
r.cas.RegisterService(rcs)
}

Expand Down

0 comments on commit dbdb908

Please sign in to comment.