[#2152] cli: Do not search for LOCK objects when delete container when session provided

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2022-12-16 15:14:26 +03:00 committed by Anton Nikiforov
parent 04b5ec759b
commit 33d279a3f2
2 changed files with 19 additions and 14 deletions

View file

@ -66,6 +66,7 @@ Changelog for NeoFS Node
- Force object removal via control service (#2145) - Force object removal via control service (#2145)
- Synchronizing a tree now longer reports an error for a single-node container (#2154) - Synchronizing a tree now longer reports an error for a single-node container (#2154)
- Prevent leaking goroutines in the tree service (#2162) - Prevent leaking goroutines in the tree service (#2162)
- Do not search for LOCK objects when delete container when session provided (#2152)
### Removed ### Removed
- `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089) - `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089)

View file

@ -57,24 +57,28 @@ Only owner of the container has a permission to remove container.`,
common.PrintVerbose("Account matches the container owner.") common.PrintVerbose("Account matches the container owner.")
fs := objectSDK.NewSearchFilters() if tok != nil {
fs.AddTypeFilter(objectSDK.MatchStringEqual, objectSDK.TypeLock) common.PrintVerbose("Skip searching for LOCK objects - session provided.")
} else {
fs := objectSDK.NewSearchFilters()
fs.AddTypeFilter(objectSDK.MatchStringEqual, objectSDK.TypeLock)
var searchPrm internalclient.SearchObjectsPrm var searchPrm internalclient.SearchObjectsPrm
searchPrm.SetClient(cli) searchPrm.SetClient(cli)
searchPrm.SetContainerID(id) searchPrm.SetContainerID(id)
searchPrm.SetFilters(fs) searchPrm.SetFilters(fs)
searchPrm.SetTTL(2) searchPrm.SetTTL(2)
common.PrintVerbose("Searching for LOCK objects...") common.PrintVerbose("Searching for LOCK objects...")
res, err := internalclient.SearchObjects(searchPrm) res, err := internalclient.SearchObjects(searchPrm)
common.ExitOnErr(cmd, "can't search for LOCK objects: %w", err) common.ExitOnErr(cmd, "can't search for LOCK objects: %w", err)
if len(res.IDList()) != 0 { if len(res.IDList()) != 0 {
common.ExitOnErr(cmd, "", common.ExitOnErr(cmd, "",
fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+ fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+
"Use --%s flag to remove anyway.", commonflags.ForceFlag)) "Use --%s flag to remove anyway.", commonflags.ForceFlag))
}
} }
} }