mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-13 07:54:01 +00:00
Don't revert to regular pull if delta server 401
If the Supervisor receives a 401 Unauthorized from the delta server when requesting a delta image location, we should surface the error instead of falling back to a regular pull immediately, as there could be an issue with the delta auth token, which refreshes after DELTA_TOKEN_TIMEOUT (10min), or some other edge case. Change-type: patch Signed-off-by: Christina Ying Wang <christina@balena.io>
This commit is contained in:
parent
b6f0ecba18
commit
2dc9d275b1
@ -219,9 +219,17 @@ export async function fetchDeltaWithProgress(
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// If 400s status code, throw a more specific error & revert immediately to a regular pull
|
||||
// If 400s status code, throw a more specific error & revert immediately to a regular pull,
|
||||
// unless the code is 401 Unauthorized, in which case we should surface the error by retrying
|
||||
// the delta server request, instead of falling back to a regular pull immediately.
|
||||
if (res.statusCode >= 400 && res.statusCode < 500) {
|
||||
throw new DeltaServerError(res.statusCode, res.statusMessage);
|
||||
if (res.statusCode === 401) {
|
||||
throw new Error(
|
||||
`Got ${res.statusCode} when requesting an image from delta server: ${res.statusMessage}`,
|
||||
);
|
||||
} else {
|
||||
throw new DeltaServerError(res.statusCode, res.statusMessage);
|
||||
}
|
||||
}
|
||||
if (res.statusCode !== 200) {
|
||||
throw new Error(
|
||||
|
Loading…
x
Reference in New Issue
Block a user