Skip to content

Commit

Permalink
bug: 容量上报增加字段以及重试 #2870
Browse files Browse the repository at this point in the history
  • Loading branch information
zacYL committed Jan 10, 2025
1 parent bc862dc commit ccbd704
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package com.tencent.bkrepo.job.batch.task.usage
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonProperty
import com.tencent.bkrepo.common.api.constant.MediaTypes
import com.tencent.bkrepo.common.api.constant.retry
import com.tencent.bkrepo.common.api.util.JsonUtils
import com.tencent.bkrepo.common.storage.innercos.http.toRequestBody
import com.tencent.bkrepo.job.BATCH_SIZE
Expand Down Expand Up @@ -130,7 +131,8 @@ class ProjectMonthMetricReportJob(
logger.info("report project month usage with size ${projectMonthUsage.size}")
val bkMonthUsage = BkMonthUsage(
dataSourceName = properties.reportServiceName,
bills = projectMonthUsage
bills = projectMonthUsage,
month = projectMonthUsage.first().costDate
)
val bkMonthUsageSummary = BkMonthUsageSummary(bkMonthUsage)
reportUsageData(bkMonthUsageSummary)
Expand All @@ -143,7 +145,9 @@ class ProjectMonthMetricReportJob(
try {
val request = Request.Builder().url(url).header(PLATFORM_KEY_HEADER, properties.reportPlatformKey)
.post(requestBody).build()
doRequest(okHttpClient, request)
retry(RETRY_COUNT, 1) {
doRequest(okHttpClient, request)
}
} catch (exception: Exception) {
logger.warn("report usage data error:", exception)
}
Expand Down Expand Up @@ -231,5 +235,6 @@ class ProjectMonthMetricReportJob(
private val logger = LoggerFactory.getLogger(ProjectMonthMetricReportJob::class.java)
private const val COLLECTION_NAME_PROJECT_METRICS_DAILY_AVG_RECORD = "project_metrics_daily_avg_record"
private const val PLATFORM_KEY_HEADER = "Platform-Key"
private const val RETRY_COUNT = 3
}
}

0 comments on commit ccbd704

Please sign in to comment.