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

Fix console container startup issue #741

Open
wants to merge 7 commits into
base: 1.6.x
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/_base/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# CHANGELOG

## 1.5.0 - 20230126

### Added attributes

* `attribute('console.state.steps')` - Steps necessary to test the health of the console container
* `attribute('console.healthcheck.enabled')` - Defaults to `true` only for local builds
* `attribute('console.healthcheck.test')` - The command in array format that will run the healthcheck - Defaults to ['CMD', 'app', 'state']
* `attribute('console.healthcheck.test.start_period')` - Defaults to 5s
* `attribute('console.healthcheck.test.interval')` - Defaults to 5s
* `attribute('console.healthcheck.test.timeout')` - Defaults to 3s
* `attribute('console.healthcheck.test.retries')` - Defaults to 10
marcomc marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions src/_base/_twig/docker-compose.yml/service/console.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
build:
context: ./
dockerfile: .my127ws/docker/image/console/Dockerfile
{% if @('console.healthcheck.enabled') %}
healthcheck:
test: {{ to_nice_yaml( @('console.healthcheck.test'), 2, 8) | raw }}
start_period: {{ @('console.healthcheck.start_period') }}
interval: {{ @('console.healthcheck.interval') }}
timeout: {{ @('console.healthcheck.timeout') }}
retries: {{ @('console.healthcheck.retries') }}
{% endif %}
{% if @('app.build') == 'dynamic' %}
entrypoint: [/entrypoint.dynamic.sh]
command: [sleep, infinity]
Expand Down
Empty file modified src/_base/docker/image/console/root/entrypoint.dynamic.sh
100755 → 100644
Empty file.
6 changes: 6 additions & 0 deletions src/_base/docker/image/console/root/entrypoint.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ run_steps()
fi
}

healthcheck_checkpoint()
{
echo 'Entrypoint tasks completed: console has started' > /run/started
}

bootstrap()
{
setup_app_networking
run_steps
healthcheck_checkpoint
}

bootstrap
Expand Down
8 changes: 0 additions & 8 deletions src/_base/docker/image/console/root/lib/task/state.sh

This file was deleted.

20 changes: 20 additions & 0 deletions src/_base/docker/image/console/root/lib/task/state.sh.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

function test_ok()
{
# run any command required which result can be monitored by Docker's HEALTHCHECK
{% for step in @('console.state.steps') -%}
{{ step|raw }}
{% else -%}
:
{% endfor %}

}

function task_state()
{
if ! test_ok; then
echo "Console is not ready: test steps failed!"
return 1
fi
}
11 changes: 11 additions & 0 deletions src/_base/harness/attributes/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ attributes.default:
steps: []

console:
state:
steps:
- if [[ -f /run/started ]]; then cat /run/started; else return 1; fi
healthcheck:
# we want that enabled only for local builds
enabled: false
test: ['CMD', 'app', 'state']
start_period: 5s
interval: 5s
timeout: 3s
retries: 10
entrypoint:
steps: []

Expand Down
5 changes: 4 additions & 1 deletion src/_base/harness/attributes/environment/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ attributes:
app:
build: dynamic
mode: development
version: develop
version: develop
console:
healthcheck:
enabled: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be enabled for helm and CI as well? It's useful for seeing the deployment readiness, and CI should act the same as local

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically helm way is enough being a common console.healthcheck.enabled, as it'll get the same file CI was built from

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note though that the helm way is hard coded to app state

1 change: 1 addition & 0 deletions src/_base/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down
3 changes: 2 additions & 1 deletion src/_base/harness/scripts/enable.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ dynamic_console()

find .my127ws/docker/image/ -type d ! -perm u+rwx,go+rx,o-w -exec chmod u+rwx,go+rx,o-w {} +

passthru docker-compose up --build -d console
# docker-compose will wait for `console` to be in healty status if healthcheck is enabled
passthru docker-compose up --build -d console --wait
passthru docker-compose exec -T -u build console app build

if [ "$USE_MUTAGEN" = yes ]; then
Expand Down
1 change: 1 addition & 0 deletions src/akeneo/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down
1 change: 1 addition & 0 deletions src/magento1/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down
1 change: 1 addition & 0 deletions src/magento2/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down
8 changes: 8 additions & 0 deletions src/spryker/_twig/docker-compose.yml/service/console.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
build:
context: ./
dockerfile: .my127ws/docker/image/console/Dockerfile
{% if @('console.healthcheck.enabled') %}
healthcheck:
test: {{ to_nice_yaml( @('console.healthcheck.test'), 2, 8) | raw }}
start_period: {{ @('console.healthcheck.start_period') }}
interval: {{ @('console.healthcheck.interval') }}
timeout: {{ @('console.healthcheck.timeout') }}
retries: {{ @('console.healthcheck.retries') }}
{% endif %}
{% if @('app.build') == 'dynamic' %}
image: {{ @('workspace.name') ~ '-console:dev' }}
entrypoint: [/entrypoint.dynamic.sh]
Expand Down
3 changes: 3 additions & 0 deletions src/spryker/harness/attributes/environment/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ attributes:
build: dynamic
mode: development
version: develop
console:
healthcheck:
enabled: true
1 change: 1 addition & 0 deletions src/spryker/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down
1 change: 1 addition & 0 deletions src/symfony/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down
1 change: 1 addition & 0 deletions src/wordpress/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ confd('harness:/'):
- { src: docker/image/console/root/lib/task/install.sh }
- { src: docker/image/console/root/lib/task/migrate.sh }
- { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh }
- { src: docker/image/console/root/lib/task/state.sh }
- { src: docker/image/console/root/lib/task/welcome.sh }
- { src: docker/image/console/root/usr/local/etc/php/php.ini }
- { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini }
Expand Down