Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing healthcheck liveness probe protocol for port/path #678

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/common/docker-compose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class DockerComposeUtils {
volumes: {},
};

const protocol = use_ssl ? 'https' : 'http';
const limit = pLimit(5);
const port_promises = [];

Expand Down Expand Up @@ -180,7 +179,7 @@ export class DockerComposeUtils {
const liveness_probe = node.config.liveness_probe;
if (liveness_probe) {
if (!liveness_probe.command) {
liveness_probe.command = ['CMD-SHELL', `curl -f ${protocol}://localhost:${liveness_probe.port}${liveness_probe.path} || exit 1`]; // deprecated
liveness_probe.command = ['CMD-SHELL', `curl -f http://localhost:${liveness_probe.port}${liveness_probe.path} || exit 1`]; // deprecated
} else {
liveness_probe.command = ['CMD', ...liveness_probe.command];
}
Expand Down
53 changes: 53 additions & 0 deletions test/commands/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ describe('local dev environment', function () {
`
}

function getHelloComponentConfigWithPortPathHealthcheck(): any {
return `
name: hello-world

secrets:
hello_ingress: hello

services:
api:
image: heroku/nodejs-hello-world
interfaces:
main:
port: 3000
environment: {}
liveness_probe:
port: 3000
path: /status

interfaces:
hello:
ingress:
subdomain: \${{ secrets.hello_ingress }}
url: \${{ services.api.interfaces.main.url }}
`
}

function getDeprecatedHelloComponentConfig(): any { // TODO: 404: remove
return `
name: hello-world
Expand Down Expand Up @@ -1042,6 +1068,33 @@ describe('local dev environment', function () {
});
});

test
.timeout(20000)
.stub(ComponentBuilder, 'loadFile', () => {
return getHelloComponentConfigWithPortPathHealthcheck();
})
.stub(Docker, 'verify', sinon.stub().returns(Promise.resolve()))
.stub(Dev.prototype, 'runCompose', sinon.stub().returns(undefined))
.stub(Dev.prototype, 'downloadSSLCerts', sinon.stub().returns(undefined))
.stdout({ print })
.stderr({ print })
.command(['dev', './examples/hello-world/architect.yml', '-i', 'hello'])
.it('Path/port healthcheck converted to http path', ctx => {
const runCompose = Dev.prototype.runCompose as sinon.SinonStub;
const compose = runCompose.firstCall.args[0];
expect(runCompose.calledOnce).to.be.true;
expect(compose.services['hello-world--api'].healthcheck).to.deep.equal({
"test": [
'CMD-SHELL',
'curl -f http://localhost:3000/status || exit 1',
],
"interval": "30s",
"timeout": "5s",
"retries": 3,
"start_period": "0s"
});
});

test
.timeout(20000)
.stub(ComponentBuilder, 'loadFile', () => {
Expand Down