Skip to content

Commit fad60e4

Browse files
authored
fix: remove test log (#2432)
Signed-off-by: 张启航 <[email protected]>
1 parent 797234e commit fad60e4

File tree

1 file changed

+2
-162
lines changed

1 file changed

+2
-162
lines changed

worker/appm/store/store.go

Lines changed: 2 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -405,45 +405,13 @@ func (a *appRuntimeStore) OnAdd(obj interface{}) {
405405
createrID := deployment.Labels["creater_id"]
406406
migrator := deployment.Labels["migrator"]
407407
appID := deployment.Labels["app_id"]
408-
409-
// 目标service_id用于调试
410-
targetServiceID := "f2aa2032719d4b82bc3d0cf6d44d4488"
411-
412408
if serviceID != "" && version != "" && createrID != "" {
413-
replicas := int32(0)
414-
if deployment.Spec.Replicas != nil {
415-
replicas = *deployment.Spec.Replicas
416-
}
417-
418-
if serviceID == targetServiceID {
419-
logrus.Errorf("[目标组件调试] ========== Deployment OnAdd 事件触发 ==========")
420-
logrus.Errorf("[目标组件调试] Deployment名称: %s", deployment.Name)
421-
logrus.Errorf("[目标组件调试] 命名空间: %s", deployment.Namespace)
422-
logrus.Errorf("[目标组件调试] version标签: %s", version)
423-
logrus.Errorf("[目标组件调试] ReadyReplicas: %d", deployment.Status.ReadyReplicas)
424-
logrus.Errorf("[目标组件调试] 期望副本数: %d", replicas)
425-
}
426-
427-
logrus.Infof("[Deployment新增] 检测到 %s 的 Deployment: %s, service_id=%s, version=%s, ReadyReplicas=%d, DesiredReplicas=%d",
428-
deployment.Namespace, deployment.Name, serviceID, version,
429-
deployment.Status.ReadyReplicas, replicas)
430-
431409
appservice, err := a.getAppService(serviceID, version, createrID, true)
432410
if err == conversion.ErrServiceNotFound {
433411
a.k8sClient.Clientset.AppsV1().Deployments(deployment.Namespace).Delete(context.Background(), deployment.Name, metav1.DeleteOptions{})
434412
}
435413
if appservice != nil {
436414
appservice.SetDeployment(deployment)
437-
438-
if serviceID == targetServiceID {
439-
logrus.Errorf("[目标组件调试] SetDeployment 执行成功")
440-
logrus.Errorf("[目标组件调试] AppService.DeployVersion: %s", appservice.DeployVersion)
441-
logrus.Errorf("[目标组件调试] AppService.Replicas: %d", appservice.Replicas)
442-
logrus.Errorf("[目标组件调试] 当前Pod数量: %d", len(appservice.GetPods(false)))
443-
}
444-
445-
logrus.Infof("[Deployment新增] %s Deployment %s: 成功设置到 AppService (serviceID=%s, AppService.Replicas=%d, CurrentPodCount=%d)",
446-
deployment.Namespace, deployment.Name, serviceID, appservice.Replicas, len(appservice.GetPods(false)))
447415
if migrator == "rainbond" {
448416
label := "service_id=" + serviceID
449417
pods, _ := a.k8sClient.Clientset.CoreV1().Pods(deployment.Namespace).List(context.Background(), metav1.ListOptions{LabelSelector: label})
@@ -1159,8 +1127,6 @@ func (a *appRuntimeStore) DeleteAppService(app *v1.AppService) {
11591127
// DeleteAppServiceByKey delete cache app service
11601128
func (a *appRuntimeStore) DeleteAppServiceByKey(key v1.CacheKey) {
11611129
a.appServices.Delete(key)
1162-
newCount := atomic.AddInt32(&a.appCount, -1)
1163-
logrus.Debugf("current have %d app after delete \n", newCount)
11641130
}
11651131

11661132
func (a *appRuntimeStore) GetAppService(serviceID string) *v1.AppService {
@@ -1348,62 +1314,15 @@ func (a *appRuntimeStore) GetAppServiceStatuses(serviceIDs []string) map[string]
13481314
statusMap := make(map[string]string, len(serviceIDs))
13491315
var queryComponentIDs []string
13501316

1351-
// 目标service_id用于调试
1352-
targetServiceID := "f2aa2032719d4b82bc3d0cf6d44d4488"
1353-
13541317
for _, serviceID := range serviceIDs {
13551318
app := a.GetAppService(serviceID)
13561319
if app == nil {
1357-
if serviceID == targetServiceID {
1358-
logrus.Errorf("[目标组件调试] ========== GetAppServiceStatuses 被调用 ==========")
1359-
logrus.Errorf("[目标组件调试] AppService 在内存中不存在!将检查数据库和K8s")
1360-
}
13611320
queryComponentIDs = append(queryComponentIDs, serviceID)
13621321
continue
13631322
}
13641323

1365-
// 详细日志
1366-
if serviceID == targetServiceID {
1367-
deployment := app.GetDeployment()
1368-
statefulset := app.GetStatefulSet()
1369-
pods := app.GetPods(false)
1370-
1371-
logrus.Errorf("[目标组件调试] ========== GetAppServiceStatuses 被调用 ==========")
1372-
logrus.Errorf("[目标组件调试] AppService 在内存中找到")
1373-
logrus.Errorf("[目标组件调试] ServiceAlias: %s", app.ServiceAlias)
1374-
logrus.Errorf("[目标组件调试] TenantID: %s", app.TenantID)
1375-
logrus.Errorf("[目标组件调试] DeployVersion: %s", app.DeployVersion)
1376-
logrus.Errorf("[目标组件调试] 期望副本数: %d", app.Replicas)
1377-
logrus.Errorf("[目标组件调试] Deployment存在: %v", deployment != nil)
1378-
if deployment != nil {
1379-
logrus.Errorf("[目标组件调试] Deployment.ReadyReplicas: %d", deployment.Status.ReadyReplicas)
1380-
logrus.Errorf("[目标组件调试] Deployment.Replicas: %d", *deployment.Spec.Replicas)
1381-
}
1382-
logrus.Errorf("[目标组件调试] StatefulSet存在: %v", statefulset != nil)
1383-
logrus.Errorf("[目标组件调试] Pod总数: %d", len(pods))
1384-
for i, pod := range pods {
1385-
podReady := false
1386-
if pod.Status.Phase == corev1.PodRunning {
1387-
for _, cond := range pod.Status.Conditions {
1388-
if cond.Type == corev1.PodReady && cond.Status == corev1.ConditionTrue {
1389-
podReady = true
1390-
break
1391-
}
1392-
}
1393-
}
1394-
logrus.Errorf("[目标组件调试] Pod[%d] 名称: %s", i, pod.Name)
1395-
logrus.Errorf("[目标组件调试] Pod[%d] version: %s", i, pod.Labels["version"])
1396-
logrus.Errorf("[目标组件调试] Pod[%d] 状态: %s", i, pod.Status.Phase)
1397-
logrus.Errorf("[目标组件调试] Pod[%d] Ready: %v", i, podReady)
1398-
}
1399-
}
1400-
14011324
status := app.GetServiceStatus()
14021325

1403-
if serviceID == targetServiceID {
1404-
logrus.Errorf("[目标组件调试] 最终返回状态: %s", status)
1405-
}
1406-
14071326
if status == v1.UNKNOW {
14081327
app := a.UpdateGetAppService(serviceID)
14091328
if app == nil {
@@ -1787,73 +1706,17 @@ func (a *appRuntimeStore) podEventHandler() cache.ResourceEventHandlerFuncs {
17871706
AddFunc: func(obj interface{}) {
17881707
pod := obj.(*corev1.Pod)
17891708
a.resourceCache.SetPodResource(pod)
1790-
tenantID, serviceID, version, createrID := k8sutil.ExtractLabels(pod.GetLabels())
1791-
1792-
// 目标service_id用于调试
1793-
targetServiceID := "f2aa2032719d4b82bc3d0cf6d44d4488"
1794-
1795-
// rbd-prd 命名空间的详细日志
1796-
if pod.Namespace == "rbd-prd" {
1797-
logrus.Infof("[Pod新增] 检测到 rbd-prd 的 Pod: %s, tenant_id=%s, service_id=%s, version=%s, creater_id=%s",
1798-
pod.Name, tenantID, serviceID, version, createrID)
1799-
}
1800-
1801-
if serviceID == targetServiceID {
1802-
podReady := false
1803-
if pod.Status.Phase == corev1.PodRunning {
1804-
for _, cond := range pod.Status.Conditions {
1805-
if cond.Type == corev1.PodReady && cond.Status == corev1.ConditionTrue {
1806-
podReady = true
1807-
break
1808-
}
1809-
}
1810-
}
1811-
logrus.Errorf("[目标组件调试] ========== Pod OnAdd 事件触发 ==========")
1812-
logrus.Errorf("[目标组件调试] Pod名称: %s", pod.Name)
1813-
logrus.Errorf("[目标组件调试] 命名空间: %s", pod.Namespace)
1814-
logrus.Errorf("[目标组件调试] version标签: %s", version)
1815-
logrus.Errorf("[目标组件调试] Pod状态: %s", pod.Status.Phase)
1816-
logrus.Errorf("[目标组件调试] Pod是否Ready: %v", podReady)
1817-
}
1709+
_, serviceID, version, createrID := k8sutil.ExtractLabels(pod.GetLabels())
18181710

18191711
// 检查必需标签是否存在
18201712
if serviceID == "" || version == "" || createrID == "" {
1821-
if pod.Namespace == "rbd-prd" {
1822-
logrus.Warnf("[Pod新增] rbd-prd Pod %s 缺少必需标签,将被忽略 - service_id=%q, version=%q, creater_id=%q, 所有标签: %v",
1823-
pod.Name, serviceID, version, createrID, pod.GetLabels())
1824-
}
18251713
return
18261714
}
18271715

18281716
if serviceID != "" && version != "" && createrID != "" {
18291717
appservice, err := a.getAppService(serviceID, version, createrID, true)
18301718

1831-
if serviceID == targetServiceID {
1832-
if appservice != nil {
1833-
logrus.Errorf("[目标组件调试] 找到AppService,准备添加Pod")
1834-
logrus.Errorf("[目标组件调试] AppService.DeployVersion: %s", appservice.DeployVersion)
1835-
} else {
1836-
logrus.Errorf("[目标组件调试] AppService为nil, 错误: %v", err)
1837-
}
1838-
}
1839-
1840-
if pod.Namespace == "rbd-prd" {
1841-
if err != nil {
1842-
logrus.Warnf("[Pod新增] rbd-prd Pod %s: 获取 AppService 失败 - %v (serviceID=%s, version=%s, createrID=%s)",
1843-
pod.Name, err, serviceID, version, createrID)
1844-
} else if appservice == nil {
1845-
logrus.Warnf("[Pod新增] rbd-prd Pod %s: AppService 为空,无法添加 (serviceID=%s, version=%s, createrID=%s)",
1846-
pod.Name, serviceID, version, createrID)
1847-
} else {
1848-
logrus.Infof("[Pod新增] rbd-prd Pod %s: 成功添加到 AppService (serviceID=%s, 当前Pod数量=%d)",
1849-
pod.Name, serviceID, len(appservice.GetPods(false))+1)
1850-
}
1851-
}
1852-
18531719
if err == conversion.ErrServiceNotFound {
1854-
if pod.Namespace == "rbd-prd" {
1855-
logrus.Warnf("[Pod新增] rbd-prd Pod %s: 数据库中未找到服务,将删除该 Pod (serviceID=%s)", pod.Name, serviceID)
1856-
}
18571720
a.k8sClient.Clientset.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, metav1.DeleteOptions{})
18581721
}
18591722
if appservice != nil {
@@ -1886,40 +1749,17 @@ func (a *appRuntimeStore) podEventHandler() cache.ResourceEventHandlerFuncs {
18861749
UpdateFunc: func(old, cur interface{}) {
18871750
pod := cur.(*corev1.Pod)
18881751
a.resourceCache.SetPodResource(pod)
1889-
tenantID, serviceID, version, createrID := k8sutil.ExtractLabels(pod.GetLabels())
1890-
1891-
// rbd-prd 命名空间的详细日志
1892-
if pod.Namespace == "rbd-prd" {
1893-
logrus.Infof("[Pod更新] 检测到 rbd-prd 的 Pod: %s, tenant_id=%s, service_id=%s, version=%s, creater_id=%s, Phase=%s",
1894-
pod.Name, tenantID, serviceID, version, createrID, pod.Status.Phase)
1895-
}
1752+
_, serviceID, version, createrID := k8sutil.ExtractLabels(pod.GetLabels())
18961753

18971754
// 检查必需标签是否存在
18981755
if serviceID == "" || version == "" || createrID == "" {
1899-
if pod.Namespace == "rbd-prd" {
1900-
logrus.Warnf("[Pod更新] rbd-prd Pod %s 缺少必需标签,将被忽略 - service_id=%q, version=%q, creater_id=%q",
1901-
pod.Name, serviceID, version, createrID)
1902-
}
19031756
return
19041757
}
19051758

19061759
if serviceID != "" && version != "" && createrID != "" {
19071760
appservice, err := a.getAppService(serviceID, version, createrID, true)
19081761

1909-
if pod.Namespace == "rbd-prd" {
1910-
if err != nil {
1911-
logrus.Warnf("[Pod更新] rbd-prd Pod %s: 获取 AppService 失败 - %v", pod.Name, err)
1912-
} else if appservice == nil {
1913-
logrus.Warnf("[Pod更新] rbd-prd Pod %s: AppService 为空,无法更新", pod.Name)
1914-
} else {
1915-
logrus.Infof("[Pod更新] rbd-prd Pod %s: 成功更新到 AppService (serviceID=%s)", pod.Name, serviceID)
1916-
}
1917-
}
1918-
19191762
if err == conversion.ErrServiceNotFound {
1920-
if pod.Namespace == "rbd-prd" {
1921-
logrus.Warnf("[Pod更新] rbd-prd Pod %s: 数据库中未找到服务,将删除该 Pod", pod.Name)
1922-
}
19231763
a.k8sClient.Clientset.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, metav1.DeleteOptions{})
19241764
}
19251765
if appservice != nil {

0 commit comments

Comments
 (0)