finch icon indicating copy to clipboard operation
finch copied to clipboard

Add support for compose file healthchecks

Open bdonlan opened this issue 2 years ago • 1 comments
trafficstars

What is the problem you're trying to solve?. finch 0.7.0 does not support healthcheck stanzas and related dependency definitions in dockerfiles.

Describe the feature you'd like

Consider this dockerfile:

version: '3'
services:
  svc_a:
    image: busybox
    command: 
    - sh
    - '-c'
    - |
      set -x
      sleep 30
      touch /vol/marker
    healthcheck:
      test: [CMD, 'sh', '-c', '[ -f /vol/marker ]']
    volumes:
      - marker:/vol
  svc_b:
    image: busybox
    depends_on:
      svc_a:
        condition: service_healthy
    command:
    - sh
    - '-c'
    - |
      [ -f /vol/marker ] || (echo MARKER NOT FOUND; exit 1)
    volumes:
      - marker:/vol
volumes:
  marker: {}

svc_b should wait for svc_a's healthcheck to pass before starting; however, finch ignores this stanza:

% finch compose -p test -f test.yml up
INFO[0000] Creating network test_default                
INFO[0000] Creating volume test_marker                  
WARN[0000] Ignoring: service svc_a: [HealthCheck]       
WARN[0000] Ignoring: service svc_b: depends_on: svc_a: condition service_healthy 
INFO[0000] Ensuring image busybox                       
INFO[0000] Ensuring image busybox                       
INFO[0000] Creating container test_svc_a_1              
INFO[0000] Creating container test_svc_b_1              
INFO[0000] Attaching to logs                            
svc_b_1 |MARKER NOT FOUND
svc_a_1 |+ sleep 30
INFO[0000] Container "test_svc_b_1" exited        
svc_a_1 |+ touch /vol/marker
INFO[0030] Container "test_svc_a_1" exited              
INFO[0030] All the containers have exited               
INFO[0030] Stopping containers (forcibly)               
INFO[0030] Stopping container test_svc_b_1              
INFO[0030] Stopping container test_svc_a_1   

bdonlan avatar Jul 24 '23 01:07 bdonlan

Hi @bdonlan , finch is using nerdctl under the hood in a Lima VM. The healthcheck field is currently unsupported for nerdctl's implementation of compose: https://github.com/containerd/nerdctl/blob/main/docs/compose.md#unimplemented-yaml-fields

We can see what we can do to work with the upstream community to bridge this feature gap.

ginglis13 avatar Jul 28 '23 22:07 ginglis13