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

Process B fails quickly results in "process A depends on B, but it isn't running" #274

Closed
3 tasks done
secobarbital opened this issue Nov 7, 2024 · 2 comments · Fixed by #276
Closed
3 tasks done

Comments

@secobarbital
Copy link
Contributor

secobarbital commented Nov 7, 2024

Defect

When process A depends on B completing successfully, process A runs if B fails quickly. It should not run if B fails, regardless how quickly.

  • Included the relevant configuration snippet
  • Included the relevant process-compose log (log location: process-compose info)
  • Included a [Minimal, Complete, and Verifiable example] (https://stackoverflow.com/help/mcve)

Version of process-compose: v1.34.0

OS environment: MacOS 14.7.1

Steps or code to reproduce the issue:

process-compose.json:

{
  "processes": {
    "bundle-install": { "command": "sleep 10", "namespace": "default" },
    "configure": { "command": "diff a b", "namespace": "default" },
    "mysql": {
      "availability": { "max_restarts": 5, "restart": "on_failure" },
      "command": "sleep 100",
      "namespace": "mysql.mysql",
      "readiness_probe": {
        "exec": {
          "command": "echo mysql"
        },
        "failure_threshold": 5,
        "initial_delay_seconds": 2,
        "period_seconds": 10,
        "success_threshold": 1,
        "timeout_seconds": 4
      }
    },
    "mysql-configure": {
      "command": "sleep 3",
      "depends_on": { "mysql": { "condition": "process_healthy" } },
      "namespace": "mysql.mysql"
    },
    "prepare-db": {
      "command": "echo PREPARE DB",
      "depends_on": {
        "bundle-install": { "condition": "process_completed_successfully" },
        "configure": { "condition": "process_completed_successfully" },
        "mysql-configure": { "condition": "process_completed_successfully" }
      },
      "namespace": "default"
    },
    "web": {
      "command": "sleep 100",
      "depends_on": {
        "bundle-install": { "condition": "process_completed_successfully" },
        "configure": { "condition": "process_completed_successfully" },
        "prepare-db": { "condition": "process_completed_successfully" }
      },
      "namespace": "default"
    }
  },
  "shell": { "shell_argument": "-c", "shell_command": "/bin/bash" }
}

Expected result:

24-11-07 16:04:39.275 ERR Error: process prepare-db depended on configure to complete successfully, but it exited with status 2
24-11-07 16:04:39.275 ERR Error: process prepare-db won't run

Actual result:

24-11-07 16:04:49.281 ERR Error: process web depends on configure, but it isn't running
24-11-07 16:04:49.281 ERR Error: process web depends on prepare-db, but it isn't running
24-11-07 16:04:49.286 INF Started command=["/bin/bash","-c","sleep 100"] process=web

Full log:

This run had both the good case and the bad case happening:

24-11-07 16:04:39.260 INF Process Compose v1.34.0
24-11-07 16:04:39.261 INF Loaded project from nix/process-compose-enterprise.json
24-11-07 16:04:39.261 INF Global shell command: /bin/bash -c
24-11-07 16:04:39.261 INF start http server listening :8080
24-11-07 16:04:39.261 DBG Spinning up 6 processes. Order: ["configure" "mysql" "mysql-configure" "bundle-install" "prepare-db" "web"]
24-11-07 16:04:39.261 INF web is waiting for bundle-install to complete successfully
24-11-07 16:04:39.262 INF mysql-configure is waiting for mysql to be healthy
24-11-07 16:04:39.262 INF prepare-db is waiting for configure to complete successfully
24-11-07 16:04:39.264 INF Started command=["/bin/bash","-c","sleep 100"] process=mysql
24-11-07 16:04:39.264 INF Started command=["/bin/bash","-c","sleep 10"] process=bundle-install
24-11-07 16:04:39.265 INF Started command=["/bin/bash","-c","diff a b"] process=configure
24-11-07 16:04:39.275 INF Exited exit_code=2 process=configure
24-11-07 16:04:39.275 ERR Error: process prepare-db depended on configure to complete successfully, but it exited with status 2
24-11-07 16:04:39.275 ERR Error: process prepare-db won't run
24-11-07 16:04:41.264 DBG mysql_ready_probe started monitoring
24-11-07 16:04:41.275 INF Started command=["/bin/bash","-c","sleep 3"] process=mysql-configure
24-11-07 16:04:44.288 INF Exited exit_code=0 process=mysql-configure
24-11-07 16:04:49.281 INF Exited exit_code=0 process=bundle-install
24-11-07 16:04:49.281 ERR Error: process web depends on configure, but it isn't running
24-11-07 16:04:49.281 ERR Error: process web depends on prepare-db, but it isn't running
24-11-07 16:04:49.286 INF Started command=["/bin/bash","-c","sleep 100"] process=web
24-11-07 16:06:19.279 INF Exited exit_code=0 process=mysql
24-11-07 16:06:29.315 INF Exited exit_code=0 process=web
24-11-07 16:06:29.315 INF Project completed
24-11-07 16:06:31.008 DBG Shutting down 0 processes. Order: []
24-11-07 16:06:32.009 DBG Logs monitoring canceled
24-11-07 16:06:32.011 DBG TUI Wait stopped
24-11-07 16:06:32.011 INF Thank you for using process-compose
@secobarbital
Copy link
Contributor Author

It looks like waitIfNeeded only looks for the depended on processes in the list of running processes, from which processes are removed once they exit. It should probably check a list of completed processes as well.

@F1bonacc1
Copy link
Owner

Thanks for the quick fix @secobarbital.
Added in v1.40.0

F1bonacc1 added a commit that referenced this issue Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants