From af51bfc561232593f58b2eb44e3b567f74f2c010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Thu, 14 Nov 2024 20:34:54 +0800 Subject: [PATCH] fix(region): shareable virtual resource query (#21596) --- pkg/cloudcommon/db/sharablebase.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/cloudcommon/db/sharablebase.go b/pkg/cloudcommon/db/sharablebase.go index e4f66a4387d..1b0d523342c 100644 --- a/pkg/cloudcommon/db/sharablebase.go +++ b/pkg/cloudcommon/db/sharablebase.go @@ -346,9 +346,17 @@ func SharableManagerFilterByOwner(ctx context.Context, manager IStandaloneModelM )) } if !result.ProjectTags.IsEmpty() && resScope == rbacscope.ScopeProject { + subq := manager.Query("id") policyTagFilters := tagutils.STagFilters{} policyTagFilters.AddFilters(result.ProjectTags) - q = ObjectIdQueryWithTagFilters(ctx, q, "tenant_id", "project", policyTagFilters) + subq = ObjectIdQueryWithTagFilters(ctx, subq, "tenant_id", "project", policyTagFilters) + q = q.Filter(sqlchemy.OR( + sqlchemy.In(q.Field("id"), subq.SubQuery()), + sqlchemy.AND( + sqlchemy.IsTrue(q.Field("is_public")), + sqlchemy.Equals(q.Field("public_scope"), rbacscope.ScopeSystem), + ), + )) } if !result.ObjectTags.IsEmpty() { policyTagFilters := tagutils.STagFilters{}