Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: 容量上报增加字段以及重试 #2870 #2918

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading