Validate deployment polling intervals

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Yoann Chaudet
2026-09-01 14:13:45 -07:00
parent 0143e11abb
commit 7e97763d1f
6 changed files with 70 additions and 18 deletions

View File

@@ -24,6 +24,7 @@ const finalErrorStatus = {
}
const MAX_TIMEOUT = 600000
const DEFAULT_REPORTING_INTERVAL = 5000
const MAX_REPORTING_INTERVAL = 30000
const REPORTING_BACKOFF_MULTIPLIER = 1.5
const REPORTING_JITTER_FACTOR = 0.2
@@ -146,9 +147,19 @@ class Deployment {
}
const deploymentId = this.deploymentInfo.id || this.buildVersion
let reportingInterval = Number(core.getInput('reporting_interval'))
const reportingIntervalInput = Number(core.getInput('reporting_interval'))
const initialReportingInterval =
Number.isFinite(reportingIntervalInput) && reportingIntervalInput > 0
? reportingIntervalInput
: DEFAULT_REPORTING_INTERVAL
const maxReportingInterval = Math.max(MAX_REPORTING_INTERVAL, initialReportingInterval)
const maxErrorCount = Number(core.getInput('error_count'))
if (initialReportingInterval !== reportingIntervalInput) {
core.warning(`Invalid reporting_interval value; using the default of ${DEFAULT_REPORTING_INTERVAL} milliseconds.`)
}
let reportingInterval = initialReportingInterval
let errorCount = 0
// Time in milliseconds between two deployment status report when status errored, default 0.
@@ -187,10 +198,7 @@ class Deployment {
// reset the error reporting interval once get the proper status back.
errorReportingInterval = 0
reportingInterval = Math.min(
Math.round(reportingInterval * REPORTING_BACKOFF_MULTIPLIER),
MAX_REPORTING_INTERVAL
)
reportingInterval = Math.min(Math.round(reportingInterval * REPORTING_BACKOFF_MULTIPLIER), maxReportingInterval)
} catch (error) {
core.error(error.stack)
@@ -257,6 +265,7 @@ class Deployment {
module.exports = {
Deployment,
MAX_TIMEOUT,
DEFAULT_REPORTING_INTERVAL,
MAX_REPORTING_INTERVAL,
ONE_GIGABYTE,
SIZE_LIMIT_DESCRIPTION