From dfd431959a08bcfffe1d00687ca486e975e66835 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:25:30 +0100 Subject: [PATCH] add flag to simulate checkpoint push failure --- apps/coordinator/src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/coordinator/src/index.ts b/apps/coordinator/src/index.ts index 340137905..cd4a16f79 100644 --- a/apps/coordinator/src/index.ts +++ b/apps/coordinator/src/index.ts @@ -28,6 +28,7 @@ const FORCE_CHECKPOINT_SIMULATION = ["1", "true"].includes( const DISABLE_CHECKPOINT_SUPPORT = ["1", "true"].includes( process.env.DISABLE_CHECKPOINT_SUPPORT ?? "false" ); +const SIMULATE_PUSH_FAILURE = ["1", "true"].includes(process.env.SIMULATE_PUSH_FAILURE ?? "false"); const REGISTRY_HOST = process.env.REGISTRY_HOST || "localhost:5000"; const CHECKPOINT_PATH = process.env.CHECKPOINT_PATH || "/checkpoints"; @@ -489,6 +490,13 @@ class Checkpointer { this.#logger.debug(await $$`buildah rm ${container}`); const postRm = performance.now(); + if (SIMULATE_PUSH_FAILURE) { + if (performance.now() < 5 * 60 * 1000) { + this.#logger.error("Simulating push failure", { options }); + throw new Error("SIMULATE_PUSH_FAILURE"); + } + } + // Push checkpoint image this.#logger.debug(await $$`buildah push --tls-verify=${REGISTRY_TLS_VERIFY} ${imageRef}`); const postPush = performance.now();