superfly / flyctl

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

Allow `fly pg connect` to work with custom images #3680

Open benwaffle opened 1 week ago

benwaffle commented 1 week ago

This is relevant in development - e.g. if you run fly deploy -a <my-db> in postgres-flex

davissp14 commented 1 week ago

You can currently specify FLY_DEV=1 to bypass the custom image restriction.

benwaffle commented 1 week ago

Oh, didn't notice that. This PR makes it unnecessary. Any thoughts about getting rid of FLY_DEV? I don't see any risk here.

davissp14 commented 1 week ago

The pg connect command calls https://github.com/fly-apps/postgres-flex/blob/master/bin/connect

The main problem is that we can't assume custom images have this binary.

benwaffle commented 1 week ago

Today if you run fly pg connect on a custom image, you get this error: Error: Malformed version: ustom.

Anyone who's hacking on postgres-flex is likely to have the connect binary. In the rare case that they have removed it, with this PR they will see:

❯ f pg connect -a dbdbdb
Connecting to fdaa:1:a290:a7b:2f1:f87a:2dab:2... complete
exec: "connect": executable file not found in $PATH
Error: ssh shell: wait: remote command exited without exit status or exit signal
davissp14 commented 6 days ago

I'm don't think we should remove the FLY_DEV check, but i'm cool opening up the fly pg connect command.

benwaffle commented 6 days ago

For the record, this changes hasRequiredVersionOnMachines, which is used in nearly all fly pg commands.