Skip to content

Commit

Permalink
rbd: update namespace name in rados object
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Madhu-1 committed Oct 27, 2022
1 parent 5f1149b commit 8cf4250
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/journal/voljournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,3 +864,14 @@ func (conn *Connection) ReserveNewUUIDMapping(ctx context.Context,

return setOMapKeys(ctx, conn, journalPool, cj.namespace, cj.csiDirectory, setKeys)
}

// ResetVolumeOwner update the owner in the rados object.
func (conn *Connection) ResetVolumeOwner(ctx context.Context, pool, reservedUUID, owner string) error {
err := setOMapKeys(ctx, conn, pool, conn.config.namespace, conn.config.cephUUIDDirectoryPrefix+reservedUUID,
map[string]string{conn.config.ownerKey: owner})
if err != nil {
return err
}

return nil
}
6 changes: 6 additions & 0 deletions internal/rbd/rbd_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ func RegenerateJournal(
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
parameters := k8s.PrepareVolumeMetadata(claimName, owner, "")
err = rbdVol.setAllMetadata(parameters)
Expand Down

0 comments on commit 8cf4250

Please sign in to comment.