superfly / flyctl

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

add "Checks" and "Role" columns to "fly machine list" (consistent with dashboard) #3593

Closed soulware closed 1 month ago

soulware commented 2 months ago

Change Summary

flyctl machine list --app postgres-ssh-test
3 machines have been retrieved from app postgres-ssh-test.
View them in the UI here

postgres-ssh-test
ID              NAME                STATE   CHECKS  REGION  ROLE    IMAGE                               IP ADDRESS                      VOLUME                  CREATED                 LAST UPDATED            APP PLATFORM    PROCESS GROUP   SIZE
781352a9704658  divine-dust-9139    started 3/3     lhr     replica flyio/postgres-flex:15.6 (v0.0.51)  fdaa:1:b1f7:a7b:8e:63fb:9f58:2  vol_4qy6gyej5y2w5lwv    2024-05-22T11:04:31Z    2024-05-22T11:04:44Z    v2                              shared-cpu-2x:4096MB
e82d379c3716d8  twilight-dawn-5608  started 3/3     lhr     replica flyio/postgres-flex:15.6 (v0.0.51)  fdaa:1:b1f7:a7b:172:dfe:cb0e:2  vol_vjp6epo79gpm88mv    2024-05-22T11:04:50Z    2024-06-04T09:40:37Z    v2                              shared-cpu-2x:4096MB
e2867542a6e5d8  patient-hill-1241   started 3/3     lhr     primary flyio/postgres-flex:15.6 (v0.0.51)  fdaa:1:b1f7:a7b:15d:c177:bac5:2 vol_vwegjeknm8qlmwqv    2024-05-22T11:04:08Z    2024-06-04T09:23:35Z    v2                              shared-cpu-2x:4096MB
Screenshot 2024-06-04 at 17 25 44

Also added "PG" and "Checks" tables to flyctl machine status. The PG table is only displayed for "fly postgres" apps (and currently only displays the primary/replica Role). The Checks table is only displayed if the machine belongs to an app with healthchecks configured.

Note: We can currently view all checks for the app via flyctl checks list but this PR adds the machine specific checks to flyctl machine status for convenience.

flyctl machine status 781352a9704658
Machine ID: 781352a9704658
Instance ID: 01HYFZJQP388F2FD0WB51YHA1N
State: started

VM
  ID            = 781352a9704658
  Instance ID   = 01HYFZJQP388F2FD0WB51YHA1N
  State         = started
  [...]

PG
  Role = replica

Checks [3/3]
NAME    STATUS  LAST UPDATED    OUTPUT
pg      passing 10m44s ago      [✓] connections: 6 used, 3 reserved, 300 max (17.67ms)
vm      passing 10m40s ago      [✓] checkDisk: 36.93 GB (94.5%) free space on /data/ (100.05µs)
                                [✓] checkLoad: load averages: 0.00 0.00 0.00 (89.51µs)
                                [✓] memory: system spent 0s of the last 60s waiting on memory (99.85µs)
                                [✓] cpu: system spent 252ms of the last 60s waiting on cpu (1.18ms)
                                [✓] io: system spent 414ms of the last 60s waiting on io (74.86µs)
role    passing 10m44s ago      replica

Event Logs
STATE       EVENT   SOURCE  TIMESTAMP                       INFO
started     start   flyd    2024-06-06T11:00:29.209+01:00
starting    start   user    2024-06-06T11:00:28.382+01:00
stopped     exit    flyd    2024-06-05T15:37:46.418+01:00   exit_code=0,oom_killed=false,requested_stop=true
stopping    stop    user    2024-06-05T15:37:43.744+01:00
started     start   flyd    2024-05-22T12:04:44.194+01:00

Example of an machine with no PG and no Checks tables -

flyctl machine status e7843ed5f275e8
Machine ID: e7843ed5f275e8
Instance ID: 01HXCEQD3XBN71AFC4X1K7X0CF
State: stopped

VM
  ID            = e7843ed5f275e8
  Instance ID   = 01HXCEQD3XBN71AFC4X1K7X0CF
  State         = stopped
  [...]

Event Logs
STATE   EVENT   SOURCE  TIMESTAMP                       INFO
stopped exit    flyd    2024-05-14T10:31:01.647+01:00   exit_code=0,oom_killed=false,requested_stop=false
started start   flyd    2024-05-08T16:56:38.869+01:00
created launch  user    2024-05-08T16:56:33.297+01:00

Documentation