mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-31 00:59:30 +00:00
csiaddons: use rbd.Manager
for encryption key rotation
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
2dd235849e
commit
6560eee3d8
@ -32,11 +32,15 @@ import (
|
|||||||
|
|
||||||
type EncryptionKeyRotationServer struct {
|
type EncryptionKeyRotationServer struct {
|
||||||
*ekr.UnimplementedEncryptionKeyRotationControllerServer
|
*ekr.UnimplementedEncryptionKeyRotationControllerServer
|
||||||
|
driver string
|
||||||
volLock *util.VolumeLocks
|
volLock *util.VolumeLocks
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEncryptionKeyRotationServer(volLock *util.VolumeLocks) *EncryptionKeyRotationServer {
|
func NewEncryptionKeyRotationServer(driver string, volLock *util.VolumeLocks) *EncryptionKeyRotationServer {
|
||||||
return &EncryptionKeyRotationServer{volLock: volLock}
|
return &EncryptionKeyRotationServer{
|
||||||
|
driver: driver,
|
||||||
|
volLock: volLock,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ekrs *EncryptionKeyRotationServer) RegisterService(svc grpc.ServiceRegistrar) {
|
func (ekrs *EncryptionKeyRotationServer) RegisterService(svc grpc.ServiceRegistrar) {
|
||||||
@ -58,15 +62,10 @@ func (ekrs *EncryptionKeyRotationServer) EncryptionKeyRotate(
|
|||||||
}
|
}
|
||||||
defer ekrs.volLock.Release(volID)
|
defer ekrs.volLock.Release(volID)
|
||||||
|
|
||||||
// Get the credentials required to authenticate
|
mgr := rbd.NewManager(ekrs.driver, nil, req.GetSecrets())
|
||||||
// against a ceph cluster
|
defer mgr.Destroy(ctx)
|
||||||
creds, err := util.NewUserCredentials(req.GetSecrets())
|
|
||||||
if err != nil {
|
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
|
||||||
}
|
|
||||||
defer creds.DeleteCredentials()
|
|
||||||
|
|
||||||
rbdVol, err := rbd.GenVolFromVolID(ctx, volID, creds, req.GetSecrets())
|
rbdVol, err := mgr.GetVolumeByID(ctx, volID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, rbd.ErrImageNotFound):
|
case errors.Is(err, rbd.ErrImageNotFound):
|
||||||
|
@ -249,7 +249,7 @@ func (r *Driver) setupCSIAddonsServer(conf *util.Config) error {
|
|||||||
rs := casrbd.NewReclaimSpaceNodeServer(r.ns.VolumeLocks)
|
rs := casrbd.NewReclaimSpaceNodeServer(r.ns.VolumeLocks)
|
||||||
r.cas.RegisterService(rs)
|
r.cas.RegisterService(rs)
|
||||||
|
|
||||||
ekr := casrbd.NewEncryptionKeyRotationServer(r.ns.VolumeLocks)
|
ekr := casrbd.NewEncryptionKeyRotationServer(conf.InstanceID, r.ns.VolumeLocks)
|
||||||
r.cas.RegisterService(ekr)
|
r.cas.RegisterService(ekr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user