From 01434ed74708c2f6625fea23521144e2e6d13cc2 Mon Sep 17 00:00:00 2001 From: Marina Biryukova Date: Tue, 3 Sep 2024 17:50:51 +0300 Subject: [PATCH] [#482] Fix containers resolving Signed-off-by: Marina Biryukova --- api/resolver/resolver.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/api/resolver/resolver.go b/api/resolver/resolver.go index c394be7..b3f4ac1 100644 --- a/api/resolver/resolver.go +++ b/api/resolver/resolver.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strings" "sync" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware" @@ -212,11 +213,15 @@ func NewNNSResolver(address string, settings Settings) (*Resolver, error) { resolveFunc := func(ctx context.Context, name string) (cid.ID, error) { var d container.Domain - d.SetName(name) + if strings.Contains(name, ".") { + d = parseToDomain(name) + } else { + d.SetName(name) - reqInfo := middleware.GetReqInfo(ctx) - zone, _ := settings.FormContainerZone(reqInfo.Namespace) - d.SetZone(zone) + reqInfo := middleware.GetReqInfo(ctx) + zone, _ := settings.FormContainerZone(reqInfo.Namespace) + d.SetZone(zone) + } cnrID, err := nns.ResolveContainerDomain(d) if err != nil { @@ -230,3 +235,10 @@ func NewNNSResolver(address string, settings Settings) (*Resolver, error) { resolve: resolveFunc, }, nil } + +func parseToDomain(cName string) container.Domain { + domain := container.Domain{} + domain.SetName(strings.Split(cName, ".")[0]) + domain.SetZone(strings.Split(cName, ".")[1]) + return domain +}