diff --git a/CHANGELOG.md b/CHANGELOG.md index d6df3cbebe..e61567a318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ Changelog for NeoFS Node - Force object removal via control service (#2145) - Synchronizing a tree now longer reports an error for a single-node container (#2154) - Prevent leaking goroutines in the tree service (#2162) +- Do not search for LOCK objects when delete container when session provided (#2152) ### Removed - `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089) diff --git a/cmd/frostfs-cli/modules/container/delete.go b/cmd/frostfs-cli/modules/container/delete.go index b9c9590711..1190b48d5a 100644 --- a/cmd/frostfs-cli/modules/container/delete.go +++ b/cmd/frostfs-cli/modules/container/delete.go @@ -57,24 +57,28 @@ Only owner of the container has a permission to remove container.`, common.PrintVerbose("Account matches the container owner.") - fs := objectSDK.NewSearchFilters() - fs.AddTypeFilter(objectSDK.MatchStringEqual, objectSDK.TypeLock) + if tok != nil { + common.PrintVerbose("Skip searching for LOCK objects - session provided.") + } else { + fs := objectSDK.NewSearchFilters() + fs.AddTypeFilter(objectSDK.MatchStringEqual, objectSDK.TypeLock) - var searchPrm internalclient.SearchObjectsPrm - searchPrm.SetClient(cli) - searchPrm.SetContainerID(id) - searchPrm.SetFilters(fs) - searchPrm.SetTTL(2) + var searchPrm internalclient.SearchObjectsPrm + searchPrm.SetClient(cli) + searchPrm.SetContainerID(id) + searchPrm.SetFilters(fs) + searchPrm.SetTTL(2) - common.PrintVerbose("Searching for LOCK objects...") + common.PrintVerbose("Searching for LOCK objects...") - res, err := internalclient.SearchObjects(searchPrm) - common.ExitOnErr(cmd, "can't search for LOCK objects: %w", err) + res, err := internalclient.SearchObjects(searchPrm) + common.ExitOnErr(cmd, "can't search for LOCK objects: %w", err) - if len(res.IDList()) != 0 { - common.ExitOnErr(cmd, "", - fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+ - "Use --%s flag to remove anyway.", commonflags.ForceFlag)) + if len(res.IDList()) != 0 { + common.ExitOnErr(cmd, "", + fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+ + "Use --%s flag to remove anyway.", commonflags.ForceFlag)) + } } }