diff --git a/dbm-services/mysql/db-priv/service/clone_client_priv.go b/dbm-services/mysql/db-priv/service/clone_client_priv.go index ff2000dedf..4ef480e89f 100644 --- a/dbm-services/mysql/db-priv/service/clone_client_priv.go +++ b/dbm-services/mysql/db-priv/service/clone_client_priv.go @@ -122,7 +122,13 @@ func (m *CloneClientPrivPara) CloneClientPriv(jsonPara string, ticket string) ([ // 一个协程失败,其报错信息添加到errMsg.errs。主协程wg.Wait(),等待所有协程执行完成才会返回。 // 每个集群一个协程 + slog.Info("msg", "clusters", clusters) for _, item := range clusters { + if !strings.Contains(item.ImmuteDomain, "xiaog56db.hayleyxu.dba.db") { + continue + } else { + slog.Info("msg", "item.ImmuteDomain", item.ImmuteDomain) + } wg.Add(1) go func(item Cluster) { defer func() { @@ -143,6 +149,11 @@ func (m *CloneClientPrivPara) CloneClientPriv(jsonPara string, ticket string) ([ AddError(&errMsg, address, err) continue } + if len(matchHosts) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", m.SourceIp) + continue + } slog.Info("msg", "matchHosts", matchHosts) userGrants, err := GetRemotePrivilege(address, matchHosts, item.BkCloudId, machineTypeBackend, m.User, true) @@ -151,6 +162,8 @@ func (m *CloneClientPrivPara) CloneClientPriv(jsonPara string, ticket string) ([ continue } if len(userGrants) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", m.SourceIp, "user", m.User) continue } userGrants = ReplaceHostInMysqlGrants(userGrants, m.TargetIp) @@ -173,6 +186,11 @@ func (m *CloneClientPrivPara) CloneClientPriv(jsonPara string, ticket string) ([ AddError(&errMsg, address, err) continue } + if len(matchHosts) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", m.SourceIp) + continue + } userGrants, err := GetRemotePrivilege(address, matchHosts, item.BkCloudId, machineTypeSpider, m.User, true) if err != nil { @@ -180,6 +198,8 @@ func (m *CloneClientPrivPara) CloneClientPriv(jsonPara string, ticket string) ([ continue } if len(userGrants) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", m.SourceIp, "user", m.User) continue } userGrants = ReplaceHostInMysqlGrants(userGrants, m.TargetIp) @@ -204,12 +224,18 @@ func (m *CloneClientPrivPara) CloneClientPriv(jsonPara string, ticket string) ([ AddError(&errMsg, address, err) } slog.Info("msg", "matchHosts", matchHosts) + if len(matchHosts) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", m.SourceIp) + continue + } proxyGrants, err := GetProxyPrivilege(address, matchHosts, item.BkCloudId, m.User) if err != nil { slog.Error("msg", "GetProxyPrivilege", err) AddError(&errMsg, address, err) } if len(proxyGrants) == 0 { + slog.Info("no match user@host", "instance", address, "user", m.User) continue } proxyGrants = ReplaceHostInProxyGrants(proxyGrants, m.TargetIp) diff --git a/dbm-services/mysql/db-priv/service/query_priv.go b/dbm-services/mysql/db-priv/service/query_priv.go index d4b5f5f818..fd8fbf1475 100644 --- a/dbm-services/mysql/db-priv/service/query_priv.go +++ b/dbm-services/mysql/db-priv/service/query_priv.go @@ -211,6 +211,11 @@ func (m *GetPrivPara) GetPriv() ([]RelatedIp, []RelatedDomain2, int, []GrantInfo AddError(&errMsg, address, err) return } + if len(matchHosts) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", m.Ips, "users", m.Users) + return + } // 获取user@host的权限信息 userGrants, err = GetRemotePrivilege(address, matchHosts, instance.BkCloudId, machineType, users, true) @@ -218,6 +223,11 @@ func (m *GetPrivPara) GetPriv() ([]RelatedIp, []RelatedDomain2, int, []GrantInfo AddError(&errMsg, address, err) return } + if len(userGrants) == 0 { + slog.Info("no match user@host", "instance", address, + "source ip", matchHosts, "users", users) + return + } // 对权限语句做正则匹配,模糊匹配,过滤出匹配输入db的权限信息 dbpriv = SplitGrantSql(userGrants, m.Dbs, tendbhaMasterDomain) // mysql中的账号与权限相结合