Machine API returning 500 when passing in mounts

I’m trying to use the machine api to launch a machine with a volume attached, but the request seems to hang for a while, then returns a 500.

Here’s the curl i’m making that’s causing the 500.

curl -v -X 'POST' \
  "https://api.machines.dev/v1/apps/${FLY_APP}/machines" \
  -H "Authorization: Bearer ${FLY_API_TOKEN}" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"name":"cool-app-flame-WhvC1+8+drGT42WDtRYU","config":{"env":{"FLAME_PARENT":"g2gDWgADdw1ub25vZGVAbm9ob3N0AAAAAAABMm4DnAAGtSen6Vh3DW5vbm9kZUBub2hvc3QAAAGLAAAAAAAAAAB3F0VsaXhpci5GTEFNRS5GbHlCYWNrZW5k","PHX_SERVER":"false"},"restart":{"policy":"no"},"image":"registry.fly.io/gm-familiar:deployment-01HHWTVNHZMV2WBNXDB2SAPWJP","services":[],"mounts":[{"name":"data","path":"/data"}],"auto_destroy":true,"guest":{"cpus":1,"cpu_kind":"performance","gpu_kind":null,"memory_mb":4096}}}'

Is this a fly bug, or am I doing something wrong?

:wave: Looking at what you’re passing in mounts, I think you’re just missing the required volume field which represents the ID of the Fly Volume to mount (like vol_2n0l3vl60qpv635d).

Note that mounts refers to volumes that already exist. If you aren’t already, you’ll first need to ensure the volume you’d like to mount has been created. You can create a volume by POSTing to the /apps/:app_name/volumes endpoint: https://docs.machines.dev/swagger/index.html#/Volumes/Volumes_create.

Oh so you need to pass a specific volume id?

FYI on this page it doesn’t say volumeId is required.
I thought fly would pick one unattached volume with that name.

Hey thanks for getting back to me. I added the volumeId to my request, but I’m still getting the same 500 error.

Here’s my request now (fake volume id for the post, but I use a real one for testing, ofc)

curl -v -X 'POST' \
  "https://api.machines.dev/v1/apps/${FLY_APP}/machines" \
  -H "Authorization: Bearer ${FLY_API_TOKEN}" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"name":"cool-app-flame-WhvC1+8+drGT42WDtRYU","config":{"env":{"FLAME_PARENT":"g2gDWgADdw1ub25vZGVAbm9ob3N0AAAAAAABMm4DnAAGtSen6Vh3DW5vbm9kZUBub2hvc3QAAAGLAAAAAAAAAAB3F0VsaXhpci5GTEFNRS5GbHlCYWNrZW5k","PHX_SERVER":"false"},"restart":{"policy":"no"},"image":"registry.fly.io/gm-familiar:deployment-01HHWTVNHZMV2WBNXDB2SAPWJP","services":[],"mounts":[{"volumeId": "vol_545x70wnnpwy2g9g", "name":"data","path":"/data"}],"auto_destroy":true,"guest":{"cpus":1,"cpu_kind":"performance","gpu_kind":null,"memory_mb":4096}}}'

Hey @benbot, try with the property name volume instead of volumeId. Does your request succeed then?

By the way, thanks for pointing out what’s in the doc – I missed that volume isn’t required. Passing just mount name and path should work, so I’ve mentioned this internally in case I’m missing anything else.

In the meantime, if it works for you, I suggest passing in a volume ID in your create Machine requests.

1 Like

Oh yep, i was using volumeId instead of volume :sweat_smile:

If you remember to, could you update me on what the outcome of your internal comms is?
I’d like to know if volume ends up being a required field OR if we can omit it.

Thanks :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.