From 33d279a3f23219e4b5f0e49f4f1ac07fcfc5935e Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Fri, 16 Dec 2022 15:14:26 +0300 Subject: [PATCH] [#2152] cli: Do not search for LOCK objects when delete container when session provided Signed-off-by: Anton Nikiforov --- CHANGELOG.md | 1 + cmd/frostfs-cli/modules/container/delete.go | 32 ++++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6df3cbeb..e61567a31 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 b9c959071..1190b48d5 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)) + } } }