(lcuuid string, kubernetesGatherResource kubernetes_model.KubernetesGatherResource, cResource model.Resource)
| 59 | } |
| 60 | |
| 61 | func (c *Cloud) generateSubDomainResource(lcuuid string, kubernetesGatherResource kubernetes_model.KubernetesGatherResource, cResource model.Resource) model.SubDomainResource { |
| 62 | |
| 63 | if kubernetesGatherResource.ErrorState != common.RESOURCE_STATE_CODE_SUCCESS { |
| 64 | return model.SubDomainResource{ |
| 65 | ErrorState: kubernetesGatherResource.ErrorState, |
| 66 | ErrorMessage: kubernetesGatherResource.ErrorMessage, |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // 容器节点及与虚拟机关联关系 |
| 71 | podNodes, vmPodNodeConnections, nodeLcuuidToAZLcuuid := c.getSubDomainPodNodes(lcuuid, cResource, &kubernetesGatherResource) |
| 72 | // 如果当前KubernetesGather数据中没有与主云平台相关的容器节点,则跳过该集群 |
| 73 | if len(podNodes) == 0 { |
| 74 | msg := "gather node is not associated with cloud vm" |
| 75 | log.Warning(msg, logger.NewORGPrefix(c.orgID)) |
| 76 | return model.SubDomainResource{ |
| 77 | ErrorState: common.RESOURCE_STATE_CODE_WARNING, |
| 78 | ErrorMessage: msg, |
| 79 | } |
| 80 | } |
| 81 | // 取集群中某个容器节点的az信息作为集群的az,当前不支持附属容器集群跨可用区 |
| 82 | azLcuuid := podNodes[0].AZLcuuid |
| 83 | |
| 84 | // 获取主云平台vm的ip和mac在附属容器中排除,以免重复添加 |
| 85 | vmLcuuids := map[string]bool{} |
| 86 | for _, vm := range cResource.VMs { |
| 87 | vmLcuuids[vm.Lcuuid] = false |
| 88 | } |
| 89 | existMacs := map[string]bool{} |
| 90 | vinterfaceLcuuids := map[string]bool{} |
| 91 | for _, v := range cResource.VInterfaces { |
| 92 | if v.Mac == common.VIF_DEFAULT_MAC { |
| 93 | continue |
| 94 | } |
| 95 | if _, ok := vmLcuuids[v.DeviceLcuuid]; !ok { |
| 96 | continue |
| 97 | } |
| 98 | existMacs[v.Mac] = false |
| 99 | vinterfaceLcuuids[v.Lcuuid] = false |
| 100 | } |
| 101 | existIPs := map[string]bool{} |
| 102 | for _, ip := range cResource.IPs { |
| 103 | if _, ok := vinterfaceLcuuids[ip.VInterfaceLcuuid]; !ok { |
| 104 | continue |
| 105 | } |
| 106 | existIPs[ip.IP] = false |
| 107 | } |
| 108 | |
| 109 | // 容器集群 |
| 110 | podClusters := c.getSubDomainPodClusters(lcuuid, &kubernetesGatherResource, azLcuuid) |
| 111 | |
| 112 | // 命名空间 |
| 113 | podNamespaces := c.getSubDomainPodNamespaces(lcuuid, &kubernetesGatherResource, azLcuuid) |
| 114 | |
| 115 | // Ingress及规则 |
| 116 | podIngresses, podIngressRules, podIngressRuleBackends := c.getSubDomainIngresses( |
| 117 | lcuuid, &kubernetesGatherResource, azLcuuid, |
| 118 | ) |
no test coverage detected