switch to busybox and only call post start hook for restore (#1005)

This commit is contained in:
nicktrn
2024-04-05 15:47:58 +01:00
committed by GitHub
parent e35f29764a
commit f2894c177a
3 changed files with 19 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Fix post start hooks
+10 -7
View File
@@ -152,11 +152,6 @@ class KubernetesTaskOperations implements TaskOperations {
},
},
lifecycle: {
postStart: {
exec: {
command: this.#getLifecycleCommand("postStart", "create"),
},
},
preStop: {
exec: {
command: this.#getLifecycleCommand("preStop", "terminate"),
@@ -404,11 +399,19 @@ class KubernetesTaskOperations implements TaskOperations {
type: THookType,
cause: THookType extends "postStart" ? PostStartCauses : PreStopCauses
) {
const retries = 5
const retries = 5;
// This will retry sending the lifecycle hook up to `retries` times
// The sleep is required as this may start running before the HTTP server is up
return ["/bin/sh", "-c", `for i in $(seq ${retries}); do sleep 1; wget -q -O- 127.0.0.1:8000/${type}?cause=${cause} && break; done`];
const exec = [
"/bin/sh",
"-c",
`for i in $(seq ${retries}); do sleep 1; busybox wget -q -O- 127.0.0.1:8000/${type}?cause=${cause} && break; done`,
];
logger.log("getLifecycleCommand()", { exec });
return exec;
}
#getIndexContainerName(suffix: string) {
+4 -1
View File
@@ -1,7 +1,10 @@
FROM node:20-bookworm-slim@sha256:d4cdfc305abe5ea78da7167bf78263c22596dc332f2654b662890777ea166224 AS base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends \
busybox \
dumb-init \
&& rm -rf /var/lib/apt/lists/*
# Create and set workdir with appropriate permissions
RUN mkdir /app && chown node:node /app