mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rbd: update namespace name in rados object
If a PV is reattached to a new PVC in a different namespace we need to update the namespace name in the rados object. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
019628c8c2
commit
07aa9dea5c
@ -864,3 +864,9 @@ func (conn *Connection) ReserveNewUUIDMapping(ctx context.Context,
|
|||||||
|
|
||||||
return setOMapKeys(ctx, conn, journalPool, cj.namespace, cj.csiDirectory, setKeys)
|
return setOMapKeys(ctx, conn, journalPool, cj.namespace, cj.csiDirectory, setKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResetVolumeOwner updates the owner in the rados object.
|
||||||
|
func (conn *Connection) ResetVolumeOwner(ctx context.Context, pool, reservedUUID, owner string) error {
|
||||||
|
return setOMapKeys(ctx, conn, pool, conn.config.namespace, conn.config.cephUUIDDirectoryPrefix+reservedUUID,
|
||||||
|
map[string]string{conn.config.ownerKey: owner})
|
||||||
|
}
|
||||||
|
@ -538,7 +538,7 @@ func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credent
|
|||||||
// Generate new volume Handler
|
// Generate new volume Handler
|
||||||
// The volume handler won't remain same as its contains poolID,clusterID etc
|
// The volume handler won't remain same as its contains poolID,clusterID etc
|
||||||
// which are not same across clusters.
|
// which are not same across clusters.
|
||||||
// nolint:gocyclo,cyclop // TODO: reduce complexity
|
// nolint:gocyclo,cyclop,nestif // TODO: reduce complexity
|
||||||
func RegenerateJournal(
|
func RegenerateJournal(
|
||||||
volumeAttributes map[string]string,
|
volumeAttributes map[string]string,
|
||||||
claimName,
|
claimName,
|
||||||
@ -625,6 +625,12 @@ func RegenerateJournal(
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if rbdVol.Owner != owner {
|
||||||
|
err = j.ResetVolumeOwner(ctx, rbdVol.JournalPool, rbdVol.ReservedID, owner)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update Metadata on reattach of the same old PV
|
// Update Metadata on reattach of the same old PV
|
||||||
parameters := k8s.PrepareVolumeMetadata(claimName, owner, "")
|
parameters := k8s.PrepareVolumeMetadata(claimName, owner, "")
|
||||||
err = rbdVol.setAllMetadata(parameters)
|
err = rbdVol.setAllMetadata(parameters)
|
||||||
|
Loading…
Reference in New Issue
Block a user