feat(ops): add Log Center env vars to K8s and CI/CD failure reporting
Some checks failed
Build and Deploy Backend / build-and-deploy (push) Failing after 1m6s

- K8s: add ENVIRONMENT, LOG_CENTER_URL, LOG_CENTER_ENABLED to dev/prod
- CI/CD: report build/deploy failures to Log Center (source: cicd)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
repair-agent 2026-02-24 13:17:11 +08:00
parent c584df814f
commit 7603b15ffb
3 changed files with 50 additions and 4 deletions

View File

@ -61,13 +61,43 @@ jobs:
INGRESS_FILE="k8s/ingress-dev.yaml" INGRESS_FILE="k8s/ingress-dev.yaml"
DEPLOY_NAME="rtc-backend-dev" DEPLOY_NAME="rtc-backend-dev"
fi fi
# 2. 替换镜像地址 # 2. 替换镜像地址
sed -i "s|\${CI_REGISTRY_IMAGE}/backend:latest|${{ secrets.SWR_SERVER }}/${{ secrets.SWR_ORG }}/rtc-backend:latest|g" $DEPLOY_FILE sed -i "s|\${CI_REGISTRY_IMAGE}/backend:latest|${{ secrets.SWR_SERVER }}/${{ secrets.SWR_ORG }}/rtc-backend:latest|g" $DEPLOY_FILE
# 3. 应用配置 # 3. 应用配置
# kubectl apply -f k8s/redis-deployment.yaml (Cloud Redis used, skipping)
kubectl apply -f $DEPLOY_FILE kubectl apply -f $DEPLOY_FILE
kubectl apply -f $INGRESS_FILE kubectl apply -f $INGRESS_FILE
kubectl rollout restart deployment/$DEPLOY_NAME kubectl rollout restart deployment/$DEPLOY_NAME
- name: Report failure to Log Center
if: failure()
run: |
curl -s -X POST "https://qiyuan-log-center-api.airlabs.art/api/v1/logs/report" \
-H "Content-Type: application/json" \
-d "{
\"project_id\": \"rtc_backend\",
\"environment\": \"${{ github.ref_name }}\",
\"level\": \"ERROR\",
\"source\": \"cicd\",
\"commit_hash\": \"${{ github.sha }}\",
\"repo_url\": \"https://gitea.airlabs.art/zyc/rtc_backend.git\",
\"error\": {
\"type\": \"CICDFailure\",
\"message\": \"Build and Deploy failed on branch ${{ github.ref_name }}\",
\"stack_trace\": [
\"Repository: ${{ github.repository }}\",
\"Branch: ${{ github.ref_name }}\",
\"Commit: ${{ github.sha }}\",
\"Run ID: ${{ github.run_id }}\",
\"Actor: ${{ github.actor }}\"
]
},
\"context\": {
\"workflow\": \"${{ github.workflow }}\",
\"run_id\": \"${{ github.run_id }}\",
\"branch\": \"${{ github.ref_name }}\",
\"actor\": \"${{ github.actor }}\"
}
}" || true

View File

@ -60,6 +60,14 @@ spec:
value: "LTAI5tBGAkR2rra2prTAX9yc" value: "LTAI5tBGAkR2rra2prTAX9yc"
- name: ALIYUN_LOG_ACCESS_KEY_SECRET - name: ALIYUN_LOG_ACCESS_KEY_SECRET
value: "U1z3d0p5saPRD5sCxVooJYSjxSAmKB" value: "U1z3d0p5saPRD5sCxVooJYSjxSAmKB"
# Log Center
- name: ENVIRONMENT
value: "development"
- name: LOG_CENTER_URL
value: "https://qiyuan-log-center-api.airlabs.art"
- name: LOG_CENTER_ENABLED
value: "true"
resources: resources:
requests: requests:
memory: "256Mi" memory: "256Mi"

View File

@ -68,6 +68,14 @@ spec:
value: "https://qiyuan-rtc-web.airlabs.art,https://qiyuan-rtc-dev-web.airlabs.art" value: "https://qiyuan-rtc-web.airlabs.art,https://qiyuan-rtc-dev-web.airlabs.art"
- name: CSRF_TRUSTED_ORIGINS - name: CSRF_TRUSTED_ORIGINS
value: "https://qiyuan-rtc-web.airlabs.art,https://qiyuan-rtc-dev-web.airlabs.art,https://qiyuan-rtc-api.airlabs.art" value: "https://qiyuan-rtc-web.airlabs.art,https://qiyuan-rtc-dev-web.airlabs.art,https://qiyuan-rtc-api.airlabs.art"
# Log Center
- name: ENVIRONMENT
value: "production"
- name: LOG_CENTER_URL
value: "https://qiyuan-log-center-api.airlabs.art"
- name: LOG_CENTER_ENABLED
value: "true"
resources: resources:
requests: requests:
memory: "256Mi" memory: "256Mi"