flyctl icon indicating copy to clipboard operation
flyctl copied to clipboard

flyctl accepts multiple regions without error, accepts -restart=no with single hyphen

Open bradfitz opened this issue 2 years ago • 0 comments

Describe the bug

I tried to create a machine with -restart=no but accidentally used a single hyphen. It was then interpreted as "--region=estart=no" (a bogus region) but then a subsequent --region=sea on my command line corrected the region, leaving my restart policy at its default of always. It didn't warn or return an arrow.

The complete command that was bogusly accepted was flyctl machines -a tb run -restart=no --region=sea

Possible fixes:

  • not accept multiple region arguments

  • return an error early if a region is estart or contains an equals sign during flag parsing, before even sending the dockerfile/context off to a builder. (currently the bogus region is rejected very late, after building)

  • Operating system

  • fly version

flyctl v0.1.110 linux/amd64 Commit: 6e05067148b9a9ad7e1a7814a69668f265a2ea8e BuildDate: 2023-10-17T01:36:41Z

Paste your fly.toml

primary_region="sea"

Command output:

$ fly m list --json  -a tb
[]
$ flyctl machines -a tb run -restart=no --region=sea .
Remote builder fly-builder-delicate-voice-9815 ready
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 0.7s (8/8) FINISHED                                                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                                                               0.1s
 => => transferring dockerfile: 31B                                                                                                                                                0.1s
 => [internal] load .dockerignore                                                                                                                                                  0.1s
 => => transferring context: 2B                                                                                                                                                    0.1s
 => [internal] load metadata for docker.io/library/golang:1.21                                                                                                                     0.5s
 => [1/3] FROM docker.io/library/golang:1.21@sha256:24a09375a6216764a3eda6a25490a88ac178b5fcb9511d59d0da5ebf9e496474                                                               0.0s
 => [internal] load build context                                                                                                                                                  0.1s
 => => transferring context: 27B                                                                                                                                                   0.1s
 => CACHED [2/3] COPY tb.go tb.go                                                                                                                                                  0.0s
 => CACHED [3/3] RUN go build -o /tb tb.go                                                                                                                                         0.0s
 => exporting to image                                                                                                                                                             0.0s
 => => exporting layers                                                                                                                                                            0.0s
 => => writing image sha256:0250edc5c4d21a697310fac177f5e5674e3effcac191f84b381eff64c3d88083                                                                                       0.0s
 => => naming to registry.fly.io/tb:deployment-01HD4CNDCBJZT263DV9KJ53YY7                                                                                                          0.0s
--> Building image done
==> Pushing image to fly
The push refers to repository [registry.fly.io/tb]
f2d19ef29049: Layer already exists 
32202a2e625f: Layer already exists 
fe7d12ddfc65: Layer already exists 
fbc321379a11: Layer already exists 
e51777ae0bce: Layer already exists 
2ef3351afa6d: Layer already exists 
5cc3a4df1251: Layer already exists 
2fa37f2ee66e: Layer already exists 
deployment-01HD4CNDCBJZT263DV9KJ53YY7: digest: sha256:cbd7a1ff97aeb2e3c5e639364faa2b17bfa27934fafd933f5bcb0df6b22fec62 size: 2003
--> Pushing image done
Image: registry.fly.io/tb:deployment-01HD4CNDCBJZT263DV9KJ53YY7
Image size: 887 MB

Success! A machine has been successfully launched in app tb
 Machine ID: 178115d2a55328
 Instance ID: 01HD4CNM0XD077TBJ638FRYVJW
 State: created

 Attempting to start machine...

==> Monitoring health checks
No health checks found

Machine started, you can connect via the following private ip
  fdaa:0:4551:a7b:120:3737:eec5:2

And here you can see it made the VM with a restart policy of always, not no:

$ fly m list --json  -a tb
[
    {
        "id": "178115d2a55328",
        "name": "cool-star-9026",
        "state": "started",
        "region": "sea",
        "image_ref": {
            "registry": "registry.fly.io",
            "repository": "tb",
            "tag": "deployment-01HD4CNDCBJZT263DV9KJ53YY7",
            "digest": "sha256:cbd7a1ff97aeb2e3c5e639364faa2b17bfa27934fafd933f5bcb0df6b22fec62"
        },
        "instance_id": "01HD4CNM0XD077TBJ638FRYVJW",
        "private_ip": "fdaa:0:4551:a7b:120:3737:eec5:2",
        "created_at": "2023-10-19T16:35:33Z",
        "updated_at": "2023-10-19T16:35:34Z",
        "config": {
            "init": {},
            "image": "registry.fly.io/tb:deployment-01HD4CNDCBJZT263DV9KJ53YY7",
            "restart": {
                "policy": "always"
            },
            "guest": {
                "cpu_kind": "shared",
                "cpus": 1,
                "memory_mb": 256
            },
            "dns": {}
        },
        "events": [
            {
                "type": "start",
                "status": "started",
                "source": "flyd",
                "timestamp": 1697733334297
            },
            {
                "type": "launch",
                "status": "created",
                "source": "user",
                "timestamp": 1697733333063
            }
        ]
    }
]

bradfitz avatar Oct 19 '23 16:10 bradfitz