garden-io / garden

Automation for Kubernetes development and testing. Spin up production-like environments for development, testing, and CI on demand. Use the same configuration and workflows at every step of the process. Speed up your builds and test runs via shared result caching
https://garden.io
Mozilla Public License 2.0
3.3k stars 267 forks source link

[FEATURE]: Wait to start container until initial file syncs complete #6113

Open westrik opened 1 month ago

westrik commented 1 month ago

Feature Request

Background / Motivation

We have configured our Garden local dev setup is run sleep 30 before starting our backend dev server. We do this to wait until the initial file syncs have completed and avoid errors caused by missing files.

This is not ideal because we need to hard-code a wait time greater than the worst-case initial sync time, so in most cases we are sleeping an unnecessarily long amount of time. This is also brittle because the initial sync time may increase as more files are added.

What should the user be able to do?

Users should be able to configure Garden to wait to run a container's startup command until the inital file sync(s) have completed.

Why do they want to do this? What problem does it solve?

Users may want a reliable way to avoid starting a container until all files it needs to run have been synced.

Suggested Implementation(s)

Perhaps a waitForInitialSync option could be added to a container spec, e.g.:

spec:
  containers:
    - command:
        - bash
        - dev-server.sh
      waitForInitialSync: true
      # ...

Or maybe a blockStartup option could be added to the sync config:

devMode:
  sync:
    - target: /src
      source: '.'
      mode: one-way-replica
      blockStartup: true
    # ...

How important is this feature for you/your team?

🌵 Not having this feature makes using Garden painful

twelvemo commented 1 month ago

This is a great feature request. I think a flag in the sync configuration would make more sense, since we can then implement this as well for helm and kubernetes Deploys.