From e4a8573cdd2b2aa080bd3a7fe7bfb3c92eebec92 Mon Sep 17 00:00:00 2001 From: zhengya Date: Wed, 22 May 2024 16:48:03 +0800 Subject: [PATCH] [CONTROLLER/RECORDER] publishes sub_domain id --- .../http/service/resource/domain.go | 2 +- server/controller/recorder/cache/cache.go | 94 ++--- .../recorder/cache/tool/data_set.go | 390 +++++++++--------- server/controller/recorder/cleaner.go | 34 +- server/controller/recorder/common/metadata.go | 8 +- server/controller/recorder/common/org.go | 8 +- .../controller/recorder/db/idmng/manager.go | 22 +- server/controller/recorder/db/operator.go | 36 +- server/controller/recorder/db/pod_node.go | 10 +- server/controller/recorder/db/vm.go | 10 +- server/controller/recorder/domain.go | 38 +- server/controller/recorder/event/common.go | 28 +- server/controller/recorder/event/dhcp_port.go | 2 +- server/controller/recorder/event/host.go | 2 +- server/controller/recorder/event/lan_ip.go | 34 +- server/controller/recorder/event/lb.go | 2 +- server/controller/recorder/event/manager.go | 8 +- .../controller/recorder/event/nat_gateway.go | 2 +- server/controller/recorder/event/pod.go | 10 +- server/controller/recorder/event/pod_node.go | 2 +- .../controller/recorder/event/pod_service.go | 2 +- server/controller/recorder/event/process.go | 4 +- .../controller/recorder/event/rds_instance.go | 2 +- .../recorder/event/redis_instance.go | 2 +- .../controller/recorder/event/sub_domain.go | 6 +- server/controller/recorder/event/vm.go | 2 +- server/controller/recorder/event/vrouter.go | 2 +- server/controller/recorder/event/wan_ip.go | 34 +- .../recorder/pubsub/message/metadata.go | 16 +- server/controller/recorder/pubsub/pubsub.go | 6 +- server/controller/recorder/recorder.go | 2 +- server/controller/recorder/sub_domain.go | 26 +- server/controller/recorder/updater/cen.go | 4 +- .../controller/recorder/updater/dhcp_port.go | 4 +- .../recorder/updater/floating_ip.go | 10 +- server/controller/recorder/updater/lb.go | 2 +- .../recorder/updater/lb_listener.go | 2 +- .../recorder/updater/lb_target_server.go | 8 +- .../recorder/updater/nat_gateway.go | 2 +- .../controller/recorder/updater/nat_rule.go | 4 +- server/controller/recorder/updater/network.go | 4 +- .../recorder/updater/peer_connection.go | 12 +- server/controller/recorder/updater/pod.go | 20 +- .../recorder/updater/pod_cluster.go | 2 +- .../controller/recorder/updater/pod_group.go | 4 +- .../recorder/updater/pod_group_port.go | 4 +- .../recorder/updater/pod_ingress.go | 4 +- .../recorder/updater/pod_ingress_rule.go | 2 +- .../updater/pod_ingress_rule_backend.go | 6 +- .../recorder/updater/pod_namespace.go | 2 +- .../controller/recorder/updater/pod_node.go | 4 +- .../recorder/updater/pod_replica_set.go | 6 +- .../recorder/updater/pod_service.go | 10 +- .../recorder/updater/pod_service_port.go | 2 +- .../recorder/updater/prometheus_target.go | 6 +- .../recorder/updater/rds_instance.go | 2 +- .../recorder/updater/routing_table.go | 2 +- server/controller/recorder/updater/subnet.go | 4 +- server/controller/recorder/updater/updater.go | 13 +- .../controller/recorder/updater/vinterface.go | 6 +- server/controller/recorder/updater/vm.go | 4 +- server/controller/recorder/updater/vrouter.go | 4 +- 62 files changed, 508 insertions(+), 497 deletions(-) diff --git a/server/controller/http/service/resource/domain.go b/server/controller/http/service/resource/domain.go index 9b7f8b80570..91db822889b 100644 --- a/server/controller/http/service/resource/domain.go +++ b/server/controller/http/service/resource/domain.go @@ -649,7 +649,7 @@ func deleteDomain(domain *mysql.Domain, db *mysql.DB, userInfo *svc.UserInfo, cf db.Delete(&domain) // pub to tagrecorder - metadata := message.NewMetadata(db.ORGID, domain.TeamID, domain.ID) + metadata := message.NewMetadata(db.ORGID, domain.TeamID, domain.ID, 0) for _, s := range tagrecorder.GetSubscriberManager().GetSubscribers("domain") { s.OnDomainDeleted(metadata) } diff --git a/server/controller/recorder/cache/cache.go b/server/controller/recorder/cache/cache.go index 7c908aaa107..eaab8f67b8d 100644 --- a/server/controller/recorder/cache/cache.go +++ b/server/controller/recorder/cache/cache.go @@ -70,7 +70,7 @@ func NewCacheManager(ctx context.Context, cfg config.RecorderConfig, md *rcommon func (m *CacheManager) CreateSubDomainCacheIfNotExists(md *rcommon.Metadata) *Cache { if _, exists := m.SubDomainCacheMap[md.SubDomain.Lcuuid]; !exists { - log.Info(m.metadata.LogPre("new subdomain cache (lcuuid: %s) because not exists", md.SubDomain.Lcuuid)) + log.Info(m.metadata.Logf("new subdomain cache (lcuuid: %s) because not exists", md.SubDomain.Lcuuid)) m.SubDomainCacheMap[md.SubDomain.Lcuuid] = NewCache(m.ctx, md, m.cacheSetSelfHealInterval) } return m.SubDomainCacheMap[md.SubDomain.Lcuuid] @@ -160,13 +160,13 @@ const ( ) func (c *Cache) ResetRefreshSignal(caller string) { - log.Info(c.metadata.LogPre("domain: %s reset cache refresh signal (caller: %s)", c.metadata.Domain.Lcuuid, caller)) + log.Info(c.metadata.Logf("domain: %s reset cache refresh signal (caller: %s)", c.metadata.Domain.Lcuuid, caller)) c.RefreshSignal <- struct{}{} } func (c *Cache) StartSelfHealing() { go func() { - log.Info(c.metadata.LogPre("recorder cache self heal started")) + log.Info(c.metadata.Logf("recorder cache self heal started")) c.ResetRefreshSignal(RefreshSignalCallerSelfHeal) c.TryRefresh() @@ -182,7 +182,7 @@ func (c *Cache) StartSelfHealing() { break LOOP } } - log.Info(c.metadata.LogPre("recorder cache self heal completed")) + log.Info(c.metadata.Logf("recorder cache self heal completed")) }() } @@ -192,7 +192,7 @@ func (c *Cache) TryRefresh() bool { c.Refresh() return true default: - log.Warning(c.metadata.LogPre("last cache refresh not completed now")) + log.Warning(c.metadata.Logf("last cache refresh not completed now")) return false } @@ -281,7 +281,7 @@ func (c *Cache) DeleteRegions(lcuuids []string) { } func (c *Cache) refreshRegions() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_REGION_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_REGION_EN))) var regions []*mysql.Region // 使用az获取domain关联的region数据,排除“系统默认”region @@ -331,7 +331,7 @@ func (c *Cache) DeleteAZs(lcuuids []string) { } func (c *Cache) refreshAZs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_AZ_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_AZ_EN))) var azs []*mysql.AZ err := c.metadata.DB.Where(c.getConditonDomainCreateMethod()).Find(&azs).Error @@ -364,7 +364,7 @@ func (c *Cache) DeleteSubDomains(lcuuids []string) { } func (c *Cache) refreshSubDomains() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_SUB_DOMAIN_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_SUB_DOMAIN_EN))) var subDomains []*mysql.SubDomain err := c.metadata.DB.Where(c.getConditonDomainCreateMethod()).Find(&subDomains).Error @@ -403,7 +403,7 @@ func (c *Cache) UpdateHost(cloudItem *cloudmodel.Host) { } func (c *Cache) refreshHosts() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_HOST_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_HOST_EN))) var hosts []*mysql.Host err := c.metadata.DB.Where( @@ -451,7 +451,7 @@ func (c *Cache) DeleteVMs(lcuuids []string) { } func (c *Cache) refreshVMs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_VM_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_VM_EN))) var vms []*mysql.VM err := c.metadata.DB.Where(c.getConditonDomainCreateMethod()).Find(&vms).Error @@ -478,7 +478,7 @@ func (c *Cache) DeleteVPCs(lcuuids []string) { } func (c *Cache) refreshVPCs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_VPC_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_VPC_EN))) var vpcs []*mysql.VPC err := c.metadata.DB.Where(c.getConditonDomainCreateMethod()).Find(&vpcs).Error @@ -513,7 +513,7 @@ func (c *Cache) DeleteNetworks(lcuuids []string) { } func (c *Cache) refreshNetworks() []int { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN))) var networks []*mysql.Network networkIDs := []int{} @@ -554,7 +554,7 @@ func (c *Cache) DeleteSubnets(lcuuids []string) { } func (c *Cache) refreshSubnets(networkIDs []int) { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN))) var subnets []*mysql.Subnet err := c.metadata.DB.Where(map[string]interface{}{"vl2id": networkIDs}).Find(&subnets).Error @@ -589,7 +589,7 @@ func (c *Cache) DeleteVRouters(lcuuids []string) { } func (c *Cache) refreshVRouters() []int { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN))) var vrouters []*mysql.VRouter vrouterIDs := []int{} @@ -619,7 +619,7 @@ func (c *Cache) DeleteRoutingTables(lcuuids []string) { } func (c *Cache) refreshRoutingTables(vrouterIDs []int) { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_ROUTING_TABLE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_ROUTING_TABLE_EN))) var routingTables []*mysql.RoutingTable err := c.metadata.DB.Where(map[string]interface{}{"vnet_id": vrouterIDs}).Find(&routingTables).Error @@ -650,7 +650,7 @@ func (c *Cache) DeleteDHCPPorts(lcuuids []string) { } func (c *Cache) refreshDHCPPorts() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN))) var dhcpPorts []*mysql.DHCPPort err := c.metadata.DB.Where(c.getConditionDomain()).Find(&dhcpPorts).Error @@ -681,7 +681,7 @@ func (c *Cache) DeleteVInterfaces(lcuuids []string) { } func (c *Cache) refreshVInterfaces() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN))) var vifs []*mysql.VInterface err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL) AND create_method = ?", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid, ctrlrcommon.CREATE_METHOD_LEARN).Find(&vifs).Error @@ -708,7 +708,7 @@ func (c *Cache) DeleteWANIPs(lcuuids []string) { } func (c *Cache) refreshWANIPs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN))) var wanIPs []*mysql.WANIP err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&wanIPs).Error @@ -735,7 +735,7 @@ func (c *Cache) DeleteLANIPs(lcuuids []string) { } func (c *Cache) refreshLANIPs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN))) var lanIPs []*mysql.LANIP err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&lanIPs).Error @@ -760,7 +760,7 @@ func (c *Cache) DeleteFloatingIPs(lcuuids []string) { } func (c *Cache) refreshFloatingIPs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN))) var floatingIPs []*mysql.FloatingIP err := c.metadata.DB.Where(c.getConditionDomain()).Find(&floatingIPs).Error @@ -791,7 +791,7 @@ func (c *Cache) DeleteNATGateways(lcuuids []string) { } func (c *Cache) refreshNATGateways() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN))) var natGateways []*mysql.NATGateway err := c.metadata.DB.Where(c.getConditionDomain()).Find(&natGateways).Error @@ -816,7 +816,7 @@ func (c *Cache) DeleteNATVMConnections(lcuuids []string) { } func (c *Cache) refreshNATVMConnections() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_NAT_VM_CONNECTION_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_NAT_VM_CONNECTION_EN))) var natVMConnections []*mysql.NATVMConnection err := c.metadata.DB.Where(c.getConditionDomain()).Find(&natVMConnections).Error @@ -841,7 +841,7 @@ func (c *Cache) DeleteNATRules(lcuuids []string) { } func (c *Cache) refreshNATRules() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_NAT_RULE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_NAT_RULE_EN))) var natRules []*mysql.NATRule err := c.metadata.DB.Where(c.getConditionDomain()).Find(&natRules).Error @@ -872,7 +872,7 @@ func (c *Cache) DeleteLBs(lcuuids []string) { } func (c *Cache) refreshLBs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_EN))) var lbs []*mysql.LB err := c.metadata.DB.Where(c.getConditionDomain()).Find(&lbs).Error @@ -897,7 +897,7 @@ func (c *Cache) DeleteLBVMConnections(lcuuids []string) { } func (c *Cache) refreshLBVMConnections() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_VM_CONNECTION_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_VM_CONNECTION_EN))) var lbVMConnections []*mysql.LBVMConnection err := c.metadata.DB.Where(c.getConditionDomain()).Find(&lbVMConnections).Error @@ -924,7 +924,7 @@ func (c *Cache) DeleteLBListeners(lcuuids []string) { } func (c *Cache) refreshLBListeners() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN))) var listeners []*mysql.LBListener err := c.metadata.DB.Where(c.getConditionDomain()).Find(&listeners).Error @@ -949,7 +949,7 @@ func (c *Cache) DeleteLBTargetServers(lcuuids []string) { } func (c *Cache) refreshLBTargetServers() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_TARGET_SERVER_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_LB_TARGET_SERVER_EN))) var servers []*mysql.LBTargetServer err := c.metadata.DB.Where(c.getConditionDomain()).Find(&servers).Error @@ -974,7 +974,7 @@ func (c *Cache) DeletePeerConnections(lcuuids []string) { } func (c *Cache) refreshPeeConnections() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN))) var peerConnections []*mysql.PeerConnection err := c.metadata.DB.Where(c.getConditonDomainCreateMethod()).Find(&peerConnections).Error @@ -999,7 +999,7 @@ func (c *Cache) DeleteCENs(lcuuids []string) { } func (c *Cache) refreshCENs() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_CEN_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_CEN_EN))) var cens []*mysql.CEN err := c.metadata.DB.Where(c.getConditionDomain()).Find(&cens).Error @@ -1030,7 +1030,7 @@ func (c *Cache) DeleteRDSInstances(lcuuids []string) { } func (c *Cache) refreshRDSInstances() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN))) var instances []*mysql.RDSInstance err := c.metadata.DB.Where(c.getConditionDomain()).Find(&instances).Error @@ -1061,7 +1061,7 @@ func (c *Cache) DeleteRedisInstances(lcuuids []string) { } func (c *Cache) refreshRedisInstances() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN))) var instances []*mysql.RedisInstance err := c.metadata.DB.Where(c.getConditionDomain()).Find(&instances).Error @@ -1088,7 +1088,7 @@ func (c *Cache) DeletePodClusters(lcuuids []string) { } func (c *Cache) refreshPodClusters() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN))) var podClusters []*mysql.PodCluster err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&podClusters).Error @@ -1119,7 +1119,7 @@ func (c *Cache) DeletePodNodes(lcuuids []string) { } func (c *Cache) refreshPodNodes() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN))) var podNodes []*mysql.PodNode err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&podNodes).Error @@ -1144,7 +1144,7 @@ func (c *Cache) DeleteVMPodNodeConnections(lcuuids []string) { } func (c *Cache) refreshVMPodNodeConnections() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN))) var connections []*mysql.VMPodNodeConnection err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&connections).Error @@ -1171,7 +1171,7 @@ func (c *Cache) DeletePodNamespaces(lcuuids []string) { } func (c *Cache) refreshPodNamespaces() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN))) var podNamespaces []*mysql.PodNamespace err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&podNamespaces).Error @@ -1202,7 +1202,7 @@ func (c *Cache) DeletePodIngresses(lcuuids []string) { } func (c *Cache) refreshPodIngresses() []int { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN))) var podIngresses []*mysql.PodIngress podIngressIDs := []int{} @@ -1234,7 +1234,7 @@ func (c *Cache) DeletePodIngressRules(lcuuids []string) { } func (c *Cache) refreshPodIngressRules(podIngressIDs []int) { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN))) if len(podIngressIDs) == 0 { return } @@ -1262,7 +1262,7 @@ func (c *Cache) DeletePodIngressRuleBackends(lcuuids []string) { } func (c *Cache) refreshPodIngresseRuleBackends(podIngressIDs []int) { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN))) if len(podIngressIDs) == 0 { return } @@ -1300,7 +1300,7 @@ func (c *Cache) DeletePodServices(lcuuids []string) { } func (c *Cache) refreshPodServices() []int { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN))) var podServices []*mysql.PodService podServiceIDs := []int{} @@ -1330,7 +1330,7 @@ func (c *Cache) DeletePodServicePorts(lcuuids []string) { } func (c *Cache) refreshPodServicePorts(podServiceIDs []int) { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_PORT_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_PORT_EN))) if len(podServiceIDs) == 0 { return } @@ -1360,7 +1360,7 @@ func (c *Cache) DeletePodGroups(lcuuids []string) { } func (c *Cache) refreshPodGroups() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN))) var podGroups []*mysql.PodGroup err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&podGroups).Error @@ -1385,7 +1385,7 @@ func (c *Cache) DeletePodGroupPorts(lcuuids []string) { } func (c *Cache) refreshPodGroupPorts(podServiceIDs []int) { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_PORT_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_PORT_EN))) if len(podServiceIDs) == 0 { return } @@ -1415,7 +1415,7 @@ func (c *Cache) DeletePodReplicaSets(lcuuids []string) { } func (c *Cache) refreshPodReplicaSets() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN))) var podReplicaSets []*mysql.PodReplicaSet err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&podReplicaSets).Error @@ -1446,7 +1446,7 @@ func (c *Cache) DeletePods(lcuuids []string) { } func (c *Cache) refreshPods() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_POD_EN))) var pods []*mysql.Pod err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid).Find(&pods).Error @@ -1473,7 +1473,7 @@ func (c *Cache) DeleteProcesses(lcuuids []string) { } func (c *Cache) refreshProcesses() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN))) var processes []*mysql.Process processes, err := query.FindInBatches[mysql.Process](c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL)", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid)) if err != nil { @@ -1497,7 +1497,7 @@ func (c *Cache) DeletePrometheusTargets(lcuuids []string) { } func (c *Cache) refreshPrometheusTarget() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_PROMETHEUS_TARGET_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_PROMETHEUS_TARGET_EN))) var prometheusTargets []*mysql.PrometheusTarget if err := c.metadata.DB.Where("domain = ? AND (sub_domain = ? OR sub_domain IS NULL) AND create_method = ?", c.metadata.Domain.Lcuuid, c.metadata.SubDomain.Lcuuid, ctrlrcommon.PROMETHEUS_TARGET_CREATE_METHOD_RECORDER).Find(&prometheusTargets).Error; err != nil { log.Error(dbQueryResourceFailed(ctrlrcommon.RESOURCE_TYPE_PROMETHEUS_TARGET_EN, err)) @@ -1520,7 +1520,7 @@ func (c *Cache) DeleteVIPs(lcuuids []string) { } func (c *Cache) refreshVIP() { - log.Info(c.metadata.LogPre(refreshResource(ctrlrcommon.RESOURCE_TYPE_VIP_EN))) + log.Info(c.metadata.Logf(refreshResource(ctrlrcommon.RESOURCE_TYPE_VIP_EN))) var vips []*mysql.VIP if err := c.metadata.DB.Where("domain = ?", c.metadata.Domain.Lcuuid).Find(&vips).Error; err != nil { log.Error(dbQueryResourceFailed(ctrlrcommon.RESOURCE_TYPE_VIP_EN, err)) diff --git a/server/controller/recorder/cache/tool/data_set.go b/server/controller/recorder/cache/tool/data_set.go index 54ab25240f4..551ac9b9355 100644 --- a/server/controller/recorder/cache/tool/data_set.go +++ b/server/controller/recorder/cache/tool/data_set.go @@ -185,12 +185,12 @@ func (t *DataSet) GetMetadata() *rcommon.Metadata { func (t *DataSet) AddAZ(item *mysql.AZ) { t.azLcuuidToID[item.Lcuuid] = item.ID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_AZ_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_AZ_EN, item.Lcuuid))) } func (t *DataSet) DeleteAZ(lcuuid string) { delete(t.azLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_AZ_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_AZ_EN, lcuuid))) } func (t *DataSet) GetAZIDByLcuuid(lcuuid string) (int, bool) { @@ -198,14 +198,14 @@ func (t *DataSet) GetAZIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_AZ_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_AZ_EN, lcuuid))) var az mysql.AZ result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&az) if result.RowsAffected == 1 { t.AddAZ(&az) return az.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_AZ_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_AZ_EN, lcuuid))) return id, false } } @@ -213,14 +213,14 @@ func (t *DataSet) GetAZIDByLcuuid(lcuuid string) (int, bool) { func (t *DataSet) AddRegion(item *mysql.Region) { t.regionLcuuidToID[item.Lcuuid] = item.ID t.regionIDToLcuuid[item.ID] = item.Lcuuid - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_REGION_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_REGION_EN, item.Lcuuid))) } func (t *DataSet) DeleteRegion(lcuuid string) { delete(t.regionLcuuidToID, lcuuid) id, _ := t.GetRegionIDByLcuuid(lcuuid) delete(t.regionIDToLcuuid, id) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) } func (t *DataSet) AddHost(item *mysql.Host) { @@ -233,18 +233,18 @@ func (t *DataSet) AddHost(item *mysql.Host) { if azID, ok := t.GetAZIDByLcuuid(item.AZ); ok { t.hostIDtoInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_HOST_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_HOST_EN, item.Lcuuid))) } func (t *DataSet) DeleteHost(lcuuid string) { id, _ := t.GetHostIDByLcuuid(lcuuid) delete(t.hostIDtoInfo, id) delete(t.hostLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_HOST_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_HOST_EN, lcuuid))) } func (t *DataSet) UpdateHost(cloudItem *cloudmodel.Host) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_HOST_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_HOST_EN, cloudItem.Lcuuid))) id, _ := t.GetHostIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetHostInfoByID(id) if err != nil { @@ -277,11 +277,11 @@ func (t *DataSet) AddVM(item *mysql.VM) { t.vmIDToInfo[item.ID].HostID = hostID } } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VM_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VM_EN, item.Lcuuid))) } func (t *DataSet) UpdateVM(cloudItem *cloudmodel.VM) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_VM_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_VM_EN, cloudItem.Lcuuid))) id, _ := t.GetVMIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetVMInfoByID(id) if err != nil { @@ -309,27 +309,27 @@ func (t *DataSet) DeleteVM(lcuuid string) { delete(t.vmIDToIPNetworkIDMap, id) delete(t.vmLcuuidToID, lcuuid) delete(t.vmIDToInfo, id) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuid))) } func (t *DataSet) AddVPC(item *mysql.VPC) { t.vpcLcuuidToID[item.Lcuuid] = item.ID t.vpcIDToLcuuid[item.ID] = item.Lcuuid - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VPC_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VPC_EN, item.Lcuuid))) } func (t *DataSet) DeleteVPC(lcuuid string) { id, _ := t.GetVPCIDByLcuuid(lcuuid) delete(t.vpcIDToLcuuid, id) delete(t.vpcLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VPC_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VPC_EN, lcuuid))) } func (t *DataSet) AddNetwork(item *mysql.Network) { t.networkLcuuidToID[item.Lcuuid] = item.ID t.networkIDToLcuuid[item.ID] = item.Lcuuid t.networkIDToName[item.ID] = item.Name - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, item.Lcuuid))) } func (t *DataSet) UpdateNetwork(cloudItem *cloudmodel.Network) { @@ -337,7 +337,7 @@ func (t *DataSet) UpdateNetwork(cloudItem *cloudmodel.Network) { if exists { t.networkIDToName[id] = cloudItem.Name } - log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.Lcuuid))) + log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.Lcuuid))) } func (t *DataSet) DeleteNetwork(lcuuid string) { @@ -345,20 +345,20 @@ func (t *DataSet) DeleteNetwork(lcuuid string) { delete(t.networkIDToLcuuid, id) delete(t.networkIDToName, id) delete(t.networkLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, lcuuid))) } func (t *DataSet) AddSubnet(item *mysql.Subnet) { t.subnetLcuuidToID[item.Lcuuid] = item.ID t.subnetIDToLcuuid[item.ID] = item.Lcuuid - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, item.Lcuuid))) } func (t *DataSet) DeleteSubnet(lcuuid string) { id, _ := t.GetSubnetIDByLcuuid(lcuuid) delete(t.subnetIDToLcuuid, id) delete(t.subnetLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, lcuuid))) } func (t *DataSet) AddVRouter(item *mysql.VRouter) { @@ -371,11 +371,11 @@ func (t *DataSet) AddVRouter(item *mysql.VRouter) { if regionID, ok := t.GetRegionIDByLcuuid(item.Region); ok { t.vrouterIDToInfo[item.ID].RegionID = regionID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, item.Lcuuid))) } func (t *DataSet) UpdateVRouter(cloudItem *cloudmodel.VRouter) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, cloudItem.Lcuuid))) id, _ := t.GetVRouterIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetVRouterInfoByID(id) if err != nil { @@ -396,7 +396,7 @@ func (t *DataSet) DeleteVRouter(lcuuid string) { id, _ := t.GetVRouterIDByLcuuid(lcuuid) delete(t.vrouterIDToInfo, id) delete(t.vrouterLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, lcuuid))) } func (t *DataSet) AddDHCPPort(item *mysql.DHCPPort) { @@ -411,11 +411,11 @@ func (t *DataSet) AddDHCPPort(item *mysql.DHCPPort) { if azID, ok := t.GetAZIDByLcuuid(item.AZ); ok { t.dhcpPortIDToInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, item.Lcuuid))) } func (t *DataSet) UpdateDHCPPort(cloudItem *cloudmodel.DHCPPort) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, cloudItem.Lcuuid))) id, _ := t.GetDHCPPortIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetDHCPPortInfoByID(id) if err != nil { @@ -438,7 +438,7 @@ func (t *DataSet) DeleteDHCPPort(lcuuid string) { id, _ := t.GetDHCPPortIDByLcuuid(lcuuid) delete(t.dhcpPortIDToInfo, id) delete(t.dhcpPortLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))) } func (t *DataSet) AddVInterface(item *mysql.VInterface) { @@ -451,12 +451,12 @@ func (t *DataSet) AddVInterface(item *mysql.VInterface) { t.vinterfaceLcuuidToIndex[item.Lcuuid] = item.Index t.vinterfaceLcuuidToType[item.Lcuuid] = item.Type - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, item.Lcuuid))) } func (t *DataSet) UpdateVInterface(cloudItem *cloudmodel.VInterface) { t.vinterfaceLcuuidToType[cloudItem.Lcuuid] = cloudItem.Type - log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid))) + log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid))) } func (t *DataSet) DeleteVInterface(lcuuid string) { @@ -469,7 +469,7 @@ func (t *DataSet) DeleteVInterface(lcuuid string) { delete(t.vinterfaceLcuuidToMac, lcuuid) delete(t.vinterfaceLcuuidToIndex, lcuuid) delete(t.vinterfaceLcuuidToType, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) } func (t *DataSet) AddWANIP(item *mysql.WANIP) { @@ -481,7 +481,7 @@ func (t *DataSet) AddWANIP(item *mysql.WANIP) { mac, _ := t.GetMacByVInterfaceLcuuid(vifLcuuid) networkID, _ := t.GetNetworkIDByVInterfaceLcuuid(vifLcuuid) t.setDeviceToIPNetworkMap(deviceType, deviceID, networkID, IPKey{IP: item.IP, Mac: mac, Lcuuid: item.Lcuuid}) - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, item.Lcuuid))) } func (t *DataSet) DeleteWANIP(lcuuid string) { @@ -495,7 +495,7 @@ func (t *DataSet) DeleteWANIP(lcuuid string) { t.DeleteDeviceToIPNetworkMapIP(deviceType, deviceID, networkID, IPKey{IP: ip, Mac: mac, Lcuuid: lcuuid}) delete(t.wanIPLcuuidToVInterfaceID, lcuuid) delete(t.wanIPLcuuidToIP, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) } func (t *DataSet) AddLANIP(item *mysql.LANIP) { @@ -507,7 +507,7 @@ func (t *DataSet) AddLANIP(item *mysql.LANIP) { deviceID, _ := t.GetDeviceIDByVInterfaceLcuuid(vifLcuuid) networkID, _ := t.GetNetworkIDByVInterfaceLcuuid(vifLcuuid) t.setDeviceToIPNetworkMap(deviceType, deviceID, networkID, IPKey{IP: item.IP, Mac: mac, Lcuuid: item.Lcuuid}) - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, item.Lcuuid))) } func (t *DataSet) DeleteLANIP(lcuuid string) { @@ -521,17 +521,17 @@ func (t *DataSet) DeleteLANIP(lcuuid string) { t.DeleteDeviceToIPNetworkMapIP(deviceType, deviceID, networkID, IPKey{IP: ip, Mac: mac, Lcuuid: lcuuid}) delete(t.lanIPLcuuidToVInterfaceID, lcuuid) delete(t.lanIPLcuuidToIP, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) } func (t *DataSet) AddSecurityGroup(item *mysql.SecurityGroup) { t.securityGroupLcuuidToID[item.Lcuuid] = item.ID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, item.Lcuuid))) } func (t *DataSet) DeleteSecurityGroup(lcuuid string) { delete(t.securityGroupLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, lcuuid))) } func (t *DataSet) AddNATGateway(item *mysql.NATGateway) { @@ -546,11 +546,11 @@ func (t *DataSet) AddNATGateway(item *mysql.NATGateway) { if azID, ok := t.azLcuuidToID[item.AZ]; ok { t.natGatewayIDToInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, item.Lcuuid))) } func (t *DataSet) UpdateNATGateway(cloudItem *cloudmodel.NATGateway) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, cloudItem.Lcuuid))) id, _ := t.GetNATGatewayIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetNATGatewayInfoByID(id) if err != nil { @@ -570,7 +570,7 @@ func (t *DataSet) DeleteNATGateway(lcuuid string) { id, _ := t.GetNATGatewayIDByLcuuid(lcuuid) delete(t.natGatewayIDToInfo, id) delete(t.natGatewayLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, lcuuid))) } func (t *DataSet) AddLB(item *mysql.LB) { @@ -582,11 +582,11 @@ func (t *DataSet) AddLB(item *mysql.LB) { if regionID, ok := t.GetRegionIDByLcuuid(item.Region); ok { t.lbIDToInfo[item.ID].RegionID = regionID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_LB_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_LB_EN, item.Lcuuid))) } func (t *DataSet) UpdateLB(cloudItem *cloudmodel.LB) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_LB_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_LB_EN, cloudItem.Lcuuid))) id, _ := t.GetLBIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetLBInfoByID(id) if err != nil { @@ -606,17 +606,17 @@ func (t *DataSet) DeleteLB(lcuuid string) { id, _ := t.GetLBIDByLcuuid(lcuuid) delete(t.lbIDToInfo, id) delete(t.lbLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_LB_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_LB_EN, lcuuid))) } func (t *DataSet) AddLBListener(item *mysql.LBListener) { t.lbListenerLcuuidToID[item.Lcuuid] = item.ID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, item.Lcuuid))) } func (t *DataSet) DeleteLBListener(lcuuid string) { delete(t.lbListenerLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, lcuuid))) } func (t *DataSet) AddRDSInstance(item *mysql.RDSInstance) { @@ -631,11 +631,11 @@ func (t *DataSet) AddRDSInstance(item *mysql.RDSInstance) { if azID, ok := t.GetAZIDByLcuuid(item.AZ); ok { t.rdsInstanceIDToInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, item.Lcuuid))) } func (t *DataSet) UpdateRDSInstance(cloudItem *cloudmodel.RDSInstance) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, cloudItem.Lcuuid))) id, _ := t.GetRDSInstanceIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetRDSInstanceInfoByID(id) if err != nil { @@ -658,7 +658,7 @@ func (t *DataSet) DeleteRDSInstance(lcuuid string) { id, _ := t.GetRDSInstanceIDByLcuuid(lcuuid) delete(t.rdsInstanceIDToInfo, id) delete(t.rdsInstanceLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, lcuuid))) } func (t *DataSet) AddRedisInstance(item *mysql.RedisInstance) { @@ -673,11 +673,11 @@ func (t *DataSet) AddRedisInstance(item *mysql.RedisInstance) { if azID, ok := t.GetAZIDByLcuuid(item.AZ); ok { t.redisInstanceIDToInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, item.Lcuuid))) } func (t *DataSet) UpdateRedisInstance(cloudItem *cloudmodel.RedisInstance) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, cloudItem.Lcuuid))) id, _ := t.GetRedisInstanceIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetRedisInstanceInfoByID(id) if err != nil { @@ -700,17 +700,17 @@ func (t *DataSet) DeleteRedisInstance(lcuuid string) { id, _ := t.GetRedisInstanceIDByLcuuid(lcuuid) delete(t.redisInstanceIDToInfo, id) delete(t.redisInstanceLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, lcuuid))) } func (t *DataSet) AddPodCluster(item *mysql.PodCluster) { t.podClusterLcuuidToID[item.Lcuuid] = item.ID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, item.Lcuuid))) } func (t *DataSet) DeletePodCluster(lcuuid string) { delete(t.podClusterLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, lcuuid))) } func (t *DataSet) AddPodNode(item *mysql.PodNode) { @@ -728,11 +728,11 @@ func (t *DataSet) AddPodNode(item *mysql.PodNode) { if azID, ok := t.GetAZIDByLcuuid(item.AZ); ok { t.podNodeIDToInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, item.Lcuuid))) } func (t *DataSet) UpdatePodNode(cloudItem *cloudmodel.PodNode) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, cloudItem.Lcuuid))) id := t.GetPodNodeIDByLcuuid(cloudItem.Lcuuid) if id == 0 { return @@ -765,53 +765,53 @@ func (t *DataSet) DeletePodNode(lcuuid string) { delete(t.podNodeIDToLcuuid, id) delete(t.podNodeIDToInfo, id) delete(t.podNodeLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuid))) } func (t *DataSet) AddVMPodNodeConnection(item *mysql.VMPodNodeConnection) { t.vmPodNodeConnectionLcuuidToPodNodeID[item.Lcuuid] = item.PodNodeID t.podNodeIDToVMID[item.PodNodeID] = item.VMID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, item.Lcuuid))) } func (t *DataSet) DeleteVMPodNodeConnection(lcuuid string) { podNodeID, _ := t.GetPodNodeIDByVMPodNodeConnectionLcuuid(lcuuid) delete(t.podNodeIDToVMID, podNodeID) delete(t.vmPodNodeConnectionLcuuidToPodNodeID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, lcuuid))) } func (t *DataSet) AddPodNamespace(item *mysql.PodNamespace) { t.podNamespaceLcuuidToID[item.Lcuuid] = item.ID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, item.Lcuuid))) } func (t *DataSet) DeletePodNamespace(lcuuid string) { delete(t.podNamespaceLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, lcuuid))) } func (t *DataSet) AddPodIngress(item *mysql.PodIngress) { t.podIngressLcuuidToID[item.Lcuuid] = item.ID t.podIngressIDToLcuuid[item.ID] = item.Lcuuid - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, item.Lcuuid))) } func (t *DataSet) DeletePodIngress(lcuuid string) { id, _ := t.GetPodIngressIDByLcuuid(lcuuid) delete(t.podIngressIDToLcuuid, id) delete(t.podIngressLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, lcuuid))) } func (t *DataSet) AddPodIngressRule(item *mysql.PodIngressRule) { t.podIngressRuleLcuuidToID[item.Lcuuid] = item.ID - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, item.Lcuuid))) } func (t *DataSet) DeletePodIngressRule(lcuuid string) { delete(t.podIngressRuleLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, lcuuid))) } func (t *DataSet) AddPodService(item *mysql.PodService) { @@ -829,11 +829,11 @@ func (t *DataSet) AddPodService(item *mysql.PodService) { if azID, ok := t.GetAZIDByLcuuid(item.AZ); ok { t.podServiceIDToInfo[item.ID].AZID = azID } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, item.Lcuuid))) } func (t *DataSet) UpdatePodService(cloudItem *cloudmodel.PodService) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid))) id, _ := t.GetPodServiceIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetPodServiceInfoByID(id) if err != nil { @@ -863,14 +863,14 @@ func (t *DataSet) DeletePodService(lcuuid string) { delete(t.podServiceIDToInfo, id) delete(t.podServiceLcuuidToID, lcuuid) delete(t.podServiceIDToLcuuid, id) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, lcuuid))) } func (t *DataSet) AddPodGroup(item *mysql.PodGroup) { t.podGroupLcuuidToID[item.Lcuuid] = item.ID t.podGroupIDToLcuuid[item.ID] = item.Lcuuid t.podGroupIDToType[item.ID] = item.Type - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, item.Lcuuid))) } func (t *DataSet) DeletePodGroup(lcuuid string) { @@ -878,13 +878,13 @@ func (t *DataSet) DeletePodGroup(lcuuid string) { delete(t.podGroupIDToLcuuid, id) delete(t.podGroupIDToType, id) delete(t.podGroupLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, lcuuid))) } func (t *DataSet) AddPodReplicaSet(item *mysql.PodReplicaSet) { t.podReplicaSetLcuuidToID[item.Lcuuid] = item.ID t.podReplicaSetIDToLcuuid[item.ID] = item.Lcuuid - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, item.Lcuuid))) } func (t *DataSet) DeletePodReplicaSet(lcuuid string) { @@ -893,7 +893,7 @@ func (t *DataSet) DeletePodReplicaSet(lcuuid string) { delete(t.podReplicaSetIDToLcuuid, id) } delete(t.podReplicaSetLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, lcuuid))) } func (t *DataSet) updateContainerIDToPodID(containerID string, podID int) { @@ -925,11 +925,11 @@ func (t *DataSet) AddPod(item *mysql.Pod) { } t.updateContainerIDToPodID(item.ContainerIDs, item.ID) - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_POD_EN, item.Lcuuid))) } func (t *DataSet) UpdatePod(cloudItem *cloudmodel.Pod) { - defer log.Info(t.metadata.LogPre(updateToolMap(ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid))) + defer log.Info(t.metadata.Logf(updateToolMap(ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid))) id, _ := t.GetPodIDByLcuuid(cloudItem.Lcuuid) info, err := t.GetPodInfoByID(id) if err != nil { @@ -965,7 +965,7 @@ func (t *DataSet) DeletePod(lcuuid string) { delete(t.podIDToInfo, id) delete(t.podIDToIPNetworkIDMap, id) delete(t.podLcuuidToID, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_POD_EN, lcuuid))) } func (t *DataSet) GetRegionIDByLcuuid(lcuuid string) (int, bool) { @@ -973,14 +973,14 @@ func (t *DataSet) GetRegionIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) var region mysql.Region result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(®ion) if result.RowsAffected == 1 { t.AddRegion(®ion) return region.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) return id, false } } @@ -990,14 +990,14 @@ func (t *DataSet) GetRegionLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, id))) var region mysql.Region result := t.metadata.DB.Where("id = ?", id).Find(®ion) if result.RowsAffected == 1 { t.AddRegion(®ion) return region.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, id))) return lcuuid, false } } @@ -1007,14 +1007,14 @@ func (t *DataSet) GetHostIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, lcuuid))) var host mysql.Host result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&host) if result.RowsAffected == 1 { t.AddHost(&host) return host.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, lcuuid))) return id, false } } @@ -1024,14 +1024,14 @@ func (t *DataSet) GetHostIDByIP(ip string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre("cache %s id (ip: %s) not found", ctrlrcommon.RESOURCE_TYPE_HOST_EN, ip)) + log.Warning(t.metadata.Logf("cache %s id (ip: %s) not found", ctrlrcommon.RESOURCE_TYPE_HOST_EN, ip)) var host mysql.Host result := t.metadata.DB.Where("ip = ?", ip).Find(&host) if result.RowsAffected == 1 { t.AddHost(&host) return host.ID, true } else { - log.Error(t.metadata.LogPre("db %s (ip: %s) not found", ctrlrcommon.RESOURCE_TYPE_HOST_EN, ip)) + log.Error(t.metadata.Logf("db %s (ip: %s) not found", ctrlrcommon.RESOURCE_TYPE_HOST_EN, ip)) return id, false } } @@ -1041,14 +1041,14 @@ func (t *DataSet) GetVMIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuid))) var vm mysql.VM result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&vm) if result.RowsAffected == 1 { t.AddVM(&vm) return vm.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuid))) return id, false } } @@ -1058,14 +1058,14 @@ func (t *DataSet) GetVPCIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, lcuuid))) var vpc mysql.VPC result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&vpc) if result.RowsAffected == 1 { t.AddVPC(&vpc) return vpc.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, lcuuid))) return id, false } } @@ -1075,14 +1075,14 @@ func (t *DataSet) GetVPCLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, id))) var vpc mysql.VPC result := t.metadata.DB.Where("lcuuid = ?", id).Find(&vpc) if result.RowsAffected == 1 { t.AddVPC(&vpc) return vpc.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VPC_EN, id))) return lcuuid, false } } @@ -1095,14 +1095,14 @@ func (t *DataSet) GetNetworkIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, lcuuid))) var network mysql.Network result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&network) if result.RowsAffected == 1 { t.AddNetwork(&network) return network.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, lcuuid))) return id, false } } @@ -1112,14 +1112,14 @@ func (t *DataSet) GetSubnetIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, lcuuid))) var subnet mysql.Subnet result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&subnet) if result.RowsAffected == 1 { t.AddSubnet(&subnet) return subnet.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, lcuuid))) return id, false } } @@ -1129,14 +1129,14 @@ func (t *DataSet) GetSubnetLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, id))) var subnet mysql.Subnet result := t.metadata.DB.Where("lcuuid = ?", id).Find(&subnet) if result.RowsAffected == 1 { t.AddSubnet(&subnet) return subnet.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, id))) return lcuuid, false } } @@ -1146,14 +1146,14 @@ func (t *DataSet) GetNetworkIDByVInterfaceLcuuid(vifLcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Warning(t.metadata.Logf("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) var vif mysql.VInterface result := t.metadata.DB.Where("lcuuid = ?", vifLcuuid).Find(&vif) if result.RowsAffected == 1 { t.AddVInterface(&vif) return vif.NetworkID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) return id, false } } @@ -1163,14 +1163,14 @@ func (t *DataSet) GetDeviceTypeByVInterfaceLcuuid(vifLcuuid string) (int, bool) if exists { return id, true } - log.Warning(t.metadata.LogPre("cache device type (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Warning(t.metadata.Logf("cache device type (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) var vif mysql.VInterface result := t.metadata.DB.Where("lcuuid = ?", vifLcuuid).Find(&vif) if result.RowsAffected == 1 { t.AddVInterface(&vif) return vif.DeviceType, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) return id, false } } @@ -1180,14 +1180,14 @@ func (t *DataSet) GetDeviceIDByVInterfaceLcuuid(vifLcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre("cache device id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Warning(t.metadata.Logf("cache device id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) var vif mysql.VInterface result := t.metadata.DB.Where("lcuuid = ?", vifLcuuid).Find(&vif) if result.RowsAffected == 1 { t.AddVInterface(&vif) return vif.DeviceID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) return id, false } } @@ -1197,14 +1197,14 @@ func (t *DataSet) GetMacByVInterfaceLcuuid(vifLcuuid string) (string, bool) { if exists { return mac, true } - log.Warning(t.metadata.LogPre("cache mac (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Warning(t.metadata.Logf("cache mac (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) var vif mysql.VInterface result := t.metadata.DB.Where("lcuuid = ?", vifLcuuid).Find(&vif) if result.RowsAffected == 1 { t.AddVInterface(&vif) return vif.Mac, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid))) return "", false } } @@ -1217,14 +1217,14 @@ func (t *DataSet) GetNetworkLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) var network mysql.Network result := t.metadata.DB.Where("lcuuid = ?", id).Find(&network) if result.RowsAffected == 1 { t.AddNetwork(&network) return network.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) return lcuuid, false } } @@ -1234,14 +1234,14 @@ func (t *DataSet) GetVRouterIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, lcuuid))) var vrouter mysql.VRouter result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&vrouter) if result.RowsAffected == 1 { t.AddVRouter(&vrouter) return vrouter.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, lcuuid))) return id, false } } @@ -1251,14 +1251,14 @@ func (t *DataSet) GetDHCPPortIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))) var dhcpPort mysql.DHCPPort result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&dhcpPort) if result.RowsAffected == 1 { t.AddDHCPPort(&dhcpPort) return dhcpPort.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, lcuuid))) return id, false } } @@ -1268,14 +1268,14 @@ func (t *DataSet) GetVInterfaceIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) var vinterface mysql.VInterface result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&vinterface) if result.RowsAffected == 1 { t.AddVInterface(&vinterface) return vinterface.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) return id, false } } @@ -1285,14 +1285,14 @@ func (t *DataSet) GetVInterfaceTypeByLcuuid(lcuuid string) (int, bool) { if exists { return vt, true } - log.Warning(t.metadata.LogPre("cache %s type (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid)) + log.Warning(t.metadata.Logf("cache %s type (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid)) var vinterface mysql.VInterface result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&vinterface) if result.RowsAffected == 1 { t.AddVInterface(&vinterface) return vinterface.Type, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lcuuid))) return vt, false } } @@ -1321,7 +1321,7 @@ func (t *DataSet) GetDeviceIDByDeviceLcuuid(deviceType int, deviceLcuuid string) } else if deviceType == ctrlrcommon.VIF_DEVICE_TYPE_POD { return t.GetPodIDByLcuuid(deviceLcuuid) } else { - log.Error(t.metadata.LogPre("device type %d not supported", deviceType)) + log.Error(t.metadata.Logf("device type %d not supported", deviceType)) return 0, false } } @@ -1350,7 +1350,7 @@ func (t *DataSet) GetDeviceNameByDeviceID(deviceType, deviceID int) (string, err } else if deviceType == ctrlrcommon.VIF_DEVICE_TYPE_POD { return t.GetPodNameByID(deviceID) } else { - return "", fmt.Errorf(t.metadata.LogPre("device type %d not supported", deviceType)) + return "", fmt.Errorf(t.metadata.Logf("device type %d not supported", deviceType)) } } @@ -1359,14 +1359,14 @@ func (t *DataSet) GetSecurityGroupIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, lcuuid))) var securityGroup mysql.SecurityGroup result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&securityGroup) if result.RowsAffected == 1 { t.AddSecurityGroup(&securityGroup) return securityGroup.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_SECURITY_GROUP_EN, lcuuid))) return id, false } } @@ -1376,14 +1376,14 @@ func (t *DataSet) GetNATGatewayIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, lcuuid))) var natGateway mysql.NATGateway result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&natGateway) if result.RowsAffected == 1 { t.AddNATGateway(&natGateway) return natGateway.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, lcuuid))) return id, false } } @@ -1393,14 +1393,14 @@ func (t *DataSet) GetLBIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, lcuuid))) var lb mysql.LB result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&lb) if result.RowsAffected == 1 { t.AddLB(&lb) return lb.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, lcuuid))) return id, false } } @@ -1410,14 +1410,14 @@ func (t *DataSet) GetLBListenerIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, lcuuid))) var lbListener mysql.LBListener result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&lbListener) if result.RowsAffected == 1 { t.AddLBListener(&lbListener) return lbListener.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, lcuuid))) return id, false } } @@ -1427,14 +1427,14 @@ func (t *DataSet) GetRDSInstanceIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, lcuuid))) var rdsInstance mysql.RDSInstance result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&rdsInstance) if result.RowsAffected == 1 { t.AddRDSInstance(&rdsInstance) return rdsInstance.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, lcuuid))) return id, false } } @@ -1444,14 +1444,14 @@ func (t *DataSet) GetRedisInstanceIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, lcuuid))) var redisInstance mysql.RedisInstance result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&redisInstance) if result.RowsAffected == 1 { t.AddRedisInstance(&redisInstance) return redisInstance.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, lcuuid))) return id, false } } @@ -1461,14 +1461,14 @@ func (t *DataSet) GetPodClusterIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, lcuuid))) var podCluster mysql.PodCluster result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podCluster) if result.RowsAffected == 1 { t.AddPodCluster(&podCluster) return podCluster.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, lcuuid))) return id, false } } @@ -1481,14 +1481,14 @@ func (t *DataSet) GetPodNodeIDByLcuuid(lcuuid string) int { if exists { return id } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuid))) var podNode mysql.PodNode result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podNode) if result.RowsAffected == 1 { t.AddPodNode(&podNode) return podNode.ID } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuid))) return 0 } } @@ -1498,14 +1498,14 @@ func (t *DataSet) GetPodNodeLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) var podNode mysql.PodNode result := t.metadata.DB.Where("id = ?", id).Find(&podNode) if result.RowsAffected == 1 { t.AddPodNode(&podNode) return podNode.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) return lcuuid, false } } @@ -1515,14 +1515,14 @@ func (t *DataSet) GetPodNamespaceIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, lcuuid))) var podNamespace mysql.PodNamespace result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podNamespace) if result.RowsAffected == 1 { t.AddPodNamespace(&podNamespace) return podNamespace.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, lcuuid))) return id, false } } @@ -1532,14 +1532,14 @@ func (t *DataSet) GetPodIngressIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, lcuuid))) var podIngress mysql.PodIngress result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podIngress) if result.RowsAffected == 1 { t.AddPodIngress(&podIngress) return podIngress.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, lcuuid))) return id, false } } @@ -1549,14 +1549,14 @@ func (t *DataSet) GetPodIngressLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, id))) var podIngress mysql.PodIngress result := t.metadata.DB.Where("id = ?", id).Find(&podIngress) if result.RowsAffected == 1 { t.AddPodIngress(&podIngress) return podIngress.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, id))) return lcuuid, false } } @@ -1566,14 +1566,14 @@ func (t *DataSet) GetPodIngressRuleIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, lcuuid))) var podIngressRule mysql.PodIngressRule result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podIngressRule) if result.RowsAffected == 1 { t.AddPodIngressRule(&podIngressRule) return podIngressRule.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, lcuuid))) return id, false } } @@ -1583,14 +1583,14 @@ func (t *DataSet) GetPodServiceIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, lcuuid))) var podService mysql.PodService result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podService) if result.RowsAffected == 1 { t.AddPodService(&podService) return podService.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, lcuuid))) return id, false } } @@ -1600,14 +1600,14 @@ func (t *DataSet) GetPodServiceLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) var podService mysql.PodService result := t.metadata.DB.Where("lcuuid = ?", id).Find(&podService) if result.RowsAffected == 1 { t.AddPodService(&podService) return podService.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) return lcuuid, false } } @@ -1617,14 +1617,14 @@ func (t *DataSet) GetPodGroupIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, lcuuid))) var podGroup mysql.PodGroup result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podGroup) if result.RowsAffected == 1 { t.AddPodGroup(&podGroup) return podGroup.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, lcuuid))) return id, false } } @@ -1634,14 +1634,14 @@ func (t *DataSet) GetPodGroupTypeByID(id int) (int, bool) { if exists { return podGroupType, true } - log.Warning(t.metadata.LogPre(fmt.Sprintf("cache %s type (id: %d) not found", ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) + log.Warning(t.metadata.Logf(fmt.Sprintf("cache %s type (id: %d) not found", ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) var podGroup mysql.PodGroup result := t.metadata.DB.Where("id = ?", id).Find(&podGroup) if result.RowsAffected == 1 { t.AddPodGroup(&podGroup) return podGroup.Type, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) return 0, false } } @@ -1651,14 +1651,14 @@ func (t *DataSet) GetPodGroupLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) var podGroup mysql.PodGroup result := t.metadata.DB.Where("id = ?", id).Find(&podGroup) if result.RowsAffected == 1 { t.AddPodGroup(&podGroup) return podGroup.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, id))) return lcuuid, false } } @@ -1668,14 +1668,14 @@ func (t *DataSet) GetPodReplicaSetIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, lcuuid))) var podReplicaSet mysql.PodReplicaSet result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&podReplicaSet) if result.RowsAffected == 1 { t.AddPodReplicaSet(&podReplicaSet) return podReplicaSet.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, lcuuid))) return id, false } } @@ -1685,14 +1685,14 @@ func (t *DataSet) GetPodReplicaSetLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, id))) var podReplicaSet mysql.PodReplicaSet result := t.metadata.DB.Where("id = ?", id).Find(&podReplicaSet) if result.RowsAffected == 1 { t.AddPodReplicaSet(&podReplicaSet) return podReplicaSet.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, id))) return lcuuid, false } } @@ -1702,14 +1702,14 @@ func (t *DataSet) GetPodIDByLcuuid(lcuuid string) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, lcuuid))) var pod mysql.Pod result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&pod) if result.RowsAffected == 1 { t.AddPod(&pod) return pod.ID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, lcuuid))) return id, false } } @@ -1720,14 +1720,14 @@ func (t *DataSet) GetHostInfoByID(id int) (*hostInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, id))) var dbItem mysql.Host result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddHost(&dbItem) return t.hostIDtoInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, id))) } func (t *DataSet) GetHostNameByID(id int) (string, error) { @@ -1744,14 +1744,14 @@ func (t *DataSet) GetVMInfoByID(id int) (*vmInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, id))) var dbItem mysql.VM result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddVM(&dbItem) return t.vmIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, id))) } func (t *DataSet) GetVMNameByID(id int) (string, error) { @@ -1767,14 +1767,14 @@ func (t *DataSet) GetNetworkNameByID(id int) (string, bool) { if exists { return name, true } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) var network mysql.Network result := t.metadata.DB.Where("id = ?", id).Find(&network) if result.RowsAffected == 1 { t.AddNetwork(&network) return network.Name, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, id))) return name, false } } @@ -1784,7 +1784,7 @@ func (t *DataSet) GetVRouterInfoByID(id int) (*vrouterInfo, error) { if exists { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, id))) var vRouter mysql.VRouter result := t.metadata.DB.Where("id = ?", id).Find(&vRouter) @@ -1792,7 +1792,7 @@ func (t *DataSet) GetVRouterInfoByID(id int) (*vrouterInfo, error) { t.AddVRouter(&vRouter) return t.vrouterIDToInfo[vRouter.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, id))) } func (t *DataSet) GetVRouterNameByID(id int) (string, error) { @@ -1808,14 +1808,14 @@ func (t *DataSet) GetDHCPPortInfoByID(id int) (*dhcpPortInfo, error) { if exists { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, id))) var dbItem mysql.DHCPPort result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddDHCPPort(&dbItem) return t.dhcpPortIDToInfo[id], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, id))) } func (t *DataSet) GetDHCPPortNameByID(id int) (string, error) { @@ -1832,14 +1832,14 @@ func (t *DataSet) GetLBInfoByID(id int) (*lbInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, id))) var dbItem mysql.LB result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddLB(&dbItem) return t.lbIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, id))) } func (t *DataSet) GetLBNameByID(id int) (string, error) { @@ -1855,7 +1855,7 @@ func (t *DataSet) GetNATGatewayInfoByID(id int) (*natGatewayInfo, error) { if exists { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, id))) var dbItem mysql.NATGateway result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) @@ -1863,7 +1863,7 @@ func (t *DataSet) GetNATGatewayInfoByID(id int) (*natGatewayInfo, error) { t.AddNATGateway(&dbItem) return t.natGatewayIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, id))) } func (t *DataSet) GetNATGatewayNameByID(id int) (string, error) { @@ -1880,14 +1880,14 @@ func (t *DataSet) GetRDSInstanceInfoByID(id int) (*rdsInstanceInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, id))) var dbItem mysql.RDSInstance result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddRDSInstance(&dbItem) return t.rdsInstanceIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, id))) } func (t *DataSet) GetRDSInstanceNameByID(id int) (string, error) { @@ -1904,14 +1904,14 @@ func (t *DataSet) GetRedisInstanceInfoByID(id int) (*redisInstanceInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, id))) var dbItem mysql.RedisInstance result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddRedisInstance(&dbItem) return t.redisInstanceIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, id))) } func (t *DataSet) GetRedisInstanceNameByID(id int) (string, error) { @@ -1928,14 +1928,14 @@ func (t *DataSet) GetPodNodeInfoByID(id int) (*podNodeInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) var dbItem mysql.PodNode result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddPodNode(&dbItem) return t.podNodeIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, id))) } func (t *DataSet) GetPodNodeNameByID(id int) (string, error) { @@ -1952,14 +1952,14 @@ func (t *DataSet) GetPodServiceInfoByID(id int) (*podServiceInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) var dbItem mysql.PodService result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddPodService(&dbItem) return t.podServiceIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, id))) } func (t *DataSet) GetPodServiceNameByID(id int) (string, error) { @@ -1976,14 +1976,14 @@ func (t *DataSet) GetPodInfoByID(id int) (*podInfo, error) { return info, nil } - log.Warning(t.metadata.LogPre(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, id))) + log.Warning(t.metadata.Logf(cacheNameByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, id))) var dbItem mysql.Pod result := t.metadata.DB.Where("id = ?", id).Find(&dbItem) if result.RowsAffected == 1 { t.AddPod(&dbItem) return t.podIDToInfo[dbItem.ID], nil } - return nil, errors.New(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, id))) + return nil, errors.New(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, id))) } func (t *DataSet) GetPodNameByID(id int) (string, error) { @@ -1999,14 +1999,14 @@ func (t *DataSet) GetVInterfaceLcuuidByID(id int) (string, bool) { if exists { return lcuuid, true } - log.Warning(t.metadata.LogPre(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, id))) + log.Warning(t.metadata.Logf(cacheLcuuidByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, id))) var vif mysql.VInterface result := t.metadata.DB.Where("id = ?", id).Find(&vif) if result.RowsAffected == 1 { t.AddVInterface(&vif) return vif.Lcuuid, true } else { - log.Error(t.metadata.LogPre(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, id))) + log.Error(t.metadata.Logf(dbResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, id))) return lcuuid, false } } @@ -2016,7 +2016,7 @@ func (t *DataSet) GetVInterfaceIDByWANIPLcuuid(lcuuid string) (int, bool) { if exists { return vifID, true } - log.Warning(t.metadata.LogPre("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid)) + log.Warning(t.metadata.Logf("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid)) var wanIP mysql.WANIP result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&wanIP) if result.RowsAffected == 1 { @@ -2024,7 +2024,7 @@ func (t *DataSet) GetVInterfaceIDByWANIPLcuuid(lcuuid string) (int, bool) { vifID, exists = t.wanIPLcuuidToVInterfaceID[lcuuid] return vifID, exists } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) return vifID, false } } @@ -2034,14 +2034,14 @@ func (t *DataSet) GetWANIPByLcuuid(lcuuid string) (string, bool) { if exists { return ip, true } - log.Warning(t.metadata.LogPre(cacheIPByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIPByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) var wanIP mysql.WANIP result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&wanIP) if result.RowsAffected == 1 { t.AddWANIP(&wanIP) return wanIP.IP, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid))) return ip, false } } @@ -2051,7 +2051,7 @@ func (t *DataSet) GetVInterfaceIDByLANIPLcuuid(lcuuid string) (int, bool) { if exists { return vifID, true } - log.Warning(t.metadata.LogPre("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid)) + log.Warning(t.metadata.Logf("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid)) var lanIP mysql.LANIP result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&lanIP) if result.RowsAffected == 1 { @@ -2059,7 +2059,7 @@ func (t *DataSet) GetVInterfaceIDByLANIPLcuuid(lcuuid string) (int, bool) { vifID, exists = t.lanIPLcuuidToVInterfaceID[lcuuid] return vifID, exists } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) return vifID, false } } @@ -2069,14 +2069,14 @@ func (t *DataSet) GetLANIPByLcuuid(lcuuid string) (string, bool) { if exists { return ip, true } - log.Warning(t.metadata.LogPre(cacheIPByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIPByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) var lanIP mysql.LANIP result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&lanIP) if result.RowsAffected == 1 { t.AddLANIP(&lanIP) return lanIP.IP, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid))) return ip, false } } @@ -2086,14 +2086,14 @@ func (t *DataSet) GetVMIDByPodNodeID(podNodeID int) (int, bool) { if exists { return id, true } - log.Warning(t.metadata.LogPre("cache %s id (%s id: %d) not found", ctrlrcommon.RESOURCE_TYPE_VM_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, podNodeID)) + log.Warning(t.metadata.Logf("cache %s id (%s id: %d) not found", ctrlrcommon.RESOURCE_TYPE_VM_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, podNodeID)) var conn mysql.VMPodNodeConnection result := t.metadata.DB.Where("pod_node_id = ?", podNodeID).Find(&conn) if result.RowsAffected == 1 { t.AddVMPodNodeConnection(&conn) return conn.VMID, true } else { - log.Error(t.metadata.LogPre("db %s (%s id: %d) not found", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, podNodeID)) + log.Error(t.metadata.Logf("db %s (%s id: %d) not found", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, podNodeID)) return 0, false } } @@ -2103,14 +2103,14 @@ func (t *DataSet) GetPodNodeIDByVMPodNodeConnectionLcuuid(lcuuid string) (int, b if exists { return id, true } - log.Warning(t.metadata.LogPre("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, lcuuid)) + log.Warning(t.metadata.Logf("cache %s id (%s lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, lcuuid)) var conn mysql.VMPodNodeConnection result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&conn) if result.RowsAffected == 1 { t.AddVMPodNodeConnection(&conn) return conn.PodNodeID, true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, lcuuid))) return 0, false } @@ -2121,12 +2121,12 @@ func (t *DataSet) AddProcess(item *mysql.Process) { ID: item.ID, Name: item.Name, } - t.GetLogFunc()(t.metadata.LogPre(addToToolMap(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN, item.Lcuuid))) + t.GetLogFunc()(t.metadata.Logf(addToToolMap(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN, item.Lcuuid))) } func (t *DataSet) DeleteProcess(lcuuid string) { delete(t.processLcuuidToInfo, lcuuid) - log.Info(t.metadata.LogPre(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN, lcuuid))) + log.Info(t.metadata.Logf(deleteFromToolMap(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN, lcuuid))) } func (t *DataSet) GetProcessInfoByLcuuid(lcuuid string) (*processInfo, bool) { @@ -2134,14 +2134,14 @@ func (t *DataSet) GetProcessInfoByLcuuid(lcuuid string) (*processInfo, bool) { if exists { return processInfo, true } - log.Warning(t.metadata.LogPre(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) + log.Warning(t.metadata.Logf(cacheIDByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_REGION_EN, lcuuid))) var process *mysql.Process result := t.metadata.DB.Where("lcuuid = ?", lcuuid).Find(&process) if result.RowsAffected == 1 { t.AddProcess(process) return t.processLcuuidToInfo[lcuuid], true } else { - log.Error(t.metadata.LogPre(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN, lcuuid))) + log.Error(t.metadata.Logf(dbResourceByLcuuidNotFound(ctrlrcommon.RESOURCE_TYPE_PROCESS_EN, lcuuid))) return nil, false } } diff --git a/server/controller/recorder/cleaner.go b/server/controller/recorder/cleaner.go index 9d5b35f5603..4b8e662283b 100644 --- a/server/controller/recorder/cleaner.go +++ b/server/controller/recorder/cleaner.go @@ -221,7 +221,7 @@ func newCleaner(orgID int) (*Cleaner, error) { func (c *Cleaner) cleanDeletedData(retentionInterval int) { expiredAt := time.Now().Add(time.Duration(-retentionInterval) * time.Hour) - log.Info(c.org.LogPre("clean soft deleted resources (deleted_at < %s) started", expiredAt.Format(ctrlrcommon.GO_BIRTHDAY))) + log.Info(c.org.Logf("clean soft deleted resources (deleted_at < %s) started", expiredAt.Format(ctrlrcommon.GO_BIRTHDAY))) deleteExpired[mysql.Region](c.org.DB, expiredAt) deleteExpired[mysql.AZ](c.org.DB, expiredAt) deleteExpired[mysql.Host](c.org.DB, expiredAt) @@ -247,11 +247,11 @@ func (c *Cleaner) cleanDeletedData(retentionInterval int) { deleteExpired[mysql.Pod](c.org.DB, expiredAt) deleteExpired[mysql.Process](c.org.DB, expiredAt) deleteExpired[mysql.PrometheusTarget](c.org.DB, expiredAt) - log.Info(c.org.LogPre("clean soft deleted resources completed")) + log.Info(c.org.Logf("clean soft deleted resources completed")) } func (c *Cleaner) cleanDirtyData() { - log.Info(c.org.LogPre("clean dirty data started")) + log.Info(c.org.Logf("clean dirty data started")) c.cleanNetworkDirty() c.cleanVRouterDirty() c.cleanPodIngressDirty() @@ -259,7 +259,7 @@ func (c *Cleaner) cleanDirtyData() { c.cleanPodNodeDirty() c.cleanPodDirty() c.cleanVInterfaceDirty() - log.Info(c.org.LogPre("clean dirty data completed")) + log.Info(c.org.Logf("clean dirty data completed")) } func (c *Cleaner) cleanNetworkDirty() { @@ -269,7 +269,7 @@ func (c *Cleaner) cleanNetworkDirty() { c.org.DB.Where("vl2id NOT IN ?", networkIDs).Find(&subnets) if len(subnets) != 0 { c.org.DB.Delete(&subnets) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, subnets))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, subnets))) } } } @@ -281,7 +281,7 @@ func (c *Cleaner) cleanVRouterDirty() { c.org.DB.Where("vnet_id NOT IN ?", vrouterIDs).Find(&rts) if len(rts) != 0 { c.org.DB.Delete(&rts) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_ROUTING_TABLE_EN, ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, rts))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_ROUTING_TABLE_EN, ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, rts))) } } } @@ -293,14 +293,14 @@ func (c *Cleaner) cleanPodIngressDirty() { c.org.DB.Where("pod_ingress_id NOT IN ?", podIngressIDs).Find(&podIngressRules) if len(podIngressRules) != 0 { c.org.DB.Delete(&podIngressRules) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, podIngressRules))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, podIngressRules))) } var podIngressRuleBkds []mysql.PodIngressRuleBackend c.org.DB.Where("pod_ingress_id NOT IN ?", podIngressIDs).Find(&podIngressRuleBkds) if len(podIngressRuleBkds) != 0 { c.org.DB.Delete(&podIngressRuleBkds) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, podIngressRuleBkds))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, podIngressRuleBkds))) } } } @@ -312,21 +312,21 @@ func (c *Cleaner) cleanPodServiceDirty() { c.org.DB.Where("pod_service_id NOT IN ?", podServiceIDs).Find(&podServicePorts) if len(podServicePorts) != 0 { c.org.DB.Delete(&podServicePorts) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_PORT_EN, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, podServicePorts))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_PORT_EN, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, podServicePorts))) } var podGroupPorts []mysql.PodGroupPort c.org.DB.Where("pod_service_id NOT IN ?", podServiceIDs).Find(&podGroupPorts) if len(podGroupPorts) != 0 { c.org.DB.Delete(&podGroupPorts) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_PORT_EN, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, podGroupPorts))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_GROUP_PORT_EN, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, podGroupPorts))) } var vifs []mysql.VInterface c.org.DB.Where("devicetype = ? AND deviceid NOT IN ?", ctrlrcommon.VIF_DEVICE_TYPE_POD_SERVICE, podServiceIDs).Find(&vifs) if len(vifs) != 0 { c.org.DB.Delete(&vifs) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, vifs))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, vifs))) } } } @@ -338,21 +338,21 @@ func (c *Cleaner) cleanPodNodeDirty() { c.org.DB.Where("devicetype = ? AND deviceid NOT IN ?", ctrlrcommon.VIF_DEVICE_TYPE_POD_NODE, podNodeIDs).Find(&vifs) if len(vifs) != 0 { c.org.DB.Delete(&vifs) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, vifs))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, vifs))) } var vmPodNodeConns []mysql.VMPodNodeConnection c.org.DB.Where("pod_node_id NOT IN ?", podNodeIDs).Find(&vmPodNodeConns) if len(vmPodNodeConns) != 0 { c.org.DB.Delete(&vmPodNodeConns) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, vmPodNodeConns))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, vmPodNodeConns))) } var pods []mysql.Pod c.org.DB.Where("pod_node_id NOT IN ?", podNodeIDs).Find(&pods) if len(pods) != 0 { c.org.DB.Delete(&pods) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, pods))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, pods))) } } } @@ -364,7 +364,7 @@ func (c *Cleaner) cleanPodDirty() { c.org.DB.Where("devicetype = ? AND deviceid NOT IN ?", ctrlrcommon.VIF_DEVICE_TYPE_POD, podIDs).Find(&vifs) if len(vifs) != 0 { c.org.DB.Delete(&vifs) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_POD_EN, vifs))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_POD_EN, vifs))) } } } @@ -376,13 +376,13 @@ func (c *Cleaner) cleanVInterfaceDirty() { c.org.DB.Where("vifid NOT IN ?", vifIDs).Find(&lanIPs) if len(lanIPs) != 0 { c.org.DB.Delete(&lanIPs) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lanIPs))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, lanIPs))) } var wanIPs []mysql.WANIP c.org.DB.Where("vifid NOT IN ?", vifIDs).Find(&wanIPs) if len(wanIPs) != 0 { c.org.DB.Delete(&wanIPs) - log.Error(c.org.LogPre(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, wanIPs))) + log.Error(c.org.Logf(formatLogDeleteABecauseBHasGone(ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, wanIPs))) } } } diff --git a/server/controller/recorder/common/metadata.go b/server/controller/recorder/common/metadata.go index 427e4fbce7f..06a5d86354c 100644 --- a/server/controller/recorder/common/metadata.go +++ b/server/controller/recorder/common/metadata.go @@ -63,11 +63,15 @@ func (m *Metadata) SetSubDomain(subDomain mysql.SubDomain) { m.Logger.SetSubDomainName(subDomain.Name) } -// LogPre adds org id, domain info, sub_domain info to logs -func (m *Metadata) LogPre(format string, a ...any) string { +// Logf adds org id, domain info, sub_domain info to logs +func (m *Metadata) Logf(format string, a ...any) string { return m.Logger.AddPre(format, a...) } +func (m *Metadata) Log(format string) string { + return m.Logger.AddPre(format) +} + type DomainInfo struct { mysql.Domain } diff --git a/server/controller/recorder/common/org.go b/server/controller/recorder/common/org.go index b5e35addd8a..7e451fbf3d9 100644 --- a/server/controller/recorder/common/org.go +++ b/server/controller/recorder/common/org.go @@ -37,11 +37,15 @@ func NewORG(id int) (*ORG, error) { }, err } -// LogPre adds org id, domain info, sub_domain info to logs -func (o *ORG) LogPre(format string, a ...any) string { +// Logf adds org id, domain info, sub_domain info to logs +func (o *ORG) Logf(format string, a ...any) string { return o.Logger.AddPre(format, a...) } +func (o *ORG) Log(format string) string { + return o.Logger.AddPre(format) +} + func FmtORGID(id int) string { return fmt.Sprintf("[OID-%d] ", id) } diff --git a/server/controller/recorder/db/idmng/manager.go b/server/controller/recorder/db/idmng/manager.go index 11d8bd19d56..34864f10d60 100644 --- a/server/controller/recorder/db/idmng/manager.go +++ b/server/controller/recorder/db/idmng/manager.go @@ -79,7 +79,7 @@ func newIDManager(cfg RecorderConfig, orgID int) (*IDManager, error) { } func (m *IDManager) Refresh() error { - log.Info(m.org.LogPre("refresh id pools")) + log.Info(m.org.Logf("refresh id pools")) var result error for _, idPool := range m.resourceTypeToIDPool { err := idPool.refresh() @@ -93,7 +93,7 @@ func (m *IDManager) Refresh() error { func (m *IDManager) AllocateIDs(resourceType string, count int) []int { idPool, ok := m.resourceTypeToIDPool[resourceType] if !ok { - log.Error(m.org.LogPre("resource type (%s) does not need to allocate id", resourceType)) + log.Error(m.org.Logf("resource type (%s) does not need to allocate id", resourceType)) return []int{} } ids, _ := idPool.allocate(count) @@ -103,7 +103,7 @@ func (m *IDManager) AllocateIDs(resourceType string, count int) []int { func (m *IDManager) RecycleIDs(resourceType string, ids []int) { idPool, ok := m.resourceTypeToIDPool[resourceType] if !ok { - log.Error(m.org.LogPre("resource type (%s) does not need to allocate id", resourceType)) + log.Error(m.org.Logf("resource type (%s) does not need to allocate id", resourceType)) return } idPool.recycle(ids) @@ -135,7 +135,7 @@ func newIDPool[MT MySQLModel](org *common.ORG, resourceType string, max int) *ID } func (p *IDPool[MT]) refresh() error { - log.Info(p.org.LogPre("refresh %s id pools started", p.resourceType)) + log.Info(p.org.Logf("refresh %s id pools started", p.resourceType)) var items []*MT var err error @@ -148,7 +148,7 @@ func (p *IDPool[MT]) refresh() error { err = p.org.DB.Unscoped().Select("id").Find(&items).Error } if err != nil { - log.Error(p.org.LogPre("db query %s failed: %v", p.resourceType, err)) + log.Error(p.org.Logf("db query %s failed: %v", p.resourceType, err)) return err } inUseIDsSet := mapset.NewSet[int]() @@ -192,7 +192,7 @@ func (p *IDPool[MT]) refresh() error { } p.usableIDs = usableIDs - log.Info(p.org.LogPre("refresh %s id pools (usable ids count: %d) completed", p.resourceType, len(p.usableIDs))) + log.Info(p.org.Logf("refresh %s id pools (usable ids count: %d) completed", p.resourceType, len(p.usableIDs))) return nil } @@ -203,7 +203,7 @@ func (p *IDPool[MT]) allocate(count int) (ids []int, err error) { defer p.mutex.Unlock() if len(p.usableIDs) == 0 { - log.Error(p.org.LogPre("%s has no more usable ids", p.resourceType)) + log.Error(p.org.Logf("%s has no more usable ids", p.resourceType)) return } @@ -218,7 +218,7 @@ func (p *IDPool[MT]) allocate(count int) (ids []int, err error) { var dbItems []*MT err = p.org.DB.Unscoped().Where("id IN ?", ids).Find(&dbItems).Error if err != nil { - log.Error(p.org.LogPre("db query %s failed: %v", p.resourceType, err)) + log.Error(p.org.Logf("db query %s failed: %v", p.resourceType, err)) return } if len(dbItems) != 0 { @@ -226,10 +226,10 @@ func (p *IDPool[MT]) allocate(count int) (ids []int, err error) { for _, item := range dbItems { inUseIDs = append(inUseIDs, (*item).GetID()) } - log.Info(p.org.LogPre("%s ids: %+v are in use.", p.resourceType, inUseIDs)) + log.Info(p.org.Logf("%s ids: %+v are in use.", p.resourceType, inUseIDs)) ids = mapset.NewSet(ids...).Difference(mapset.NewSet(inUseIDs...)).ToSlice() } - log.Info(p.org.LogPre("allocate %s ids: %v (expected count: %d, true count: %d)", p.resourceType, ids, count, len(ids))) + log.Info(p.org.Logf("allocate %s ids: %v (expected count: %d, true count: %d)", p.resourceType, ids, count, len(ids))) return } @@ -239,5 +239,5 @@ func (p *IDPool[MT]) recycle(ids []int) { sort.IntSlice(ids).Sort() p.usableIDs = append(p.usableIDs, ids...) - log.Info(p.org.LogPre("recycle %s ids: %v", p.resourceType, ids)) + log.Info(p.org.Logf("recycle %s ids: %v", p.resourceType, ids)) } diff --git a/server/controller/recorder/db/operator.go b/server/controller/recorder/db/operator.go index 9c9a660f330..6b27e966300 100644 --- a/server/controller/recorder/db/operator.go +++ b/server/controller/recorder/db/operator.go @@ -76,8 +76,8 @@ func (o *OperatorBase[MT]) AddBatch(items []*MT) ([]*MT, bool) { err := o.metadata.DB.Create(&itemsToAdd).Error if err != nil { - log.Error(o.metadata.LogPre("add %s batch failed: %v", o.resourceTypeName, err)) - log.Error(o.metadata.LogPre("add %s (lcuuids: %v) failed", o.resourceTypeName, lcuuidsToAdd)) + log.Error(o.metadata.Logf("add %s batch failed: %v", o.resourceTypeName, err)) + log.Error(o.metadata.Logf("add %s (lcuuids: %v) failed", o.resourceTypeName, lcuuidsToAdd)) if o.allocateID && len(allocatedIDs) > 0 { idmng.ReleaseIDs(o.metadata.GetORGID(), o.resourceTypeName, allocatedIDs) @@ -97,7 +97,7 @@ func (o *OperatorBase[MT]) AddBatch(items []*MT) ([]*MT, bool) { } for _, item := range itemsToAdd { - log.Info(o.metadata.LogPre("add %s (detail: %+v) success", o.resourceTypeName, item)) + log.Info(o.metadata.Logf("add %s (detail: %+v) success", o.resourceTypeName, item)) } return itemsToAdd, true @@ -107,10 +107,10 @@ func (o *OperatorBase[MT]) Update(lcuuid string, updateInfo map[string]interface dbItem := new(MT) err := o.metadata.DB.Model(&dbItem).Where("lcuuid = ?", lcuuid).Updates(updateInfo).Error if err != nil { - log.Error(o.metadata.LogPre("update %s (lcuuid: %s, detail: %+v) failed: %s", o.resourceTypeName, lcuuid, updateInfo, err.Error())) + log.Error(o.metadata.Logf("update %s (lcuuid: %s, detail: %+v) failed: %s", o.resourceTypeName, lcuuid, updateInfo, err.Error())) return dbItem, false } - log.Info(o.metadata.LogPre("update %s (lcuuid: %s, detail: %+v) success", o.resourceTypeName, lcuuid, updateInfo)) + log.Info(o.metadata.Logf("update %s (lcuuid: %s, detail: %+v) success", o.resourceTypeName, lcuuid, updateInfo)) o.metadata.DB.Model(&dbItem).Where("lcuuid = ?", lcuuid).Find(&dbItem) return dbItem, true } @@ -124,13 +124,13 @@ func (o *OperatorBase[MT]) DeleteBatch(lcuuids []string) ([]*MT, bool) { } err = o.metadata.DB.Delete(&deletedItems).Error if err != nil { - log.Error(o.metadata.LogPre("delete %s (lcuuids: %v) failed: %v", o.resourceTypeName, lcuuids, err)) + log.Error(o.metadata.Logf("delete %s (lcuuids: %v) failed: %v", o.resourceTypeName, lcuuids, err)) return nil, false } if o.softDelete { - log.Info(o.metadata.LogPre("update %s (lcuuids: %v) deleted_at success", o.resourceTypeName, lcuuids)) + log.Info(o.metadata.Logf("update %s (lcuuids: %v) deleted_at success", o.resourceTypeName, lcuuids)) } else { - log.Info(o.metadata.LogPre("delete %s (lcuuids: %v) success", o.resourceTypeName, lcuuids)) + log.Info(o.metadata.Logf("delete %s (lcuuids: %v) success", o.resourceTypeName, lcuuids)) } o.returnUsedIDs(deletedItems) @@ -159,7 +159,7 @@ func (o OperatorBase[MT]) dedupInSelf(items []*MT) ([]*MT, []string, map[string] for _, item := range items { lcuuid := (*item).GetLcuuid() if common.Contains(lcuuids, lcuuid) { - log.Info(o.metadata.LogPre("%s data is duplicated in cloud data (lcuuid: %s)", o.resourceTypeName, lcuuid)) + log.Info(o.metadata.Logf("%s data is duplicated in cloud data (lcuuid: %s)", o.resourceTypeName, lcuuid)) } else { dedupItems = append(dedupItems, item) lcuuids = append(lcuuids, lcuuid) @@ -173,7 +173,7 @@ func (o OperatorBase[MT]) dedupInDB(items []*MT, lcuuids []string, lcuuidToItem var dupItems []*MT err := o.metadata.DB.Unscoped().Where("lcuuid IN ?", lcuuids).Find(&dupItems).Error if err != nil { - log.Error(o.metadata.LogPre("get %s duplicate data failed: %v", o.resourceTypeName, err)) + log.Error(o.metadata.Logf("get %s duplicate data failed: %v", o.resourceTypeName, err)) return nil, nil, false } @@ -194,10 +194,10 @@ func (o OperatorBase[MT]) dedupInDB(items []*MT, lcuuids []string, lcuuidToItem } o.setter.setDBItemID(item, id) } - log.Info(o.metadata.LogPre("%s data is duplicated with db data (lcuuids: %v, ids: %v, one detail: %+v), will learn again", o.resourceTypeName, dupLcuuids, dupItemIDs, dupItems[0])) + log.Info(o.metadata.Logf("%s data is duplicated with db data (lcuuids: %v, ids: %v, one detail: %+v), will learn again", o.resourceTypeName, dupLcuuids, dupItemIDs, dupItems[0])) err = o.metadata.DB.Unscoped().Delete(&dupItems).Error if err != nil { - log.Error(o.metadata.LogPre("delete duplicated data failed: %+v", err)) + log.Error(o.metadata.Logf("delete duplicated data failed: %+v", err)) return items, lcuuids, false } } else { @@ -208,7 +208,7 @@ func (o OperatorBase[MT]) dedupInDB(items []*MT, lcuuids []string, lcuuidToItem dupLcuuids = append(dupLcuuids, lcuuid) } } - log.Error(o.metadata.LogPre("%s data is duplicated with db data (lcuuids: %v, one detail: %+v)", o.resourceTypeName, dupLcuuids, dupItems[0])) + log.Error(o.metadata.Logf("%s data is duplicated with db data (lcuuids: %v, one detail: %+v)", o.resourceTypeName, dupLcuuids, dupItems[0])) count := len(lcuuids) - len(dupLcuuids) dedupItems := make([]*MT, 0, count) @@ -241,17 +241,17 @@ func (o *OperatorBase[MT]) requestIDs(items []*MT) ([]*MT, []int, bool) { if count > 0 { ids, err := idmng.GetIDs(o.metadata.GetORGID(), o.resourceTypeName, count) if err != nil { - log.Error(o.metadata.LogPre("%s request ids failed", o.resourceTypeName)) + log.Error(o.metadata.Logf("%s request ids failed", o.resourceTypeName)) return itemsHasID, []int{}, false } for i, id := range ids { o.setter.setDBItemID(itemsHasNoID[i], id) itemsHasID = append(itemsHasID, itemsHasNoID[i]) } - log.Info(o.metadata.LogPre("%s use ids: %v", o.resourceTypeName, ids)) + log.Info(o.metadata.Logf("%s use ids: %v", o.resourceTypeName, ids)) return itemsHasID, ids, true } else { - log.Info(o.metadata.LogPre("%s not use any id", o.resourceTypeName)) + log.Info(o.metadata.Logf("%s not use any id", o.resourceTypeName)) return itemsHasID, []int{}, true } } @@ -267,8 +267,8 @@ func (o *OperatorBase[MT]) returnUsedIDs(deletedItems []*MT) { } err := idmng.ReleaseIDs(o.metadata.GetORGID(), o.resourceTypeName, ids) if err != nil { - log.Error(o.metadata.LogPre("%s release ids: %v failed", o.resourceTypeName, ids)) + log.Error(o.metadata.Logf("%s release ids: %v failed", o.resourceTypeName, ids)) } - log.Info(o.metadata.LogPre("%s return used ids: %v", o.resourceTypeName, ids)) + log.Info(o.metadata.Logf("%s return used ids: %v", o.resourceTypeName, ids)) } } diff --git a/server/controller/recorder/db/pod_node.go b/server/controller/recorder/db/pod_node.go index f34b41f4722..bbeae065ad0 100644 --- a/server/controller/recorder/db/pod_node.go +++ b/server/controller/recorder/db/pod_node.go @@ -45,25 +45,25 @@ func (n *PodNode) DeleteBatch(lcuuids []string) ([]*mysql.PodNode, bool) { var vmPodNodeConns []*mysql.VMPodNodeConnection err := n.metadata.DB.Model(&mysql.VMPodNodeConnection{}).Joins("JOIN pod_node On vm_pod_node_connection.pod_node_id = pod_node.id").Where("pod_node.lcuuid IN ?", lcuuids).Scan(&vmPodNodeConns).Error if err != nil { - log.Error(n.metadata.LogPre("get %s (%s lcuuids: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuids, err)) + log.Error(n.metadata.Logf("get %s (%s lcuuids: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuids, err)) return nil, false } else { for _, con := range vmPodNodeConns { err = n.metadata.DB.Delete(con).Error if err != nil { - log.Error(n.metadata.LogPre("delete %s (info: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con, err)) + log.Error(n.metadata.Logf("delete %s (info: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con, err)) continue } - log.Info(n.metadata.LogPre("delete %s (info: %+v) success", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con)) + log.Info(n.metadata.Logf("delete %s (info: %+v) success", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con)) } } var dbItems []*mysql.PodNode err = n.metadata.DB.Where("lcuuid IN ?", lcuuids).Delete(&dbItems).Error if err != nil { - log.Error(n.metadata.LogPre("delete %s (lcuuids: %v) failed: %v", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuids, err)) + log.Error(n.metadata.Logf("delete %s (lcuuids: %v) failed: %v", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuids, err)) return nil, false } - log.Info(n.metadata.LogPre("delete %s (lcuuids: %v) success", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuids)) + log.Info(n.metadata.Logf("delete %s (lcuuids: %v) success", ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, lcuuids)) return dbItems, true } diff --git a/server/controller/recorder/db/vm.go b/server/controller/recorder/db/vm.go index 06f00b0e4be..254398e14ac 100644 --- a/server/controller/recorder/db/vm.go +++ b/server/controller/recorder/db/vm.go @@ -45,25 +45,25 @@ func (v *VM) DeleteBatch(lcuuids []string) ([]*mysql.VM, bool) { var vmPodNodeConns []*mysql.VMPodNodeConnection err := v.metadata.DB.Model(&mysql.VMPodNodeConnection{}).Joins("JOIN vm On vm_pod_node_connection.vm_id = vm.id").Where("vm.lcuuid IN ?", lcuuids).Scan(&vmPodNodeConns).Error if err != nil { - log.Error(v.metadata.LogPre("get %s (%s lcuuids: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuids, err)) + log.Error(v.metadata.Logf("get %s (%s lcuuids: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuids, err)) return nil, false } else { for _, con := range vmPodNodeConns { err = v.metadata.DB.Delete(con).Error if err != nil { - log.Error(v.metadata.LogPre("delete %s (info: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con, err)) + log.Error(v.metadata.Logf("delete %s (info: %+v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con, err)) continue } - log.Info(v.metadata.LogPre("delete %s (info: %+v) success", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con)) + log.Info(v.metadata.Logf("delete %s (info: %+v) success", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, con)) } } var dbItems []*mysql.VM err = v.metadata.DB.Where("lcuuid IN ?", lcuuids).Delete(&dbItems).Error if err != nil { - log.Error(v.metadata.LogPre("delete %s (lcuuids: %v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuids, err)) + log.Error(v.metadata.Logf("delete %s (lcuuids: %v) failed: %v", ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuids, err)) return nil, false } - log.Info(v.metadata.LogPre("delete %s (lcuuids: %v) success", ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuids)) + log.Info(v.metadata.Logf("delete %s (lcuuids: %v) success", ctrlrcommon.RESOURCE_TYPE_VM_EN, lcuuids)) return dbItems, true } diff --git a/server/controller/recorder/domain.go b/server/controller/recorder/domain.go index 5f917c8154d..10de0a4669c 100644 --- a/server/controller/recorder/domain.go +++ b/server/controller/recorder/domain.go @@ -62,19 +62,19 @@ func newDomain(ctx context.Context, cfg config.RecorderConfig, eventQueue *queue } func (d *domain) Refresh(target string, cloudData cloudmodel.Resource) error { - log.Info(d.metadata.LogPre("refresh target: %s", target)) + log.Info(d.metadata.Logf("refresh target: %s", target)) switch target { case RefreshTargetDomain: - log.Info(d.metadata.LogPre("refresher started, triggered by ticker/hand")) + log.Info(d.metadata.Logf("refresher started, triggered by ticker/hand")) if err := d.refreshDomainExcludeSubDomain(cloudData); err != nil { return err } return d.subDomains.RefreshAll(cloudData.SubDomainResources) case RefreshTargetSubDomain: - log.Info(d.metadata.LogPre("refresher started, triggered by hand")) + log.Info(d.metadata.Logf("refresher started, triggered by hand")) return d.subDomains.RefreshOne(cloudData.SubDomainResources) default: - return errors.New(d.metadata.LogPre("invalid refresh target")) + return errors.New(d.metadata.Logf("invalid refresh target")) } } @@ -100,7 +100,7 @@ func (d *domain) tryRefresh(cloudData cloudmodel.Resource) error { d.cache.ResetRefreshSignal(cache.RefreshSignalCallerDomain) return nil default: - log.Info(d.metadata.LogPre("domain refresh is running, does nothing")) + log.Info(d.metadata.Logf("domain refresh is running, does nothing")) return RefreshConflictError } } @@ -108,22 +108,22 @@ func (d *domain) tryRefresh(cloudData cloudmodel.Resource) error { func (d *domain) shouldRefresh(cloudData cloudmodel.Resource) error { if cloudData.Verified { if len(cloudData.Networks) == 0 || len(cloudData.VInterfaces) == 0 { - log.Info(d.metadata.LogPre("domain has no networks or vinterfaces, does nothing")) + log.Info(d.metadata.Logf("domain has no networks or vinterfaces, does nothing")) return DataMissingError } if len(cloudData.VMs) == 0 && len(cloudData.Pods) == 0 { - log.Info(d.metadata.LogPre("domain has no vms and pods, does nothing")) + log.Info(d.metadata.Logf("domain has no vms and pods, does nothing")) return DataMissingError } } else { - log.Info(d.metadata.LogPre("domain is not verified, does nothing")) + log.Info(d.metadata.Logf("domain is not verified, does nothing")) return DataNotVerifiedError } return nil } func (d *domain) refresh(cloudData cloudmodel.Resource) { - log.Info(d.metadata.LogPre("domain refresh started")) + log.Info(d.metadata.Logf("domain refresh started")) // 指定创建及更新操作的资源顺序 // 基本原则:无依赖资源优先;实时性需求高资源优先 @@ -135,7 +135,7 @@ func (d *domain) refresh(cloudData cloudmodel.Resource) { d.updateSyncedAt(cloudData.SyncAt) - log.Info(d.metadata.LogPre("domain refresh completed")) + log.Info(d.metadata.Logf("domain refresh completed")) } func (d *domain) getUpdatersInOrder(cloudData cloudmodel.Resource) []updater.ResourceUpdater { @@ -251,7 +251,7 @@ func (r *domain) executeUpdaters(updatersInUpdateOrder []updater.ResourceUpdater func (d *domain) notifyOnResourceChanged(updatersInUpdateOrder []updater.ResourceUpdater) { platformDataChanged := isPlatformDataChanged(updatersInUpdateOrder) if platformDataChanged { - log.Info(d.metadata.LogPre("domain data changed, refresh platform data")) + log.Info(d.metadata.Logf("domain data changed, refresh platform data")) refresh.RefreshCache(d.metadata.GetORGID(), []common.DataChanged{common.DATA_CHANGED_PLATFORM_DATA}) } } @@ -263,41 +263,41 @@ func (d *domain) updateSyncedAt(syncAt time.Time) { var domain mysql.Domain err := d.metadata.DB.Where("lcuuid = ?", d.metadata.Domain.Lcuuid).First(&domain).Error if err != nil { - log.Error(d.metadata.LogPre("get domain from db failed: %s", err)) + log.Error(d.metadata.Logf("get domain from db failed: %s", err)) return } domain.SyncedAt = &syncAt d.metadata.DB.Save(&domain) - log.Debug(d.metadata.LogPre("update domain (%+v)", domain)) + log.Debug(d.metadata.Logf("update domain (%+v)", domain)) } func (d *domain) updateStateInfo(cloudData cloudmodel.Resource) { var domain mysql.Domain err := d.metadata.DB.Where("lcuuid = ?", d.metadata.Domain.Lcuuid).First(&domain).Error if err != nil { - log.Error(d.metadata.LogPre("get domain from db failed: %s", err)) + log.Error(d.metadata.Logf("get domain from db failed: %s", err)) return } domain.State, domain.ErrorMsg = d.formatStateInfo(cloudData) d.metadata.DB.Save(&domain) - log.Debug(d.metadata.LogPre("update domain (%+v)", domain)) + log.Debug(d.metadata.Logf("update domain (%+v)", domain)) for subDomainLcuuid, subDomainResource := range cloudData.SubDomainResources { var subDomain mysql.SubDomain err := d.metadata.DB.Where("lcuuid = ?", subDomainLcuuid).First(&subDomain).Error if err != nil { - log.Error(d.metadata.LogPre("get sub_domain (lcuuid: %s) from db failed: %s", subDomainLcuuid, err)) + log.Error(d.metadata.Logf("get sub_domain (lcuuid: %s) from db failed: %s", subDomainLcuuid, err)) continue } subDomain.State = subDomainResource.ErrorState subDomain.ErrorMsg = subDomainResource.ErrorMessage d.metadata.DB.Save(&subDomain) - log.Debug(d.metadata.LogPre("update sub_domain (%+v)", subDomain)) + log.Debug(d.metadata.Logf("update sub_domain (%+v)", subDomain)) } } func (d *domain) formatStateInfo(domainResource cloudmodel.Resource) (state int, errMsg string) { - log.Info(d.metadata.LogPre("cloud state info: %d, %s", domainResource.ErrorState, domainResource.ErrorMessage)) + log.Info(d.metadata.Logf("cloud state info: %d, %s", domainResource.ErrorState, domainResource.ErrorMessage)) // 状态优先级 exception > warning > sunccess stateToLevel := map[int]int{ common.RESOURCE_STATE_CODE_SUCCESS: 1, @@ -312,7 +312,7 @@ func (d *domain) formatStateInfo(domainResource cloudmodel.Resource) (state int, var subDomainErrMsgs []string for subDomainLcuuid, subDomainResource := range domainResource.SubDomainResources { - log.Info(d.metadata.LogPre("cloud sub_domain (%s) state info: %d, %s", subDomainLcuuid, subDomainResource.ErrorState, subDomainResource.ErrorMessage)) + log.Info(d.metadata.Logf("cloud sub_domain (%s) state info: %d, %s", subDomainLcuuid, subDomainResource.ErrorState, subDomainResource.ErrorMessage)) if stateToLevel[subDomainResource.ErrorState] > stateToLevel[state] { state = subDomainResource.ErrorState } diff --git a/server/controller/recorder/event/common.go b/server/controller/recorder/event/common.go index 95baa3fbeaf..d8d8e8b1f36 100644 --- a/server/controller/recorder/event/common.go +++ b/server/controller/recorder/event/common.go @@ -74,7 +74,7 @@ func (i *IPTool) GetDeviceOptionsByDeviceID(deviceType, deviceID int) ([]eventap case ctrlrcommon.VIF_DEVICE_TYPE_POD: return i.getPodOptionsByID(deviceID) default: - return nil, fmt.Errorf(i.metadata.LogPre("device type %d not supported", deviceType)) + return nil, fmt.Errorf(i.metadata.Logf("device type %d not supported", deviceType)) } } @@ -264,7 +264,7 @@ func (i *IPTool) getPodOptionsByID(id int) ([]eventapi.TagFieldOption, error) { } podGroupType, ok := i.t.GetPodGroupTypeByID(info.PodGroupID) if !ok { - log.Error(i.metadata.LogPre(fmt.Sprintf("db pod_group type(id: %d) not found", info.PodGroupID))) + log.Error(i.metadata.Logf(fmt.Sprintf("db pod_group type(id: %d) not found", info.PodGroupID))) } var opts []eventapi.TagFieldOption @@ -301,82 +301,82 @@ func (i *IPTool) getDeviceNameFromAllByID(deviceType, deviceID int) string { case ctrlrcommon.VIF_DEVICE_TYPE_HOST: device := findFromAllByID[mysql.Host](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_HOST_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_VM: device := findFromAllByID[mysql.VM](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VM_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_VROUTER: device := findFromAllByID[mysql.VRouter](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_DHCP_PORT: device := findFromAllByID[mysql.DHCPPort](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_NAT_GATEWAY: device := findFromAllByID[mysql.NATGateway](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_LB: device := findFromAllByID[mysql.LB](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_LB_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_RDS_INSTANCE: device := findFromAllByID[mysql.RDSInstance](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_REDIS_INSTANCE: device := findFromAllByID[mysql.RedisInstance](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_REDIS_INSTANCE_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_POD_NODE: device := findFromAllByID[mysql.PodNode](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_POD_SERVICE: device := findFromAllByID[mysql.PodService](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, deviceID))) } else { return device.Name } case ctrlrcommon.VIF_DEVICE_TYPE_POD: device := findFromAllByID[mysql.Pod](i.metadata.DB, deviceID) if device == nil { - log.Error(i.metadata.LogPre(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, deviceID))) + log.Error(i.metadata.Logf(dbSoftDeletedResourceByIDNotFound(ctrlrcommon.RESOURCE_TYPE_POD_EN, deviceID))) } else { return device.Name } default: - log.Error(i.metadata.LogPre("device type: %d is not supported", deviceType)) + log.Error(i.metadata.Logf("device type: %d is not supported", deviceType)) return "" } return "" diff --git a/server/controller/recorder/event/dhcp_port.go b/server/controller/recorder/event/dhcp_port.go index e79a1d381b5..30d8c7a981a 100644 --- a/server/controller/recorder/event/dhcp_port.go +++ b/server/controller/recorder/event/dhcp_port.go @@ -84,7 +84,7 @@ func (p *DHCPPort) ProduceByDelete(lcuuids []string) { var err error name, err = p.ToolDataSet.GetDHCPPortNameByID(id) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(p.resourceType, id)) diff --git a/server/controller/recorder/event/host.go b/server/controller/recorder/event/host.go index 7b5aec3ebf9..90e373764d1 100644 --- a/server/controller/recorder/event/host.go +++ b/server/controller/recorder/event/host.go @@ -85,7 +85,7 @@ func (h *Host) ProduceByDelete(lcuuids []string) { var err error name, err = h.ToolDataSet.GetHostNameByID(id) if err != nil { - log.Error(h.metadata.LogPre("%v, %v", idByLcuuidNotFound(h.resourceType, lcuuid), err)) + log.Error(h.metadata.Logf("%v, %v", idByLcuuidNotFound(h.resourceType, lcuuid), err)) } } diff --git a/server/controller/recorder/event/lan_ip.go b/server/controller/recorder/event/lan_ip.go index 1fa6392c61f..6773b1c461a 100644 --- a/server/controller/recorder/event/lan_ip.go +++ b/server/controller/recorder/event/lan_ip.go @@ -62,35 +62,35 @@ func (i *LANIP) ProduceByAdd(items []*mysql.LANIP) { if ok { deviceType, ok = i.ToolDataSet.GetDeviceTypeByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceID, ok = i.ToolDataSet.GetDeviceIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } mac, ok = i.ToolDataSet.GetMacByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } var err error deviceName, err = i.ToolDataSet.GetDeviceNameByDeviceID(deviceType, deviceID) if err != nil { - log.Error(i.metadata.LogPre("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) + log.Error(i.metadata.Logf("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) } deviceRelatedOpts, err = i.tool.GetDeviceOptionsByDeviceID(deviceType, deviceID) if err != nil { - log.Error(i.metadata.LogPre("releated options for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) + log.Error(i.metadata.Logf("releated options for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) } networkID, ok = i.ToolDataSet.GetNetworkIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } networkName, ok = i.ToolDataSet.GetNetworkNameByID(networkID) if !ok { - log.Error(i.metadata.LogPre("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } } else { - log.Error(i.metadata.LogPre("%s lcuuid (id: %d) for %s not found", + log.Error(i.metadata.Logf("%s lcuuid (id: %d) for %s not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, item.VInterfaceID, ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN)) } opts = append(opts, []eventapi.TagFieldOption{ @@ -175,41 +175,41 @@ func (i *LANIP) ProduceByDelete(lcuuids []string) { if ok { deviceType, ok = i.ToolDataSet.GetDeviceTypeByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceID, ok = i.ToolDataSet.GetDeviceIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } mac, ok = i.ToolDataSet.GetMacByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceName, err = i.ToolDataSet.GetDeviceNameByDeviceID(deviceType, deviceID) if err != nil { - log.Error(i.metadata.LogPre("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) + log.Error(i.metadata.Logf("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) deviceName = i.tool.getDeviceNameFromAllByID(deviceType, deviceID) } networkID, ok = i.ToolDataSet.GetNetworkIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } networkName, ok = i.ToolDataSet.GetNetworkNameByID(networkID) if !ok { - log.Error(i.metadata.LogPre("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } } else { - log.Error(i.metadata.LogPre("%s lcuuid (id: %d) for %s not found", + log.Error(i.metadata.Logf("%s lcuuid (id: %d) for %s not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifID, ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN)) } } else { - log.Error(i.metadata.LogPre("%s id for %s (lcuuid: %s) not found", + log.Error(i.metadata.Logf("%s id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid)) } ip, ok := i.ToolDataSet.GetLANIPByLcuuid(lcuuid) if !ok { - log.Error(i.metadata.LogPre("%s (lcuuid: %s) ip not found", ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid)) + log.Error(i.metadata.Logf("%s (lcuuid: %s) ip not found", ctrlrcommon.RESOURCE_TYPE_LAN_IP_EN, lcuuid)) } i.createAndEnqueue( diff --git a/server/controller/recorder/event/lb.go b/server/controller/recorder/event/lb.go index 6b3e984d10b..04428a1e004 100644 --- a/server/controller/recorder/event/lb.go +++ b/server/controller/recorder/event/lb.go @@ -83,7 +83,7 @@ func (l *LB) ProduceByDelete(lcuuids []string) { var err error name, err = l.ToolDataSet.GetLBNameByID(id) if err != nil { - log.Error(l.metadata.LogPre("%v, %v", idByLcuuidNotFound(l.resourceType, lcuuid), err)) + log.Error(l.metadata.Logf("%v, %v", idByLcuuidNotFound(l.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(l.resourceType, id)) diff --git a/server/controller/recorder/event/manager.go b/server/controller/recorder/event/manager.go index 89d518b2ef4..0d8ad681ae3 100644 --- a/server/controller/recorder/event/manager.go +++ b/server/controller/recorder/event/manager.go @@ -95,7 +95,7 @@ func (e *EventManagerBase) enqueue(resourceLcuuid string, event *eventapi.Resour if rt == "" { rt = common.DEVICE_TYPE_INT_TO_STR[int(event.InstanceType)] } - log.Info(e.metadata.LogPre("put %s event (lcuuid: %s): %+v into shared queue", rt, resourceLcuuid, event)) + log.Info(e.metadata.Logf("put %s event (lcuuid: %s): %+v into shared queue", rt, resourceLcuuid, event)) err := e.Queue.Put(event) if err != nil { log.Error(putEventIntoQueueFailed(rt, err)) @@ -115,7 +115,7 @@ func (e *EventManagerBase) enqueueIfInsertIntoMySQLFailed( e.fillEvent(event, eventType, instanceName, instanceType, instanceID, options...) content, err := json.Marshal(event) if err != nil { - log.Error(e.metadata.LogPre("json marshal event (detail: %#v) failed: %s", event, err.Error())) + log.Error(e.metadata.Logf("json marshal event (detail: %#v) failed: %s", event, err.Error())) } else { dbItem := mysql.ResourceEvent{ Domain: domainLcuuid, @@ -123,9 +123,9 @@ func (e *EventManagerBase) enqueueIfInsertIntoMySQLFailed( } err = e.metadata.DB.Create(&dbItem).Error if err != nil { - log.Error(e.metadata.LogPre("add resource_event (detail: %#v) failed: %s", dbItem, err.Error())) + log.Error(e.metadata.Logf("add resource_event (detail: %#v) failed: %s", dbItem, err.Error())) } else { - log.Info(e.metadata.LogPre("create resource_event (detail: %#v) success", dbItem)) + log.Info(e.metadata.Logf("create resource_event (detail: %#v) success", dbItem)) return } } diff --git a/server/controller/recorder/event/nat_gateway.go b/server/controller/recorder/event/nat_gateway.go index 0a814b29551..b89a2cd6203 100644 --- a/server/controller/recorder/event/nat_gateway.go +++ b/server/controller/recorder/event/nat_gateway.go @@ -84,7 +84,7 @@ func (n *NATGateway) ProduceByDelete(lcuuids []string) { var err error name, err = n.ToolDataSet.GetNATGatewayNameByID(id) if err != nil { - log.Error(n.metadata.LogPre("%v, %v", idByLcuuidNotFound(n.resourceType, lcuuid), err)) + log.Error(n.metadata.Logf("%v, %v", idByLcuuidNotFound(n.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(n.resourceType, id)) diff --git a/server/controller/recorder/event/pod.go b/server/controller/recorder/event/pod.go index 2a7ed0407c8..a644253a948 100644 --- a/server/controller/recorder/event/pod.go +++ b/server/controller/recorder/event/pod.go @@ -64,7 +64,7 @@ func (p *Pod) ProduceByAdd(items []*mysql.Pod) { } podGroupType, ok := p.ToolDataSet.GetPodGroupTypeByID(item.PodGroupID) if !ok { - log.Error(p.metadata.LogPre(fmt.Sprintf("db pod_group type(id: %d) not found", item.PodGroupID))) + log.Error(p.metadata.Logf(fmt.Sprintf("db pod_group type(id: %d) not found", item.PodGroupID))) } opts = append(opts, []eventapi.TagFieldOption{ @@ -114,7 +114,7 @@ func (p *Pod) ProduceByUpdate(cloudItem *cloudmodel.Pod, diffBase *diffbase.Pod) if ok { name, err = p.ToolDataSet.GetPodNameByID(id) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, diffBase.Lcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, diffBase.Lcuuid), err)) } } else { log.Error(nameByIDNotFound(p.resourceType, id)) @@ -125,7 +125,7 @@ func (p *Pod) ProduceByUpdate(cloudItem *cloudmodel.Pod, diffBase *diffbase.Pod) if oldPodNodeID != 0 { oldPodNodeName, err = p.ToolDataSet.GetPodNodeNameByID(oldPodNodeID) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, diffBase.PodNodeLcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, diffBase.PodNodeLcuuid), err)) } } @@ -134,7 +134,7 @@ func (p *Pod) ProduceByUpdate(cloudItem *cloudmodel.Pod, diffBase *diffbase.Pod) if newPodNodeID != 0 { newPodNodeName, err = p.ToolDataSet.GetPodNodeNameByID(newPodNodeID) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, cloudItem.PodNodeLcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, cloudItem.PodNodeLcuuid), err)) } } @@ -180,7 +180,7 @@ func (p *Pod) ProduceByDelete(lcuuids []string) { if ok { name, err = p.ToolDataSet.GetPodNameByID(id) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(p.resourceType, id)) diff --git a/server/controller/recorder/event/pod_node.go b/server/controller/recorder/event/pod_node.go index b43204f8cd8..9b2a4ee18cf 100644 --- a/server/controller/recorder/event/pod_node.go +++ b/server/controller/recorder/event/pod_node.go @@ -101,7 +101,7 @@ func (p *PodNode) ProduceByDelete(lcuuids []string) { var err error name, err = p.ToolDataSet.GetPodNodeNameByID(id) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) } } diff --git a/server/controller/recorder/event/pod_service.go b/server/controller/recorder/event/pod_service.go index 745db654692..9565789de4c 100644 --- a/server/controller/recorder/event/pod_service.go +++ b/server/controller/recorder/event/pod_service.go @@ -87,7 +87,7 @@ func (p *PodService) ProduceByDelete(lcuuids []string) { var err error name, err = p.ToolDataSet.GetPodServiceNameByID(id) if err != nil { - log.Error(p.metadata.LogPre("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) + log.Error(p.metadata.Logf("%v, %v", idByLcuuidNotFound(p.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(p.resourceType, id)) diff --git a/server/controller/recorder/event/process.go b/server/controller/recorder/event/process.go index 5eaa1cb9941..66d20da7ae1 100644 --- a/server/controller/recorder/event/process.go +++ b/server/controller/recorder/event/process.go @@ -70,7 +70,7 @@ func (p *Process) ProduceByAdd(items []*mysql.Process) { } else { podGroupType, ok := p.ToolDataSet.GetPodGroupTypeByID(info.PodGroupID) if !ok { - log.Error(p.metadata.LogPre(fmt.Sprintf("db pod_group type(id: %d) not found", info.PodGroupID))) + log.Error(p.metadata.Logf(fmt.Sprintf("db pod_group type(id: %d) not found", info.PodGroupID))) } opts = append(opts, []eventapi.TagFieldOption{ @@ -146,7 +146,7 @@ func (p *Process) ProduceByDelete(lcuuids []string) { var name string processInfo, exists := p.ToolDataSet.GetProcessInfoByLcuuid(lcuuid) if !exists { - log.Error(p.metadata.LogPre("process info not fount, lcuuid: %s", lcuuid)) + log.Error(p.metadata.Logf("process info not fount, lcuuid: %s", lcuuid)) } else { id = processInfo.ID name = processInfo.Name diff --git a/server/controller/recorder/event/rds_instance.go b/server/controller/recorder/event/rds_instance.go index e8c24a32721..5be20aac9ef 100644 --- a/server/controller/recorder/event/rds_instance.go +++ b/server/controller/recorder/event/rds_instance.go @@ -78,7 +78,7 @@ func (r *RDSInstance) ProduceByDelete(lcuuids []string) { var err error name, err = r.ToolDataSet.GetRDSInstanceNameByID(id) if err != nil { - log.Error(r.metadata.LogPre("%v, %v", idByLcuuidNotFound(r.resourceType, lcuuid), err)) + log.Error(r.metadata.Logf("%v, %v", idByLcuuidNotFound(r.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(r.resourceType, id)) diff --git a/server/controller/recorder/event/redis_instance.go b/server/controller/recorder/event/redis_instance.go index 20aee674147..2d4b67c639f 100644 --- a/server/controller/recorder/event/redis_instance.go +++ b/server/controller/recorder/event/redis_instance.go @@ -84,7 +84,7 @@ func (r *RedisInstance) ProduceByDelete(lcuuids []string) { var err error name, err = r.ToolDataSet.GetRedisInstanceNameByID(id) if err != nil { - log.Error(r.metadata.LogPre("%v, %v", idByLcuuidNotFound(r.resourceType, lcuuid), err)) + log.Error(r.metadata.Logf("%v, %v", idByLcuuidNotFound(r.resourceType, lcuuid), err)) } } else { log.Error(nameByIDNotFound(r.resourceType, id)) diff --git a/server/controller/recorder/event/sub_domain.go b/server/controller/recorder/event/sub_domain.go index 95f6b2b33bd..d52f858cd5c 100644 --- a/server/controller/recorder/event/sub_domain.go +++ b/server/controller/recorder/event/sub_domain.go @@ -52,14 +52,14 @@ func (r *SubDomain) ProduceFromMySQL() { var dbItems []mysql.ResourceEvent err := r.metadata.DB.Where("domain = ? AND sub_domain = ?", r.domainLcuuid, r.subDomainLcuuid).Find(&dbItems).Error if err != nil { - log.Error(r.metadata.LogPre("db query resource_event failed:%s", err.Error())) + log.Error(r.metadata.Logf("db query resource_event failed:%s", err.Error())) return } for _, item := range dbItems { var event *eventapi.ResourceEvent err = json.Unmarshal([]byte(item.Content), &event) if err != nil { - log.Error(r.metadata.LogPre("json marshal event (detail: %#v) failed: %s", item, err.Error())) + log.Error(r.metadata.Logf("json marshal event (detail: %#v) failed: %s", item, err.Error())) r.metadata.DB.Delete(&item) continue } @@ -93,7 +93,7 @@ func (r *SubDomain) fillL3DeviceInfo(event *eventapi.ResourceEvent) bool { } else if event.InstanceType == common.VIF_DEVICE_TYPE_POD { podInfo, err := r.ToolDataSet.GetPodInfoByID(int(event.InstanceID)) if err != nil { - log.Error(r.metadata.LogPre("get pod (id: %d) pod node ID failed: %s", event.InstanceID, err.Error())) + log.Error(r.metadata.Logf("get pod (id: %d) pod node ID failed: %s", event.InstanceID, err.Error())) return false } podNodeID = podInfo.PodNodeID diff --git a/server/controller/recorder/event/vm.go b/server/controller/recorder/event/vm.go index 532c8d25ec0..29f9a9a6d51 100644 --- a/server/controller/recorder/event/vm.go +++ b/server/controller/recorder/event/vm.go @@ -130,7 +130,7 @@ func (v *VM) ProduceByDelete(lcuuids []string) { for _, lcuuid := range lcuuids { id, name, err := v.getVMIDAndNameByLcuuid(lcuuid) if err != nil { - log.Error(v.metadata.LogPre("%v, %v", idByLcuuidNotFound(v.resourceType, lcuuid), err)) + log.Error(v.metadata.Logf("%v, %v", idByLcuuidNotFound(v.resourceType, lcuuid), err)) } v.createAndEnqueue(lcuuid, eventapi.RESOURCE_EVENT_TYPE_DELETE, name, v.deviceType, id) diff --git a/server/controller/recorder/event/vrouter.go b/server/controller/recorder/event/vrouter.go index c1e80c0e6f2..5add8fabeec 100644 --- a/server/controller/recorder/event/vrouter.go +++ b/server/controller/recorder/event/vrouter.go @@ -97,7 +97,7 @@ func (r *VRouter) ProduceByDelete(lcuuids []string) { var err error name, err = r.ToolDataSet.GetVRouterNameByID(id) if err != nil { - log.Error(r.metadata.LogPre("%v, %v", idByLcuuidNotFound(r.resourceType, lcuuid), err)) + log.Error(r.metadata.Logf("%v, %v", idByLcuuidNotFound(r.resourceType, lcuuid), err)) } } diff --git a/server/controller/recorder/event/wan_ip.go b/server/controller/recorder/event/wan_ip.go index 32e8cfb9432..74a94e2e17d 100644 --- a/server/controller/recorder/event/wan_ip.go +++ b/server/controller/recorder/event/wan_ip.go @@ -63,34 +63,34 @@ func (i *WANIP) ProduceByAdd(items []*mysql.WANIP) { // TODO 同 lan ip 合并 c if ok { deviceType, ok = i.ToolDataSet.GetDeviceTypeByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceID, ok = i.ToolDataSet.GetDeviceIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } mac, ok = i.ToolDataSet.GetMacByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceName, err = i.ToolDataSet.GetDeviceNameByDeviceID(deviceType, deviceID) if err != nil { - log.Error(i.metadata.LogPre("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) + log.Error(i.metadata.Logf("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) } deviceRelatedOpts, err = i.tool.GetDeviceOptionsByDeviceID(deviceType, deviceID) if err != nil { - log.Error(i.metadata.LogPre("releated options for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) + log.Error(i.metadata.Logf("releated options for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) } networkID, ok = i.ToolDataSet.GetNetworkIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } networkName, ok = i.ToolDataSet.GetNetworkNameByID(networkID) if !ok { - log.Error(i.metadata.LogPre("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } } else { - log.Error(i.metadata.LogPre("%s lcuuid (id: %d) for %s not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, item.VInterfaceID, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN)) + log.Error(i.metadata.Logf("%s lcuuid (id: %d) for %s not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, item.VInterfaceID, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN)) } opts = append(opts, []eventapi.TagFieldOption{ @@ -177,40 +177,40 @@ func (i *WANIP) ProduceByDelete(lcuuids []string) { if ok { deviceType, ok = i.ToolDataSet.GetDeviceTypeByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device type for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceID, ok = i.ToolDataSet.GetDeviceIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("device id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } mac, ok = i.ToolDataSet.GetMacByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("mac for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } deviceName, err = i.ToolDataSet.GetDeviceNameByDeviceID(deviceType, deviceID) if err != nil { - log.Error(i.metadata.LogPre("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) + log.Error(i.metadata.Logf("device name for %s (lcuuid: %s) not found, %v", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid, err)) deviceName = i.tool.getDeviceNameFromAllByID(deviceType, deviceID) } networkID, ok = i.ToolDataSet.GetNetworkIDByVInterfaceLcuuid(vifLcuuid) if !ok { - log.Error(i.metadata.LogPre("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } networkName, ok = i.ToolDataSet.GetNetworkNameByID(networkID) if !ok { - log.Error(i.metadata.LogPre("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) + log.Error(i.metadata.Logf("network name for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifLcuuid)) } } else { - log.Error(i.metadata.LogPre("%s lcuuid (id: %d) for %s not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifID, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN)) + log.Error(i.metadata.Logf("%s lcuuid (id: %d) for %s not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, vifID, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN)) } } else { - log.Error(i.metadata.LogPre("%s id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid)) + log.Error(i.metadata.Logf("%s id for %s (lcuuid: %s) not found", ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid)) } ip, ok := i.ToolDataSet.GetWANIPByLcuuid(lcuuid) if !ok { - log.Error(i.metadata.LogPre("%s (lcuuid: %s) ip not found", ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid)) + log.Error(i.metadata.Logf("%s (lcuuid: %s) ip not found", ctrlrcommon.RESOURCE_TYPE_WAN_IP_EN, lcuuid)) } i.createAndEnqueue( diff --git a/server/controller/recorder/pubsub/message/metadata.go b/server/controller/recorder/pubsub/message/metadata.go index b2af264904e..3caed2a92c0 100644 --- a/server/controller/recorder/pubsub/message/metadata.go +++ b/server/controller/recorder/pubsub/message/metadata.go @@ -17,15 +17,17 @@ package message type Metadata struct { - ORGID int - TeamID int - DomainID int + ORGID int + TeamID int + DomainID int + SubDomainID int } -func NewMetadata(orgID, teamID, domainID int) *Metadata { +func NewMetadata(orgID, teamID, domainID, subDomainID int) *Metadata { return &Metadata{ - ORGID: orgID, - TeamID: teamID, - DomainID: domainID, + ORGID: orgID, + TeamID: teamID, + DomainID: domainID, + SubDomainID: subDomainID, } } diff --git a/server/controller/recorder/pubsub/pubsub.go b/server/controller/recorder/pubsub/pubsub.go index 670c8b8e76f..f912aa324f6 100644 --- a/server/controller/recorder/pubsub/pubsub.go +++ b/server/controller/recorder/pubsub/pubsub.go @@ -121,7 +121,7 @@ func (p *ResourcePubSubComponent[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) func (p *ResourcePubSubComponent[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) PublishBatchAdded(md *message.Metadata, msg MAPT) { // TODO better log - // log.Infof("publish add %#v", msg) + log.Debugf("publish add %#v, %#v", md, msg) for topic, subs := range p.subscribers { if topic == TopicResourceBatchAddedMySQL { for _, sub := range subs { @@ -132,7 +132,7 @@ func (p *ResourcePubSubComponent[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) } func (p *ResourcePubSubComponent[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) PublishUpdated(md *message.Metadata, msg MUPT) { - // log.Infof("publish update %#v", msg) + log.Debugf("publish update %#v, %#v", md, msg) for topic, subs := range p.subscribers { if topic == TopicResourceUpdatedFields { for _, sub := range subs { @@ -148,7 +148,7 @@ func (p *ResourcePubSubComponent[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) } func (p *ResourcePubSubComponent[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) PublishBatchDeleted(md *message.Metadata, msg MDPT, softDelete bool) { - // log.Infof("publish delete %#v", msg) + log.Debugf("publish delete %#v, %#v", md, msg) for topic, subs := range p.subscribers { if topic == TopicResourceBatchDeletedLcuuid { for _, sub := range subs { diff --git a/server/controller/recorder/recorder.go b/server/controller/recorder/recorder.go index 355683d6f65..0306193beb9 100644 --- a/server/controller/recorder/recorder.go +++ b/server/controller/recorder/recorder.go @@ -47,7 +47,7 @@ func NewRecorder(ctx context.Context, cfg config.RecorderConfig, eventQueue *que } var domain mysql.Domain if err := md.DB.Where("lcuuid = ?", domainLcuuid).First(&domain).Error; err != nil { - log.Error(md.LogPre("domain lcuuid: %s, failed to get domain from db: %s", domainLcuuid, err.Error())) + log.Error(md.Logf("domain lcuuid: %s, failed to get domain from db: %s", domainLcuuid, err.Error())) return nil } md.SetDomain(domain) diff --git a/server/controller/recorder/sub_domain.go b/server/controller/recorder/sub_domain.go index 7b996b42903..88cae085de6 100644 --- a/server/controller/recorder/sub_domain.go +++ b/server/controller/recorder/sub_domain.go @@ -99,7 +99,7 @@ func (s *subDomains) RefreshOne(cloudData map[string]cloudmodel.SubDomainResourc func (s *subDomains) newRefresher(lcuuid string) (*subDomain, error) { var sd mysql.SubDomain if err := s.metadata.DB.Where("lcuuid = ?", lcuuid).First(&sd).Error; err != nil { - log.Error(s.metadata.LogPre("failed to get sub_domain from db: %s", err.Error())) + log.Error(s.metadata.Logf("failed to get sub_domain from db: %s", err.Error())) return nil, err } md := s.metadata.Copy() @@ -138,14 +138,14 @@ func (s *subDomain) tryRefresh(cloudData cloudmodel.SubDomainResource) error { s.refresh(cloudData) s.cache.ResetRefreshSignal(cache.RefreshSignalCallerSubDomain) default: - log.Info(s.metadata.LogPre("sub_domain refresh is running, does nothing")) + log.Info(s.metadata.Logf("sub_domain refresh is running, does nothing")) return RefreshConflictError } return nil } func (s *subDomain) refresh(cloudData cloudmodel.SubDomainResource) { - log.Info(s.metadata.LogPre("sub_domain sync refresh started")) + log.Info(s.metadata.Logf("sub_domain sync refresh started")) listener := listener.NewWholeSubDomain(s.metadata.Domain.Lcuuid, s.metadata.SubDomain.Lcuuid, s.cache, s.eventQueue) subDomainUpdatersInUpdateOrder := s.getUpdatersInOrder(cloudData) @@ -155,24 +155,24 @@ func (s *subDomain) refresh(cloudData cloudmodel.SubDomainResource) { s.updateSyncedAt(s.metadata.SubDomain.Lcuuid, cloudData.SyncAt) - log.Info(s.metadata.LogPre("sub_domain sync refresh completed")) + log.Info(s.metadata.Logf("sub_domain sync refresh completed")) } func (s *subDomain) clear() { - log.Info(s.metadata.LogPre("sub_domain clean refresh started")) + log.Info(s.metadata.Logf("sub_domain clean refresh started")) subDomainUpdatersInUpdateOrder := s.getUpdatersInOrder(cloudmodel.SubDomainResource{}) s.executeUpdaters(subDomainUpdatersInUpdateOrder) - log.Info(s.metadata.LogPre("sub_domain clean refresh completed")) + log.Info(s.metadata.Logf("sub_domain clean refresh completed")) } func (s *subDomain) shouldRefresh(lcuuid string, cloudData cloudmodel.SubDomainResource) error { if cloudData.Verified { if len(cloudData.Networks) == 0 || len(cloudData.VInterfaces) == 0 || len(cloudData.Pods) == 0 { - log.Info(s.metadata.LogPre("sub_domain has no networks or vinterfaces or pods, does nothing")) + log.Info(s.metadata.Logf("sub_domain has no networks or vinterfaces or pods, does nothing")) return DataMissingError } } else { - log.Info(s.metadata.LogPre("sub_domain is not verified, does nothing")) + log.Info(s.metadata.Logf("sub_domain is not verified, does nothing")) return DataNotVerifiedError } return nil @@ -245,7 +245,7 @@ func (r *subDomain) executeUpdaters(updatersInUpdateOrder []updater.ResourceUpda func (s *subDomain) notifyOnResourceChanged(updatersInUpdateOrder []updater.ResourceUpdater) { changed := isPlatformDataChanged(updatersInUpdateOrder) if changed { - log.Info(s.metadata.LogPre("sub domain data changed, refresh platform data")) + log.Info(s.metadata.Logf("sub domain data changed, refresh platform data")) refresh.RefreshCache(s.metadata.GetORGID(), []common.DataChanged{common.DATA_CHANGED_PLATFORM_DATA}) } } @@ -257,12 +257,12 @@ func (s *subDomain) updateSyncedAt(lcuuid string, syncAt time.Time) { var subDomain mysql.SubDomain err := s.metadata.DB.Where("lcuuid = ?", lcuuid).First(&subDomain).Error if err != nil { - log.Error(s.metadata.LogPre("get sub_domain from db failed: %s", err.Error())) + log.Error(s.metadata.Logf("get sub_domain from db failed: %s", err.Error())) return } subDomain.SyncedAt = &syncAt s.metadata.DB.Save(&subDomain) - log.Debug(s.metadata.LogPre("update sub_domain (%+v)", subDomain)) + log.Debug(s.metadata.Logf("update sub_domain (%+v)", subDomain)) } // TODO 单独刷新 sub_domain 时是否需要更新状态信息 @@ -270,11 +270,11 @@ func (s *subDomain) updateStateInfo(cloudData cloudmodel.SubDomainResource) { var subDomain mysql.SubDomain err := s.metadata.DB.Where("lcuuid = ?", s.metadata.SubDomain.Lcuuid).First(&subDomain).Error if err != nil { - log.Error(s.metadata.LogPre("get sub_domain from db failed: %s", err.Error())) + log.Error(s.metadata.Logf("get sub_domain from db failed: %s", err.Error())) return } subDomain.State = cloudData.ErrorState subDomain.ErrorMsg = cloudData.ErrorMessage s.metadata.DB.Save(&subDomain) - log.Debug(s.metadata.LogPre("update sub_domain (%+v)", subDomain)) + log.Debug(s.metadata.Logf("update sub_domain (%+v)", subDomain)) } diff --git a/server/controller/recorder/updater/cen.go b/server/controller/recorder/updater/cen.go index c5d9b1269ed..54cc825f253 100644 --- a/server/controller/recorder/updater/cen.go +++ b/server/controller/recorder/updater/cen.go @@ -77,7 +77,7 @@ func (c *CEN) generateDBItemToAdd(cloudItem *cloudmodel.CEN) (*mysql.CEN, bool) for _, vpcLcuuid := range cloudItem.VPCLcuuids { vpcID, exists := c.cache.ToolDataSet.GetVPCIDByLcuuid(vpcLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, vpcLcuuid, ctrlrcommon.RESOURCE_TYPE_CEN_EN, cloudItem.Lcuuid, ))) @@ -107,7 +107,7 @@ func (c *CEN) generateUpdateInfo(diffBase *diffbase.CEN, cloudItem *cloudmodel.C for _, vpcLcuuid := range cloudItem.VPCLcuuids { vpcID, exists := c.cache.ToolDataSet.GetVPCIDByLcuuid(vpcLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, vpcLcuuid, ctrlrcommon.RESOURCE_TYPE_CEN_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/dhcp_port.go b/server/controller/recorder/updater/dhcp_port.go index ff648f9acbf..e25dc8e1d7a 100644 --- a/server/controller/recorder/updater/dhcp_port.go +++ b/server/controller/recorder/updater/dhcp_port.go @@ -74,7 +74,7 @@ func (p *DHCPPort) getDiffBaseByCloudItem(cloudItem *cloudmodel.DHCPPort) (diffB func (p *DHCPPort) generateDBItemToAdd(cloudItem *cloudmodel.DHCPPort) (*mysql.DHCPPort, bool) { vpcID, exists := p.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, cloudItem.Lcuuid, ))) @@ -97,7 +97,7 @@ func (p *DHCPPort) generateUpdateInfo(diffBase *diffbase.DHCPPort, cloudItem *cl if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := p.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_DHCP_PORT_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/floating_ip.go b/server/controller/recorder/updater/floating_ip.go index e6e566075d7..08800afc3c3 100644 --- a/server/controller/recorder/updater/floating_ip.go +++ b/server/controller/recorder/updater/floating_ip.go @@ -75,7 +75,7 @@ func (f *FloatingIP) getDiffBaseByCloudItem(cloudItem *cloudmodel.FloatingIP) (d func (f *FloatingIP) generateDBItemToAdd(cloudItem *cloudmodel.FloatingIP) (*mysql.FloatingIP, bool) { networkID, exists := f.cache.ToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid) if !exists { - log.Error(f.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(f.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.NetworkLcuuid, ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN, cloudItem.Lcuuid, ))) @@ -83,7 +83,7 @@ func (f *FloatingIP) generateDBItemToAdd(cloudItem *cloudmodel.FloatingIP) (*mys } vmID, exists := f.cache.ToolDataSet.GetVMIDByLcuuid(cloudItem.VMLcuuid) if !exists { - log.Error(f.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(f.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VM_EN, cloudItem.VMLcuuid, ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN, cloudItem.Lcuuid, ))) @@ -91,7 +91,7 @@ func (f *FloatingIP) generateDBItemToAdd(cloudItem *cloudmodel.FloatingIP) (*mys } vpcID, exists := f.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(f.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(f.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN, cloudItem.Lcuuid, ))) @@ -99,7 +99,7 @@ func (f *FloatingIP) generateDBItemToAdd(cloudItem *cloudmodel.FloatingIP) (*mys } ip := rcommon.FormatIP(cloudItem.IP) if ip == "" { - log.Error(f.metadata.LogPre(ipIsInvalid( + log.Error(f.metadata.Logf(ipIsInvalid( ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN, cloudItem.Lcuuid, cloudItem.IP, ))) return nil, false @@ -122,7 +122,7 @@ func (f *FloatingIP) generateUpdateInfo(diffBase *diffbase.FloatingIP, cloudItem if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := f.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(f.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(f.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_FLOATING_IP_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/lb.go b/server/controller/recorder/updater/lb.go index 378af89d530..06d92410171 100644 --- a/server/controller/recorder/updater/lb.go +++ b/server/controller/recorder/updater/lb.go @@ -74,7 +74,7 @@ func (l *LB) getDiffBaseByCloudItem(cloudItem *cloudmodel.LB) (diffBase *diffbas func (l *LB) generateDBItemToAdd(cloudItem *cloudmodel.LB) (*mysql.LB, bool) { vpcID, exists := l.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(l.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(l.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_LB_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/lb_listener.go b/server/controller/recorder/updater/lb_listener.go index 1f95c1aea85..46f4732c457 100644 --- a/server/controller/recorder/updater/lb_listener.go +++ b/server/controller/recorder/updater/lb_listener.go @@ -74,7 +74,7 @@ func (l *LBListener) getDiffBaseByCloudItem(cloudItem *cloudmodel.LBListener) (d func (l *LBListener) generateDBItemToAdd(cloudItem *cloudmodel.LBListener) (*mysql.LBListener, bool) { lbID, exists := l.cache.ToolDataSet.GetLBIDByLcuuid(cloudItem.LBLcuuid) if !exists { - log.Error(l.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(l.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_LB_EN, cloudItem.LBLcuuid, ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/lb_target_server.go b/server/controller/recorder/updater/lb_target_server.go index 109e6b636df..49a8bb6fdb8 100644 --- a/server/controller/recorder/updater/lb_target_server.go +++ b/server/controller/recorder/updater/lb_target_server.go @@ -74,7 +74,7 @@ func (s *LBTargetServer) getDiffBaseByCloudItem(cloudItem *cloudmodel.LBTargetSe func (s *LBTargetServer) generateDBItemToAdd(cloudItem *cloudmodel.LBTargetServer) (*mysql.LBTargetServer, bool) { lbID, exists := s.cache.ToolDataSet.GetLBIDByLcuuid(cloudItem.LBLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_LB_EN, cloudItem.LBLcuuid, ctrlrcommon.RESOURCE_TYPE_LB_TARGET_SERVER_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (s *LBTargetServer) generateDBItemToAdd(cloudItem *cloudmodel.LBTargetServe } lbListenerID, exists := s.cache.ToolDataSet.GetLBListenerIDByLcuuid(cloudItem.LBListenerLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_LB_LISTENER_EN, cloudItem.LBListenerLcuuid, ctrlrcommon.RESOURCE_TYPE_LB_TARGET_SERVER_EN, cloudItem.Lcuuid, ))) @@ -92,7 +92,7 @@ func (s *LBTargetServer) generateDBItemToAdd(cloudItem *cloudmodel.LBTargetServe if cloudItem.VMLcuuid != "" { vmID, exists = s.cache.ToolDataSet.GetVMIDByLcuuid(cloudItem.VMLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VM_EN, cloudItem.VMLcuuid, ctrlrcommon.RESOURCE_TYPE_LB_TARGET_SERVER_EN, cloudItem.Lcuuid, ))) @@ -101,7 +101,7 @@ func (s *LBTargetServer) generateDBItemToAdd(cloudItem *cloudmodel.LBTargetServe } vpcID, exists := s.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_LB_TARGET_SERVER_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/nat_gateway.go b/server/controller/recorder/updater/nat_gateway.go index ec13595dd8b..81987490dce 100644 --- a/server/controller/recorder/updater/nat_gateway.go +++ b/server/controller/recorder/updater/nat_gateway.go @@ -74,7 +74,7 @@ func (g *NATGateway) getDiffBaseByCloudItem(cloudItem *cloudmodel.NATGateway) (d func (g *NATGateway) generateDBItemToAdd(cloudItem *cloudmodel.NATGateway) (*mysql.NATGateway, bool) { vpcID, exists := g.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(g.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(g.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/nat_rule.go b/server/controller/recorder/updater/nat_rule.go index 887df9ba95b..9c6c339a31f 100644 --- a/server/controller/recorder/updater/nat_rule.go +++ b/server/controller/recorder/updater/nat_rule.go @@ -77,7 +77,7 @@ func (r *NATRule) generateDBItemToAdd(cloudItem *cloudmodel.NATRule) (*mysql.NAT if cloudItem.NATGatewayLcuuid != "" { natGatewayID, exists = r.cache.ToolDataSet.GetNATGatewayIDByLcuuid(cloudItem.NATGatewayLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_NAT_GATEWAY_EN, cloudItem.NATGatewayLcuuid, ctrlrcommon.RESOURCE_TYPE_NAT_RULE_EN, cloudItem.Lcuuid, ))) @@ -88,7 +88,7 @@ func (r *NATRule) generateDBItemToAdd(cloudItem *cloudmodel.NATRule) (*mysql.NAT if cloudItem.VInterfaceLcuuid != "" { vinterfaceID, exists = r.cache.ToolDataSet.GetVInterfaceIDByLcuuid(cloudItem.VInterfaceLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.VInterfaceLcuuid, ctrlrcommon.RESOURCE_TYPE_NAT_RULE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/network.go b/server/controller/recorder/updater/network.go index ccd75b66f25..9e3870ed385 100644 --- a/server/controller/recorder/updater/network.go +++ b/server/controller/recorder/updater/network.go @@ -74,7 +74,7 @@ func (n *Network) getDiffBaseByCloudItem(cloudItem *cloudmodel.Network) (diffBas func (n *Network) generateDBItemToAdd(cloudItem *cloudmodel.Network) (*mysql.Network, bool) { vpcID, exists := n.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(n.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(n.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.Lcuuid, ))) @@ -104,7 +104,7 @@ func (n *Network) generateUpdateInfo(diffBase *diffbase.Network, cloudItem *clou if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := n.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(n.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(n.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/peer_connection.go b/server/controller/recorder/updater/peer_connection.go index 08810b5f6c0..dc4d1db09e3 100644 --- a/server/controller/recorder/updater/peer_connection.go +++ b/server/controller/recorder/updater/peer_connection.go @@ -74,7 +74,7 @@ func (c *PeerConnection) getDiffBaseByCloudItem(cloudItem *cloudmodel.PeerConnec func (c *PeerConnection) generateDBItemToAdd(cloudItem *cloudmodel.PeerConnection) (*mysql.PeerConnection, bool) { remoteVPCID, exists := c.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.RemoteVPCLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.RemoteVPCLcuuid, ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (c *PeerConnection) generateDBItemToAdd(cloudItem *cloudmodel.PeerConnectio } localVPCID, exists := c.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.LocalVPCLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.LocalVPCLcuuid, ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN, cloudItem.Lcuuid, ))) @@ -90,7 +90,7 @@ func (c *PeerConnection) generateDBItemToAdd(cloudItem *cloudmodel.PeerConnectio } remoteRegionID, exists := c.cache.ToolDataSet.GetRegionIDByLcuuid(cloudItem.RemoteRegionLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_REGION_EN, cloudItem.RemoteRegionLcuuid, ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN, cloudItem.Lcuuid, ))) @@ -98,7 +98,7 @@ func (c *PeerConnection) generateDBItemToAdd(cloudItem *cloudmodel.PeerConnectio } localRegionID, exists := c.cache.ToolDataSet.GetRegionIDByLcuuid(cloudItem.LocalRegionLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_REGION_EN, cloudItem.LocalRegionLcuuid, ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN, cloudItem.Lcuuid, ))) @@ -127,7 +127,7 @@ func (c *PeerConnection) generateUpdateInfo(diffBase *diffbase.PeerConnection, c if diffBase.RemoteRegionLcuuid != cloudItem.RemoteRegionLcuuid { remoteRegionID, exists := c.cache.ToolDataSet.GetRegionIDByLcuuid(cloudItem.RemoteRegionLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_REGION_EN, cloudItem.RemoteRegionLcuuid, ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN, cloudItem.Lcuuid, ))) @@ -140,7 +140,7 @@ func (c *PeerConnection) generateUpdateInfo(diffBase *diffbase.PeerConnection, c if diffBase.LocalRegionLcuuid != cloudItem.LocalRegionLcuuid { localRegionID, exists := c.cache.ToolDataSet.GetRegionIDByLcuuid(cloudItem.LocalRegionLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_REGION_EN, cloudItem.LocalRegionLcuuid, ctrlrcommon.RESOURCE_TYPE_PEER_CONNECTION_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod.go b/server/controller/recorder/updater/pod.go index 612e6b097aa..d67539cdda9 100644 --- a/server/controller/recorder/updater/pod.go +++ b/server/controller/recorder/updater/pod.go @@ -74,7 +74,7 @@ func (p *Pod) getDiffBaseByCloudItem(cloudItem *cloudmodel.Pod) (diffBase *diffb func (p *Pod) generateDBItemToAdd(cloudItem *cloudmodel.Pod) (*mysql.Pod, bool) { vpcID, exists := p.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (p *Pod) generateDBItemToAdd(cloudItem *cloudmodel.Pod) (*mysql.Pod, bool) } podNamespaceID, exists := p.cache.ToolDataSet.GetPodNamespaceIDByLcuuid(cloudItem.PodNamespaceLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, cloudItem.PodNamespaceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -90,7 +90,7 @@ func (p *Pod) generateDBItemToAdd(cloudItem *cloudmodel.Pod) (*mysql.Pod, bool) } podClusterID, exists := p.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -98,7 +98,7 @@ func (p *Pod) generateDBItemToAdd(cloudItem *cloudmodel.Pod) (*mysql.Pod, bool) } podGroupID, exists := p.cache.ToolDataSet.GetPodGroupIDByLcuuid(cloudItem.PodGroupLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, cloudItem.PodGroupLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -106,7 +106,7 @@ func (p *Pod) generateDBItemToAdd(cloudItem *cloudmodel.Pod) (*mysql.Pod, bool) } podServiceID, exists := p.cache.ToolDataSet.GetPodServiceIDByLcuuid(cloudItem.PodServiceLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.PodServiceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -115,7 +115,7 @@ func (p *Pod) generateDBItemToAdd(cloudItem *cloudmodel.Pod) (*mysql.Pod, bool) if cloudItem.PodReplicaSetLcuuid != "" { podReplicaSetID, exists = p.cache.ToolDataSet.GetPodReplicaSetIDByLcuuid(cloudItem.PodReplicaSetLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, cloudItem.PodReplicaSetLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -155,7 +155,7 @@ func (p *Pod) generateUpdateInfo(diffBase *diffbase.Pod, cloudItem *cloudmodel.P if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := p.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -177,7 +177,7 @@ func (p *Pod) generateUpdateInfo(diffBase *diffbase.Pod, cloudItem *cloudmodel.P var exists bool podReplicaSetID, exists = p.cache.ToolDataSet.GetPodReplicaSetIDByLcuuid(cloudItem.PodReplicaSetLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, cloudItem.PodReplicaSetLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -191,7 +191,7 @@ func (p *Pod) generateUpdateInfo(diffBase *diffbase.Pod, cloudItem *cloudmodel.P if diffBase.PodGroupLcuuid != cloudItem.PodGroupLcuuid { podGroupID, exists := p.cache.ToolDataSet.GetPodGroupIDByLcuuid(cloudItem.PodGroupLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, cloudItem.PodGroupLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) @@ -204,7 +204,7 @@ func (p *Pod) generateUpdateInfo(diffBase *diffbase.Pod, cloudItem *cloudmodel.P if diffBase.PodServiceLcuuid != cloudItem.PodServiceLcuuid { podServiceID, exists := p.cache.ToolDataSet.GetPodServiceIDByLcuuid(cloudItem.PodServiceLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.PodServiceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_cluster.go b/server/controller/recorder/updater/pod_cluster.go index e3d38d7bb71..ae143686815 100644 --- a/server/controller/recorder/updater/pod_cluster.go +++ b/server/controller/recorder/updater/pod_cluster.go @@ -74,7 +74,7 @@ func (c *PodCluster) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodCluster) (d func (c *PodCluster) generateDBItemToAdd(cloudItem *cloudmodel.PodCluster) (*mysql.PodCluster, bool) { vpcID, exists := c.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(c.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(c.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_group.go b/server/controller/recorder/updater/pod_group.go index 17cc0a030a9..3eac480a910 100644 --- a/server/controller/recorder/updater/pod_group.go +++ b/server/controller/recorder/updater/pod_group.go @@ -74,7 +74,7 @@ func (p *PodGroup) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodGroup) (diffB func (p *PodGroup) generateDBItemToAdd(cloudItem *cloudmodel.PodGroup) (*mysql.PodGroup, bool) { podNamespaceID, exists := p.cache.ToolDataSet.GetPodNamespaceIDByLcuuid(cloudItem.PodNamespaceLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, cloudItem.PodNamespaceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (p *PodGroup) generateDBItemToAdd(cloudItem *cloudmodel.PodGroup) (*mysql.P } podClusterID, exists := p.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_group_port.go b/server/controller/recorder/updater/pod_group_port.go index fffad82ff22..39ee17a5d68 100644 --- a/server/controller/recorder/updater/pod_group_port.go +++ b/server/controller/recorder/updater/pod_group_port.go @@ -74,7 +74,7 @@ func (p *PodGroupPort) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodGroupPort func (p *PodGroupPort) generateDBItemToAdd(cloudItem *cloudmodel.PodGroupPort) (*mysql.PodGroupPort, bool) { podGroupID, exists := p.cache.ToolDataSet.GetPodGroupIDByLcuuid(cloudItem.PodGroupLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, cloudItem.PodGroupLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_GROUP_PORT_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (p *PodGroupPort) generateDBItemToAdd(cloudItem *cloudmodel.PodGroupPort) ( } podServiceID, exists := p.cache.ToolDataSet.GetPodServiceIDByLcuuid(cloudItem.PodServiceLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.PodServiceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_GROUP_PORT_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_ingress.go b/server/controller/recorder/updater/pod_ingress.go index df113c9a3fd..85296d99b53 100644 --- a/server/controller/recorder/updater/pod_ingress.go +++ b/server/controller/recorder/updater/pod_ingress.go @@ -74,7 +74,7 @@ func (i *PodIngress) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodIngress) (d func (i *PodIngress) generateDBItemToAdd(cloudItem *cloudmodel.PodIngress) (*mysql.PodIngress, bool) { podNamespaceID, exists := i.cache.ToolDataSet.GetPodNamespaceIDByLcuuid(cloudItem.PodNamespaceLcuuid) if !exists { - log.Error(i.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(i.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, cloudItem.PodNamespaceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (i *PodIngress) generateDBItemToAdd(cloudItem *cloudmodel.PodIngress) (*mys } podClusterID, exists := i.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(i.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(i.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_ingress_rule.go b/server/controller/recorder/updater/pod_ingress_rule.go index aaac1798d32..d8fdf80f94c 100644 --- a/server/controller/recorder/updater/pod_ingress_rule.go +++ b/server/controller/recorder/updater/pod_ingress_rule.go @@ -74,7 +74,7 @@ func (r *PodIngressRule) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodIngress func (r *PodIngressRule) generateDBItemToAdd(cloudItem *cloudmodel.PodIngressRule) (*mysql.PodIngressRule, bool) { podIngressID, exists := r.cache.ToolDataSet.GetPodIngressIDByLcuuid(cloudItem.PodIngressLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, cloudItem.PodIngressLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_ingress_rule_backend.go b/server/controller/recorder/updater/pod_ingress_rule_backend.go index 0414f89caf1..1e5cbf82c92 100644 --- a/server/controller/recorder/updater/pod_ingress_rule_backend.go +++ b/server/controller/recorder/updater/pod_ingress_rule_backend.go @@ -74,7 +74,7 @@ func (b *PodIngressRuleBackend) getDiffBaseByCloudItem(cloudItem *cloudmodel.Pod func (b *PodIngressRuleBackend) generateDBItemToAdd(cloudItem *cloudmodel.PodIngressRuleBackend) (*mysql.PodIngressRuleBackend, bool) { podIngressRuleID, exists := b.cache.ToolDataSet.GetPodIngressRuleIDByLcuuid(cloudItem.PodIngressRuleLcuuid) if !exists { - log.Error(b.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(b.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_EN, cloudItem.PodIngressRuleLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (b *PodIngressRuleBackend) generateDBItemToAdd(cloudItem *cloudmodel.PodIng } podIngressID, exists := b.cache.ToolDataSet.GetPodIngressIDByLcuuid(cloudItem.PodIngressLcuuid) if !exists { - log.Error(b.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(b.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, cloudItem.PodIngressLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN, cloudItem.Lcuuid, ))) @@ -90,7 +90,7 @@ func (b *PodIngressRuleBackend) generateDBItemToAdd(cloudItem *cloudmodel.PodIng } podServiceID, exists := b.cache.ToolDataSet.GetPodServiceIDByLcuuid(cloudItem.PodServiceLcuuid) if !exists { - log.Error(b.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(b.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.PodServiceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_RULE_BACKEND_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_namespace.go b/server/controller/recorder/updater/pod_namespace.go index 2b9cc618868..5fd25bc12df 100644 --- a/server/controller/recorder/updater/pod_namespace.go +++ b/server/controller/recorder/updater/pod_namespace.go @@ -77,7 +77,7 @@ func (n *PodNamespace) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodNamespace func (n *PodNamespace) generateDBItemToAdd(cloudItem *cloudmodel.PodNamespace) (*mysql.PodNamespace, bool) { podClusterID, exists := n.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(n.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(n.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_node.go b/server/controller/recorder/updater/pod_node.go index 9727fb6ee4b..f8445423c78 100644 --- a/server/controller/recorder/updater/pod_node.go +++ b/server/controller/recorder/updater/pod_node.go @@ -74,7 +74,7 @@ func (n *PodNode) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodNode) (diffBas func (n *PodNode) generateDBItemToAdd(cloudItem *cloudmodel.PodNode) (*mysql.PodNode, bool) { vpcID, exists := n.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(n.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(n.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (n *PodNode) generateDBItemToAdd(cloudItem *cloudmodel.PodNode) (*mysql.Pod } podClusterID, exists := n.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(n.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(n.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_replica_set.go b/server/controller/recorder/updater/pod_replica_set.go index 582b1953af5..cc8a4ac04fb 100644 --- a/server/controller/recorder/updater/pod_replica_set.go +++ b/server/controller/recorder/updater/pod_replica_set.go @@ -74,7 +74,7 @@ func (r *PodReplicaSet) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodReplicaS func (r *PodReplicaSet) generateDBItemToAdd(cloudItem *cloudmodel.PodReplicaSet) (*mysql.PodReplicaSet, bool) { podNamespaceID, exists := r.cache.ToolDataSet.GetPodNamespaceIDByLcuuid(cloudItem.PodNamespaceLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, cloudItem.PodNamespaceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (r *PodReplicaSet) generateDBItemToAdd(cloudItem *cloudmodel.PodReplicaSet) } podClusterID, exists := r.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, cloudItem.Lcuuid, ))) @@ -90,7 +90,7 @@ func (r *PodReplicaSet) generateDBItemToAdd(cloudItem *cloudmodel.PodReplicaSet) } podGroupID, exists := r.cache.ToolDataSet.GetPodGroupIDByLcuuid(cloudItem.PodGroupLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_GROUP_EN, cloudItem.PodGroupLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_REPLICA_SET_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_service.go b/server/controller/recorder/updater/pod_service.go index 1e3dc916568..c15b0ecd858 100644 --- a/server/controller/recorder/updater/pod_service.go +++ b/server/controller/recorder/updater/pod_service.go @@ -74,7 +74,7 @@ func (s *PodService) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodService) (d func (s *PodService) generateDBItemToAdd(cloudItem *cloudmodel.PodService) (*mysql.PodService, bool) { vpcID, exists := s.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid, ))) @@ -82,14 +82,14 @@ func (s *PodService) generateDBItemToAdd(cloudItem *cloudmodel.PodService) (*mys } podNamespaceID, exists := s.cache.ToolDataSet.GetPodNamespaceIDByLcuuid(cloudItem.PodNamespaceLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_NAMESPACE_EN, cloudItem.PodNamespaceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid, ))) } podClusterID, exists := s.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid, ))) @@ -99,7 +99,7 @@ func (s *PodService) generateDBItemToAdd(cloudItem *cloudmodel.PodService) (*mys if cloudItem.PodIngressLcuuid != "" { podIngressID, exists = s.cache.ToolDataSet.GetPodIngressIDByLcuuid(cloudItem.PodIngressLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, cloudItem.PodIngressLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid, ))) @@ -135,7 +135,7 @@ func (s *PodService) generateUpdateInfo(diffBase *diffbase.PodService, cloudItem var exists bool podIngressID, exists = s.cache.ToolDataSet.GetPodIngressIDByLcuuid(cloudItem.PodIngressLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_INGRESS_EN, cloudItem.PodIngressLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/pod_service_port.go b/server/controller/recorder/updater/pod_service_port.go index 44e85d600bb..0a82a2a475d 100644 --- a/server/controller/recorder/updater/pod_service_port.go +++ b/server/controller/recorder/updater/pod_service_port.go @@ -74,7 +74,7 @@ func (s *PodServicePort) getDiffBaseByCloudItem(cloudItem *cloudmodel.PodService func (p *PodServicePort) generateDBItemToAdd(cloudItem *cloudmodel.PodServicePort) (*mysql.PodServicePort, bool) { podServiceID, exists := p.cache.ToolDataSet.GetPodServiceIDByLcuuid(cloudItem.PodServiceLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_EN, cloudItem.PodServiceLcuuid, ctrlrcommon.RESOURCE_TYPE_POD_SERVICE_PORT_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/prometheus_target.go b/server/controller/recorder/updater/prometheus_target.go index 1c6a572c551..8876c5fa07b 100644 --- a/server/controller/recorder/updater/prometheus_target.go +++ b/server/controller/recorder/updater/prometheus_target.go @@ -74,7 +74,7 @@ func (p *PrometheusTarget) getDiffBaseByCloudItem(cloudItem *cloudmodel.Promethe func (p *PrometheusTarget) generateDBItemToAdd(cloudItem *cloudmodel.PrometheusTarget) (*mysql.PrometheusTarget, bool) { podClusterID, exists := p.cache.ToolDataSet.GetPodClusterIDByLcuuid(cloudItem.PodClusterLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_POD_CLUSTER_EN, cloudItem.PodClusterLcuuid, ctrlrcommon.RESOURCE_TYPE_PROMETHEUS_TARGET_EN, cloudItem.Lcuuid, ))) @@ -82,7 +82,7 @@ func (p *PrometheusTarget) generateDBItemToAdd(cloudItem *cloudmodel.PrometheusT } vpcID, exists := p.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_PROMETHEUS_TARGET_EN, cloudItem.Lcuuid, ))) @@ -127,7 +127,7 @@ func (p *PrometheusTarget) generateUpdateInfo(diffBase *diffbase.PrometheusTarge if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := p.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(p.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(p.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_PROMETHEUS_TARGET_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/rds_instance.go b/server/controller/recorder/updater/rds_instance.go index 6e9362023c9..633871c934a 100644 --- a/server/controller/recorder/updater/rds_instance.go +++ b/server/controller/recorder/updater/rds_instance.go @@ -74,7 +74,7 @@ func (r *RDSInstance) getDiffBaseByCloudItem(cloudItem *cloudmodel.RDSInstance) func (r *RDSInstance) generateDBItemToAdd(cloudItem *cloudmodel.RDSInstance) (*mysql.RDSInstance, bool) { vpcID, exists := r.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_RDS_INSTANCE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/routing_table.go b/server/controller/recorder/updater/routing_table.go index 1d6500a3052..b47f7dab7d7 100644 --- a/server/controller/recorder/updater/routing_table.go +++ b/server/controller/recorder/updater/routing_table.go @@ -74,7 +74,7 @@ func (t *RoutingTable) getDiffBaseByCloudItem(cloudItem *cloudmodel.RoutingTable func (t *RoutingTable) generateDBItemToAdd(cloudItem *cloudmodel.RoutingTable) (*mysql.RoutingTable, bool) { vrouterID, exists := t.cache.ToolDataSet.GetVRouterIDByLcuuid(cloudItem.VRouterLcuuid) if !exists { - log.Error(t.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(t.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, cloudItem.VRouterLcuuid, ctrlrcommon.RESOURCE_TYPE_ROUTING_TABLE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/subnet.go b/server/controller/recorder/updater/subnet.go index cdd3974c1d1..43c65f69656 100644 --- a/server/controller/recorder/updater/subnet.go +++ b/server/controller/recorder/updater/subnet.go @@ -75,7 +75,7 @@ func (s *Subnet) getDiffBaseByCloudItem(cloudItem *cloudmodel.Subnet) (diffBase func (s *Subnet) generateDBItemToAdd(cloudItem *cloudmodel.Subnet) (*mysql.Subnet, bool) { networkID, exists := s.cache.ToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid) if !exists { - log.Error(s.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(s.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.NetworkLcuuid, ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, cloudItem.Lcuuid, ))) @@ -83,7 +83,7 @@ func (s *Subnet) generateDBItemToAdd(cloudItem *cloudmodel.Subnet) (*mysql.Subne } prefix, netmask, err := rcommon.CIDRToPreNetMask(cloudItem.CIDR) if err != nil { - log.Error(s.metadata.LogPre("convert %s cidr: %s failed: %v", ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, cloudItem.CIDR, err)) + log.Error(s.metadata.Logf("convert %s cidr: %s failed: %v", ctrlrcommon.RESOURCE_TYPE_SUBNET_EN, cloudItem.CIDR, err)) return nil, false } diff --git a/server/controller/recorder/updater/updater.go b/server/controller/recorder/updater/updater.go index c945df3e3ba..0e4bfad65da 100644 --- a/server/controller/recorder/updater/updater.go +++ b/server/controller/recorder/updater/updater.go @@ -112,7 +112,8 @@ func newUpdaterBase[ diffBaseData: diffBaseData, cloudData: cloudData, } - u.msgMetadata = message.NewMetadata(u.metadata.GetORGID(), u.metadata.Domain.TeamID, u.metadata.Domain.ID) + u.msgMetadata = message.NewMetadata(u.metadata.GetORGID(), u.metadata.Domain.TeamID, u.metadata.Domain.ID, u.metadata.SubDomain.ID) + log.Infof(u.metadata.Logf("new updater for resource type: %s, message metadata: %#v", resourceType, u.msgMetadata)) // TODO debug u.initPubSub() return u } @@ -120,7 +121,7 @@ func newUpdaterBase[ func (u *UpdaterBase[CT, MT, BT, MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) initPubSub() { ps := pubsub.GetPubSub(u.resourceType) if ps == nil { - log.Error(u.metadata.LogPre("pubsub not found for resource type: %s", u.resourceType)) + log.Error(u.metadata.Logf("pubsub not found for resource type: %s", u.resourceType)) return } u.pubsub = ps.(pubsub.ResourcePubSub[MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) @@ -144,11 +145,11 @@ func (u *UpdaterBase[CT, MT, BT, MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) logDebug := logDebugResourceTypeEnabled(u.resourceType) for _, cloudItem := range u.cloudData { if logDebug { - log.Info(u.metadata.LogPre(debugCloudItem(u.resourceType, cloudItem))) + log.Info(u.metadata.Logf(debugCloudItem(u.resourceType, cloudItem))) } diffBase, exists := u.dataGenerator.getDiffBaseByCloudItem(&cloudItem) if !exists { - log.Info(u.metadata.LogPre("to add (cloud item: %#v)", cloudItem)) + log.Info(u.metadata.Logf("to add (cloud item: %#v)", cloudItem)) dbItem, ok := u.dataGenerator.generateDBItemToAdd(&cloudItem) if ok { dbItemsToAdd = append(dbItemsToAdd, dbItem) @@ -157,7 +158,7 @@ func (u *UpdaterBase[CT, MT, BT, MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) diffBase.SetSequence(u.cache.GetSequence()) structInfo, mapInfo, ok := u.dataGenerator.generateUpdateInfo(diffBase, &cloudItem) if ok { - log.Info(u.metadata.LogPre("to update (cloud item: %#v, diff base item: %#v)", cloudItem, diffBase)) + log.Info(u.metadata.Logf("to update (cloud item: %#v, diff base item: %#v)", cloudItem, diffBase)) u.update(&cloudItem, diffBase, mapInfo, structInfo) } } @@ -171,7 +172,7 @@ func (u *UpdaterBase[CT, MT, BT, MAPT, MAT, MUPT, MUT, MFUPT, MFUT, MDPT, MDT]) lcuuidsOfBatchToDelete := []string{} for lcuuid, diffBase := range u.diffBaseData { if diffBase.GetSequence() != u.cache.GetSequence() { - log.Info(u.metadata.LogPre("to delete (diff base item: %#v)", diffBase)) + log.Info(u.metadata.Logf("to delete (diff base item: %#v)", diffBase)) lcuuidsOfBatchToDelete = append(lcuuidsOfBatchToDelete, lcuuid) } } diff --git a/server/controller/recorder/updater/vinterface.go b/server/controller/recorder/updater/vinterface.go index e6b96b5982e..81d3a72b070 100644 --- a/server/controller/recorder/updater/vinterface.go +++ b/server/controller/recorder/updater/vinterface.go @@ -85,7 +85,7 @@ func (i *VInterface) generateDBItemToAdd(cloudItem *cloudmodel.VInterface) (*mys networkID, exists = i.domainToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid) } if !exists { - log.Error(i.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(i.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.NetworkLcuuid, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid, ))) @@ -95,7 +95,7 @@ func (i *VInterface) generateDBItemToAdd(cloudItem *cloudmodel.VInterface) (*mys } deviceID, exists := i.cache.ToolDataSet.GetDeviceIDByDeviceLcuuid(cloudItem.DeviceType, cloudItem.DeviceLcuuid) if !exists { - log.Error(i.metadata.LogPre( + log.Error(i.metadata.Logf( "device (type: %d, lcuuid: %s) for %s (lcuuid: %s) not found", cloudItem.DeviceType, cloudItem.DeviceLcuuid, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid, @@ -136,7 +136,7 @@ func (i *VInterface) generateUpdateInfo(diffBase *diffbase.VInterface, cloudItem networkID, exists = i.domainToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid) } if !exists { - log.Error(i.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(i.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_NETWORK_EN, cloudItem.NetworkLcuuid, ctrlrcommon.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/vm.go b/server/controller/recorder/updater/vm.go index 5d5ed602298..e624d7aa632 100644 --- a/server/controller/recorder/updater/vm.go +++ b/server/controller/recorder/updater/vm.go @@ -77,7 +77,7 @@ func (m *VM) getDiffBaseByCloudItem(cloudItem *cloudmodel.VM) (diffBase *diffbas func (m *VM) generateDBItemToAdd(cloudItem *cloudmodel.VM) (*mysql.VM, bool) { vpcID, exists := m.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(m.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(m.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_VM_EN, cloudItem.Lcuuid, ))) @@ -120,7 +120,7 @@ func (m *VM) generateUpdateInfo(diffBase *diffbase.VM, cloudItem *cloudmodel.VM) if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := m.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(m.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(m.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_VM_EN, cloudItem.Lcuuid, ))) diff --git a/server/controller/recorder/updater/vrouter.go b/server/controller/recorder/updater/vrouter.go index 546e8d27b0f..466c38e1828 100644 --- a/server/controller/recorder/updater/vrouter.go +++ b/server/controller/recorder/updater/vrouter.go @@ -75,7 +75,7 @@ func (r *VRouter) getDiffBaseByCloudItem(cloudItem *cloudmodel.VRouter) (diffBas func (r *VRouter) generateDBItemToAdd(cloudItem *cloudmodel.VRouter) (*mysql.VRouter, bool) { vpcID, exists := r.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, cloudItem.Lcuuid, ))) @@ -100,7 +100,7 @@ func (r *VRouter) generateUpdateInfo(diffBase *diffbase.VRouter, cloudItem *clou if diffBase.VPCLcuuid != cloudItem.VPCLcuuid { vpcID, exists := r.cache.ToolDataSet.GetVPCIDByLcuuid(cloudItem.VPCLcuuid) if !exists { - log.Error(r.metadata.LogPre(resourceAForResourceBNotFound( + log.Error(r.metadata.Logf(resourceAForResourceBNotFound( ctrlrcommon.RESOURCE_TYPE_VPC_EN, cloudItem.VPCLcuuid, ctrlrcommon.RESOURCE_TYPE_VROUTER_EN, cloudItem.Lcuuid, )))