wasp icon indicating copy to clipboard operation
wasp copied to clipboard

CLI deploy fly.io unique name issue

Open vincanger opened this issue 1 year ago • 4 comments

Describe the bug App name must be unique across all of fly.io or deployment with wasp deploy launch fails.

To Reproduce

  • when deploying an app, use a name that already exists on the fly.io service, e.g. open-saas
  • a new, random unique name will be created instead, e.g. open-saas-fire-whisper
  • this causes wasp's deploy script to fail

Expected behavior Script should terminate and alert user to choose a new, more unique name if the created app name doesn't match the given app name

vincanger avatar Dec 04 '23 11:12 vincanger

Quoting Vince:

noticed something weird with Fly.io deployment. It's failing to connect the DB to the Server when it autogenerates parts of the name. For example, I ran: wasp deploy fly launch open-saas and it created: open-saas-wispy-fire to be unique across all of fly.io (this is where the problem lies)

What happens is that on the fly.io dashboard it created: open-saas-server-wispy-fire-4715 But the command getting run in our script is: $ flyctl postgres attach open-saas-wispy-fire-4715-db -a open-saas-wispy-fire-4715-server So we get: Error: failed retrieving app open-saas-wispy-fire-4715-server

The issue being that server is in the middle of the name, not the end (edited)

Why this is not great:

  1. if we use a name that someone else used, deployment fails
  2. if we deploy and it fails, we can't use the same command again. Why not? we've got .toml files, can't we recognize taht and skip steps?

Martinsos avatar Dec 05 '23 09:12 Martinsos

This happened because open-saas name was already taken on fly it seems.

Martinsos avatar Dec 05 '23 09:12 Martinsos

We should check if the app names are taken on Fly before using them. It's not really possible to check with the Fly CLI directly if an app name is taken. It is however possible to:

  • check the output of the commands we run and see if we have the expected output
  • use the Fly's GraphQL API drectly

Checking the output

If we did something for an app called potatos-server we expect to see potatos-server.fly.dev in the output. If we don't see it, we know something went wrong and we can abort.

Using the GraphQL API

We can send a request to https://api.fly.io/graphql (details on using it https://til.simonwillison.net/fly/undocumented-graphql-api) with the query:

{
  appNameAvailable(name: "wasp-ai-server")
}

infomiho avatar Aug 19 '24 11:08 infomiho