rbd: add replication capability & service to csiaddons server

csi-addons server will advertise replication capability and
replication service will run with csi-addons server too.

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R 2022-08-15 10:53:50 +05:30 committed by mergify[bot]
parent cb9ec35e3a
commit 19e4146fab
3 changed files with 16 additions and 0 deletions

View File

@ -90,6 +90,12 @@ func (is *IdentityServer) GetCapabilities(
Type: identity.Capability_NetworkFence_NETWORK_FENCE, Type: identity.Capability_NetworkFence_NETWORK_FENCE,
}, },
}, },
}, &identity.Capability{
Type: &identity.Capability_VolumeReplication_{
VolumeReplication: &identity.Capability_VolumeReplication{
Type: identity.Capability_VolumeReplication_VOLUME_REPLICATION,
},
},
}) })
} }

View File

@ -159,6 +159,8 @@ func (r *Driver) Run(conf *util.Config) {
r.cs = NewControllerServer(r.cd) r.cs = NewControllerServer(r.cd)
r.cs.ClusterName = conf.ClusterName r.cs.ClusterName = conf.ClusterName
r.cs.SetMetadata = conf.SetMetadata 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) r.rs = NewReplicationServer(r.cs)
} }
if !conf.IsControllerServer && !conf.IsNodeServer { if !conf.IsControllerServer && !conf.IsNodeServer {
@ -223,6 +225,9 @@ func (r *Driver) setupCSIAddonsServer(conf *util.Config) error {
fcs := casrbd.NewFenceControllerServer() fcs := casrbd.NewFenceControllerServer()
r.cas.RegisterService(fcs) r.cas.RegisterService(fcs)
rcs := NewReplicationServer(NewControllerServer(r.cd))
r.cas.RegisterService(rcs)
} }
if conf.IsNodeServer { if conf.IsNodeServer {

View File

@ -32,6 +32,7 @@ import (
librbd "github.com/ceph/go-ceph/rbd" librbd "github.com/ceph/go-ceph/rbd"
"github.com/ceph/go-ceph/rbd/admin" "github.com/ceph/go-ceph/rbd/admin"
"github.com/csi-addons/spec/lib/go/replication" "github.com/csi-addons/spec/lib/go/replication"
"google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
@ -91,6 +92,10 @@ type ReplicationServer struct {
*ControllerServer *ControllerServer
} }
func (rs *ReplicationServer) RegisterService(server grpc.ServiceRegistrar) {
replication.RegisterControllerServer(server, rs)
}
// getForceOption extracts the force option from the GRPC request parameters. // getForceOption extracts the force option from the GRPC request parameters.
// If not set, the default will be set to false. // If not set, the default will be set to false.
func getForceOption(ctx context.Context, parameters map[string]string) (bool, error) { func getForceOption(ctx context.Context, parameters map[string]string) (bool, error) {