fix/small-object-parts-locking #141

Merged
fyrchik merged 1 commit from carpawell/frostfs-node:fix/small-object-parts-locking into master 2023-03-27 07:28:33 +00:00
2 changed files with 26 additions and 6 deletions

View file

@ -51,6 +51,7 @@ Changelog for FrostFS Node
- Pretty printer of basic ACL in the NeoFS CLI (#2259) - Pretty printer of basic ACL in the NeoFS CLI (#2259)
- Adding of public key for nns group `group.frostfs` at init step (#130) - Adding of public key for nns group `group.frostfs` at init step (#130)
- Iterating over just removed files by FSTree (#98) - Iterating over just removed files by FSTree (#98)
- Parts of a locked object could not be removed anymore (#141)
### Removed ### Removed
### Updated ### Updated

View file

@ -32,16 +32,35 @@ var objectLockCmd = &cobra.Command{
err := cnr.DecodeString(cidRaw) err := cnr.DecodeString(cidRaw)
commonCmd.ExitOnErr(cmd, "Incorrect container arg: %v", err) commonCmd.ExitOnErr(cmd, "Incorrect container arg: %v", err)
key := key.GetOrGenerate(cmd)
cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC)
oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag) oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag)
lockList := make([]oid.ID, len(oidsRaw)) lockList := make([]oid.ID, 0, len(oidsRaw))
oidM := make(map[oid.ID]struct{})
for i := range oidsRaw { for i, oidRaw := range oidsRaw {
err = lockList[i].DecodeString(oidsRaw[i]) var oID oid.ID
err = oID.DecodeString(oidRaw)
commonCmd.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err) commonCmd.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err)
if _, ok := oidM[oID]; ok {
Review

Seems like a separate feature?

Seems like a separate feature?
Review

well, could be considered so. i just imagined some "responsible" user that looks for all the parts of a big object and passes all of them to the object lock cmd. a separate commit for that?

well, could be considered so. i just imagined some "responsible" user that looks for all the parts of a big object and passes all of them to the `object lock` cmd. a separate commit for that?
continue
} }
key := key.GetOrGenerate(cmd) lockList = append(lockList, oID)
oidM[oID] = struct{}{}
for _, relative := range collectObjectRelatives(cmd, cli, cnr, oID) {
if _, ok := oidM[relative]; ok {
continue
}
lockList = append(lockList, relative)
oidM[relative] = struct{}{}
}
}
var idOwner user.ID var idOwner user.ID
user.IDFromKey(&idOwner, key.PublicKey) user.IDFromKey(&idOwner, key.PublicKey)
@ -81,7 +100,7 @@ var objectLockCmd = &cobra.Command{
obj.SetPayload(lock.Marshal()) obj.SetPayload(lock.Marshal())
var prm internalclient.PutObjectPrm var prm internalclient.PutObjectPrm
ReadOrOpenSession(cmd, &prm, key, cnr, nil) ReadOrOpenSessionViaClient(cmd, &prm, cli, key, cnr, nil)
Prepare(cmd, &prm) Prepare(cmd, &prm)
prm.SetHeader(obj) prm.SetHeader(obj)