superfly / flyctl

Command line tools for fly.io services
https://fly.io
Apache License 2.0
1.42k stars 240 forks source link

Apps v2 - `fly launch` confused by `[processes]` in `fly.toml` #1682

Closed catflydotio closed 1 year ago

catflydotio commented 1 year ago

(v0.0.455-pre-1)

Trying to launch an app with two processes results in one machine with no assigned process group, and no services configured.

Launching with no [processes] section results in one machine with no assigned process group too, but services get configured.

In both cases, IPv6 and shared IPv4 are provisioned.

Looking at debug output of launch, it seems config from fly.toml is validated/"verified" with GraphQL and then used in the MachinesCreateRelease mutation, but when processes are present, nothing from fly.toml is included when it comes time to create the Machine.

I've just pasted a ton of debug output into two slabs: https://flyio.slab.com/posts/trying-to-launch-a-machines-app-with-processes-2022-feb-7-xvz92hs4 and https://flyio.slab.com/posts/no-processes-section-8hk4voi4. I put some highlighting in there at landmarks that seemed relevant; red is when the machine gets created.

Shenanigans as observed:

$ fly launch --image nginx --force-machines with the following in fly.toml:

# fly.toml file generated for gah on 2023-02-07T21:40:12-05:00

app = "gah"
kill_signal = "SIGINT"
kill_timeout = 5

[experimental]
  auto_rollback = true

[build]
  image = "nginx"

[processes]
  web = "nginx -g 'daemon off;'"
  worker = "tail -F /dev/null"

[[services]]
  protocol = "tcp"
  internal_port = 8080
  processes = ["web"]

  [[services.ports]]
    port = 80
    handlers = ["http"]
    force_https = true

  [[services.ports]]
    port = 443
    handlers = ["tls", "http"]
  [services.concurrency]
    type = "connections"
    hard_limit = 25
    soft_limit = 20

  [[services.tcp_checks]]
    interval = "15s"
    timeout = "2s"
    grace_period = "1s"
    restart_limit = 0

(? Would you like to copy its configuration to the new app? Yes)

21:40:37 [~/FlyTests/feb7]$ fly m status 6e82e07ae06787 -d
Machine ID: 6e82e07ae06787
Instance ID: 01GRQEAC14PDWHYRAHWEWZ6G9D
State: started

VM
  ID            = 6e82e07ae06787                  
  Instance ID   = 01GRQEAC14PDWHYRAHWEWZ6G9D      
  State         = started                         
  Image         = library/nginx:latest            
  Name          = old-grass-9054                  
  Private IP    = fdaa:0:3b99:a7b:93:4eaf:109b:2  
  Region        = iad                             
  Process Group =                                 
  Memory        = 256                             
  CPUs          = 1                               
  Created       = 2023-02-08T02:40:17Z            
  Updated       = 2023-02-08T02:40:18Z            
  Command       =                                 

Event Logs
STATE   EVENT   SOURCE  TIMESTAMP                       INFO 
started start   flyd    2023-02-07T21:40:18.467-05:00
created launch  user    2023-02-07T21:40:17.532-05:00

Config:
{
  "init": {},
  "image": "registry-1.docker.io/library/nginx:latest",
  "metadata": {
    "fly_platform_version": "v2",
    "fly_release_id": "Nj7oGMlVVpZ7JTJxe1K1A3Aa",
    "fly_release_version": "1"
  },
  "restart": {},
  "guest": {
    "cpu_kind": "shared",
    "cpus": 1,
    "memory_mb": 256
  }
}

If I cut out the processes section and launch the same way, the machine gets no process group but services and checks are set up.

21:46:16 [~/FlyTests/feb7]$ fly m status 217811177c9489 -d
Machine ID: 217811177c9489
Instance ID: 01GRQEN1PV42X1AV8CJP8XEGH9
State: started

VM
  ID            = 217811177c9489                  
  Instance ID   = 01GRQEN1PV42X1AV8CJP8XEGH9      
  State         = started                         
  Image         = library/nginx:latest            
  Name          = muddy-dream-7524                
  Private IP    = fdaa:0:3b99:a7b:dc:493f:6432:2  
  Region        = iad                             
  Process Group =                                 
  Memory        = 256                             
  CPUs          = 1                               
  Created       = 2023-02-08T02:46:07Z            
  Updated       = 2023-02-08T02:46:08Z            
  Command       =                                 

Event Logs
STATE   EVENT   SOURCE  TIMESTAMP                       INFO 
started start   flyd    2023-02-07T21:46:08.319-05:00
created launch  user    2023-02-07T21:46:07.365-05:00

Config:
{
  "init": {},
  "image": "registry-1.docker.io/library/nginx:latest",
  "metadata": {
    "fly_platform_version": "v2",
    "fly_release_id": "7pGPxgX11jYG2T71mvmLppJM",
    "fly_release_version": "1"
  },
  "restart": {},
  "services": [
    {
      "protocol": "tcp",
      "internal_port": 8080,
      "ports": [
        {
          "port": 80,
          "handlers": [
            "http"
          ],
          "force_https": true
        },
        {
          "port": 443,
          "handlers": [
            "tls",
            "http"
          ]
        }
      ],
      "checks": [
        {
          "type": "tcp",
          "interval": "15s",
          "timeout": "2s"
        }
      ],
      "concurrency": {
        "type": "connections",
        "hard_limit": 25,
        "soft_limit": 20
      }
    }
  ],
  "guest": {
    "cpu_kind": "shared",
    "cpus": 1,
    "memory_mb": 256
  }
}
catflydotio commented 1 year ago

The same steps now give me one machine with process group "app", which is much better. Further improvement belongs to https://github.com/superfly/flyctl/issues/1772. So closing this one.