Skip to content

Commit

Permalink
fix: now ~ or empty live/ready path should ignore liveness/readiness …
Browse files Browse the repository at this point in the history
…probe. Also, unspecified http-endpoint will lead to undefined, not empty string
  • Loading branch information
OysteinVesth committed Mar 14, 2024
1 parent 592e1e5 commit b2a0a56
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
6 changes: 2 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ inputs:
default: 'false'
healthtest-path:
required: false
description: 'Path to health test for container'
default: '/health'
description: 'Path to health test for container (~ or empty string will ignore path)'
healthtest-timeout:
required: false
description: 'Timeout after failing test - in seconds'
Expand All @@ -55,8 +54,7 @@ inputs:
description: 'Time in seconds between each test'
readytest-path:
required: false
description: 'Path to ready test for container'
default: '/ready'
description: 'Path to ready test for container (~ or empty string will ignore path)'
readytest-command:
required: false
description: 'Commands that will be run - test if commands exit with exit code 0 '
Expand Down
31 changes: 24 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ const getProbeConfiguration = (core: any, probeType: string): ProbeConfig => {
const period = core.getInput(`${probeType}-period`);
const initialdelay = core.getInput(`${probeType}-initialdelay`);
const timeout = core.getInput(`${probeType}-timeout`);

const path = core.getInput(`${probeType}-path`) || undefined;
const command = core.getInput(`${probeType}-command`)
? [core.getInput(`${probeType}-command`)]
: undefined;
if (!path && !command) {
return undefined;
}

return {
path: core.getInput(`${probeType}-path`) || undefined,
command: core.getInput(`${probeType}-command`)
? [core.getInput(`${probeType}-command`)]
: undefined,
path,
command,
periodSeconds: period ? parseInt(period) : undefined,
initialDelaySeconds: initialdelay ? parseInt(initialdelay) : undefined,
timeoutSeconds: timeout ? parseInt(timeout) : undefined,
Expand Down Expand Up @@ -65,10 +72,11 @@ const run = async () => {
const isReleaseChannel = core.getBooleanInput("release-channel");
const envVariables = getEnvironmentVariables(process.env);
const containerPortString = core.getInput("container-port");
const httpEndpoint = core.getInput("http-endpoint");
const httpEndpoint = core.getInput("http-endpoint") || undefined;
const proxyBufferSize = core.getInput("proxy-buffer-size");
const readinessProbe = getProbeConfiguration(core, "readytest");
const livenessProbe = getProbeConfiguration(core, "healthtest");
console.log("THEM PROBES:", readinessProbe, livenessProbe);
const volumes = getVolumeConfig(
core.getMultilineInput("persistent-volumes"),
"persistentVolumeClaim"
Expand Down Expand Up @@ -115,7 +123,16 @@ const run = async () => {
resources,
};
console.log(JSON.stringify(deployParams));
var location = await deploy(token, { ...deployParams, secrets });

try {
const location = await deploy(token, { ...deployParams, secrets });
await waitForDeploymentToComplete(location, token);
} catch (error) {
core.setFailed(error)
}
};

async function waitForDeploymentToComplete(location: string, token: string): Promise<void> {
core.setOutput("deploymenturl", location);
if (!location) {
console.log("No location returned. Assume the deployment is ok!");
Expand All @@ -138,7 +155,7 @@ const run = async () => {
}
}
throw "Error : Deployment was not set to active within set period.";
};
}

function getResourceSettings(c: typeof core) {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export type Deployment = {
branch?: string;
imageName?: string;
instances: number;
readinessProbe: ProbeConfig;
livenessProbe: ProbeConfig;
readinessProbe?: ProbeConfig;
livenessProbe?: ProbeConfig;
volumes: VolumeConfig[];
volumeMounts: VolumeMountConfig[];
dd_service: string;
Expand Down

0 comments on commit b2a0a56

Please sign in to comment.