Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/helpers/agent-auth-error-codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module.exports = {
CONTROLLER_DB_BUSY: 'CONTROLLER_DB_BUSY',
CONTROLLER_VAULT_UNAVAILABLE: 'CONTROLLER_VAULT_UNAVAILABLE',
CONTROLLER_AUTH_VERIFICATION_FAILED: 'CONTROLLER_AUTH_VERIFICATION_FAILED',
CONTROLLER_AGENT_CLOCK_SKEW: 'CONTROLLER_AGENT_CLOCK_SKEW',
CONTROLLER_NOT_READY: 'CONTROLLER_NOT_READY'
}
15 changes: 15 additions & 0 deletions src/helpers/agent-auth-error-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ function classifyVerifyJwtFailure (error) {
if (errorName === 'JWSSignatureVerificationFailed' || message.includes('signature verification failed') || message.includes('invalid signature')) {
return new AgentAuthenticationError(CODES.AGENT_JWT_SIGNATURE_INVALID, 'Agent JWT signature invalid')
}
if (errorName === 'JWTClaimValidationFailed' &&
(message.includes('"nbf" claim timestamp check failed') || message.includes('"iat" claim timestamp check failed'))) {
// The agent signs every request with nbf = iat = its own clock, and the
// controller verifies with a 10 s tolerance, so this means the agent's
// clock runs ahead of the controller's. Deliberately reported as a
// retryable ServiceUnavailableError, not as a 401: an agent that gets
// non-retryable auth failures deprovisions itself after 5 attempts over
// 60 s (edgelet internal/fieldagent/status_auth_gate.go), which would
// turn a few seconds of clock drift into a node that has to be
// bootstrapped again. Retrying is right; only the diagnosis was missing.
return new ServiceUnavailableError(
CODES.CONTROLLER_AGENT_CLOCK_SKEW,
`Agent clock is ahead of the controller: ${message}`
)
}
if (isVaultInfrastructureError(error)) {
return new ServiceUnavailableError(CODES.CONTROLLER_VAULT_UNAVAILABLE, 'Vault temporarily unavailable')
}
Expand Down