`flyctl machine create` waits until after a build to exit with a duplicate machine name error

I am playing around with creating and destroying machines individually, it’s a lot of fun.

I noticed this problem today:

halfer@dev:~/$ flyctl machine create \
    . \
    --config machines/fly.toml \
    --rm \
    --region lhr \
    --vm-memory 256M \
    --dockerfile machines/small/Dockerfile \
    --name sequoia-browser-small
✓ compatible remote builder found
INFO Override builder host with: https://fly-builder-red-shape-1111.fly.dev (was tcp://[fdaa:5:ffff:a7b:330:eeee:9cf5:2]:1111)

Remote builder fly-builder-red-shape-1111 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 1.0s (9/9) FINISHED                                                                                                                                                                                                              
 => [internal] load .dockerignore                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                          0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.1s
 => => transferring dockerfile: 245B                                                                                                                                                                                                     0.1s
 => [internal] load metadata for docker.io/library/php:8.3-alpine                                                                                                                                                                        0.8s
 => [1/4] FROM docker.io/library/php:8.3-alpine@sha256:212aaa3f3bfa1c302aaa5871af923faaae35cd7696dafe3aaa9ac8c9ed5aaa72                                                                                                                  0.0s
 => [internal] load build context                                                                                                                                                                                                        0.1s
 => => transferring context: 136B                                                                                                                                                                                                        0.1s
 => CACHED [2/4] WORKDIR /root                                                                                                                                                                                                           0.0s
 => CACHED [3/4] COPY docker/sleep.sh /root/sleep.sh                                                                                                                                                                                     0.0s
 => CACHED [4/4] COPY healthcheck /project/healthcheck                                                                                                                                                                                   0.0s
 => exporting to image                                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                                  0.0s
 => => writing image sha256:0926143acb50fe82186b49fd77b2ae357200091057ccd3fa5701ae759d1eb105                                                                                                                                             0.0s
 => => naming to registry.fly.io/sequoia-browser-test:deployment-01J17S1M1W212ARRJ1NQMS1N1T                                                                                                                                              0.0s
--> Building image done
==> Pushing image to fly
The push refers to repository [registry.fly.io/sequoia-browser-test]
7fffc68d2000: Layer already exists 
7da72b979000: Layer already exists 
5f70bf18a000: Layer already exists 
e00dd0b10000: Layer already exists 
6f6388c4e000: Layer already exists 
038ff495e000: Layer already exists 
727024b0e000: Layer already exists 
6af6a1e81000: Layer already exists 
36503de07000: Layer already exists 
9b4897b63000: Layer already exists 
bd336fca6000: Layer already exists 
08000c18d000: Layer already exists 
deployment-01J17S1M1W212ARRJ1NQMS1N1T: digest: sha256:c5420585719fx76c29x998xd53xf7ex0d76x42640x6cf8cb9x78848eefx65ae8 size: 2821
--> Pushing image done
Image: registry.fly.io/sequoia-browser-test:deployment-01J17S1M1W212ARRJ1NQMS1N1T
Image size: 106 MB

Error: could not launch machine: failed to launch VM: already_exists: unique machine name violation, machine ID 17815ee5b45408 already exists with name "sequoia-browser-small" (Request ID: 01JM7APDAA9YBAZZBKJA47YA8-ams)

The error message is entirely correct, I wanted to see if create acted like update in the case of a duplicate name. I don’t mind that it borks out, but it seems that it could have checked that at the start, rather than going through the build first. This particular build is super-quick, but some folks will have sluggish ones to run through.

Could the duplicate check be added at the start as well?

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