F1bonacc1/process-compose

Start/Restart action should start depended on disabled services

thenonameguy opened this issue · 7 comments

If you have a service config like:

    depends_on:
      kafka:
        condition: process_healthy
      sftp:
        condition: process_started

for a seldomly used subset of your system (therefore using disabled: true for both the service and it's dependencies (kafka and sftp)) currently starting/restarting the service does not visually do anything.

Expectation: start sftp/ kafka so the depends_on conditions have a chance to be met.

Hi @thenonameguy,

Makes sense. Will look into it.

Hi @thenonameguy,

I tried to reconstruct your scenario and here is what I found:

  1. Consider that the processes are always DAG.
  2. For example A->B->C.
  3. If not disabled A will wait on B, while B is in a running or waiting for C state.
  4. If both (A+B) are disabled, A (if started manually) won't wait for B since it's neither in waiting nor in running state.

TL;DR A will run even if it depends on B to be healthy, but B is disabled.

Now I am trying to understand how your configuration is different from mine, that it caused it to wait for B (kafka or sftp) to run, even if B is disabled.

On another topic:
When started manually, is starting the entire chain, always the desired behavior? Or only when disabled?
I am a little bit worried that it can cause some unintended consequences - someone starting A, but accidentally B will cause some damage.
I probably can add the with dependencies parameter to REST, but in UI it might be annoying to ask it each time.

Will be happy to hear your thoughts.

It would be nice if we can add a flag in the process configuration to allow dependent processes to start automatically or at least wait for the dependent process to start.

Hi @camcalaquian,

Consider the following config.yaml

processes:
  A:
    command: "sleep 5"
    depends_on:
      B:
        condition: <condition>
  B:
    command: "sleep 5"

Process A depends on B, it will start based on the following optional conditions:

// ProcessConditionCompleted is the type for waiting until a process has completed (any exit code).
ProcessConditionCompleted = "process_completed"

// ProcessConditionCompletedSuccessfully is the type for waiting until a process has completed successfully (exit code 0).
ProcessConditionCompletedSuccessfully = "process_completed_successfully"

// ProcessConditionHealthy is the type for waiting until a process is healthy.
ProcessConditionHealthy = "process_healthy"

// ProcessConditionStarted is the type for waiting until a process has started (default).
ProcessConditionStarted = "process_started"

I am a little bit worried that it can cause some unintended consequences - someone starting A, but accidentally B will cause some damage.
I probably can add the with dependencies parameter to REST, but in UI it might be annoying to ask it each time.

I think there should definitely be an option to start with deps, but default should be without. There could also be flags at top level, and at process level, to set the default behaviour.

Hi @camcalaquian,

Consider the following config.yaml

processes:
  A:
    command: "sleep 5"
    depends_on:
      B:
        condition: <condition>
  B:
    command: "sleep 5"

Process A depends on B, it will start based on the following optional conditions:

// ProcessConditionCompleted is the type for waiting until a process has completed (any exit code).
ProcessConditionCompleted = "process_completed"

// ProcessConditionCompletedSuccessfully is the type for waiting until a process has completed successfully (exit code 0).
ProcessConditionCompletedSuccessfully = "process_completed_successfully"

// ProcessConditionHealthy is the type for waiting until a process is healthy.
ProcessConditionHealthy = "process_healthy"

// ProcessConditionStarted is the type for waiting until a process has started (default).
ProcessConditionStarted = "process_started"

@F1bonacc1 don't think this works if process is disabled by default. Which is the main concern of this issue I think?

There are several alternatives to consider (not sure which one is the desired behavior):

  1. (TUI) When starting a disabled (or stopped) process ask each time if also start its dependencies. This will also require a REST flag.
  2. Configuration setting per process always_run_with_dependencies - it will be ignored when --no-deps flag is used.
  3. Configuration setting per dependency always_run - it will be ignored when --no-deps flag is used.
  4. Should this behavior apply only to disabled processes or any stopped process?
  5. In case a disabled process is started with its dependencies (TUI/config) should it affect the entire chain or only the immediate child?