Skip to content

Commit

Permalink
fix(k8s): timeout/OOM error when pulling large image to local docker
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed May 10, 2021
1 parent a693348 commit d92ed5f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions core/src/plugins/kubernetes/commands/pull-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { buildkitAuthSecretName, ensureBuilderSecret } from "../container/build/
import { PluginContext } from "../../../plugin-context"

const tmpTarPath = "/tmp/image.tar"
const imagePullTimeoutSeconds = 60 * 20

export const pullImage: PluginCommand = {
name: "pull-image",
Expand Down Expand Up @@ -168,7 +169,7 @@ async function pullFromExternalRegistry(
// See https://github.com/containers/skopeo for how all this works and the syntax
const skopeoCommand = [
"skopeo",
"--command-timeout=300s",
`--command-timeout=${imagePullTimeoutSeconds}s`,
"--insecure-policy",
"copy",
"--quiet",
Expand All @@ -193,14 +194,20 @@ async function pullFromExternalRegistry(
{
name: "main",
image: k8sUtilImageName,
command: ["sleep", "360"],
command: ["sleep", "" + (imagePullTimeoutSeconds + 10)],
volumeMounts: [
{
name: authSecretName,
mountPath: "/home/user/.docker",
readOnly: true,
},
],
resources: {
requests: {
cpu: "100m",
memory: "256M",
},
},
},
],
volumes: [
Expand All @@ -225,7 +232,7 @@ async function pullFromExternalRegistry(
log,
command: skopeoCommand,
tty: false,
timeoutSec: 60 * 1000 * 5, // 5 minutes,
timeoutSec: imagePullTimeoutSeconds + 10,
buffer: true,
})

Expand All @@ -252,6 +259,7 @@ async function loadImage({ ctx, runner, log }: { ctx: PluginContext; runner: Pod
log,
stdout: writeStream,
buffer: false,
timeoutSec: imagePullTimeoutSeconds,
})

await containerHelpers.dockerCli({
Expand Down

0 comments on commit d92ed5f

Please sign in to comment.