open-feature / flagd

A feature flag daemon with a Unix philosophy
https://openfeature.dev
Apache License 2.0
492 stars 60 forks source link

[DOC] Getting Started guide leads to "no such file or directory" fatal #352

Closed PB-TW closed 1 year ago

PB-TW commented 1 year ago

Change in the documentation

I was following this guide: https://docs.openfeature.dev/docs/tutorials/getting-started/java

In step 5, I create the flags.json file in my working directory and then I am running this command: docker run -p 8013:8013 -v $(pwd)/:/etc/flagd/ -it ghcr.io/open-feature/flagd:latest start --uri file:/etc/flagd/flags.json

This leads to the following stacktrace:

{"level":"info","ts":1675136126.8201787,"caller":"file/filepath_sync.go:29","msg":"Starting filepath sync notifier","component":"sync","sync":"filepath"}
{"level":"info","ts":1675136126.8217688,"caller":"service/connect_service.go:108","msg":"metrics listening at 8014","component":"service"}
{"level":"fatal","ts":1675136126.8291576,"caller":"cmd/start.go:120","msg":"no such file or directory","component":"start","stacktrace":"github.com/open-feature/flagd/cmd.glob..func1\n\t/workspace/cmd/start.go:120\ngithub.com/spf13/cobra.(*Command).execute\n\t/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044\ngithub.com/spf13/cobra.(*Command).Execute\n\t/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968\ngithub.com/open-feature/flagd/cmd.Execute\n\t/workspace/cmd/root.go:37\nmain.main\n\t/workspace/main.go:30\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250"}

I tried several different ways, including moving the file around, making the path explicit etc. When I run docker inspect, the volume looks correct to me.

I am using Colima instead of Docker Desktop, if that is relevant.

Either the documentation is wrong or there is a bug in the latest version of flagd.

Kavindu-Dodan commented 1 year ago

I tried installing Colima and starting flagd. I can confirm that flagd detects the mounted file and starts successfully. My assumption is the way you bind the volume. Make sure your flags.json is available at $(pwd)/ (which translates to current directory you are executing the docker command) & file is named exactly flags.json

Kavindu-Dodan commented 1 year ago

Anyway, when using Colima, I noticed that changes to file are not propogated to flagd (i.e - changing feature flag definition is not reflected in flagd [1]).

This should be a limitation/issue of colima. So you might not be able to experience the full potential of flagd.

[1] - https://docs.openfeature.dev/docs/tutorials/getting-started/java/#step-6-rerun-the-application

Kavindu-Dodan commented 1 year ago

Alternatively, you can download flagd binary matching your system from the releases [1] and run it locally.

The run command is simple : ./flagd start --uri file: <BASE_PATH>/flags.json

[1] - https://github.com/open-feature/flagd/releases

toddbaert commented 1 year ago

@PB-TW I'm not able to reproduce this on docker + Linux. Could you tell us what OS are you using?

Can you try docker run -p 8013:8013 -v {ABSOLUTE_DIR}:/etc/flagd/ -it ghcr.io/open-feature/flagd:latest start --uri file:/etc/flagd/flags.json, where {ABSOLUTE_DIR} is a full path to your working directory (or is that what you mean by making the path explicit?) Note that it should be a DIRECTORY, not a file, if you are specifying it manually.

Can you also make sure that the flags.json file has the appropriate permissions and ownership?

PB-TW commented 1 year ago

I'm using MacOS 13.2. The file is named correctly. Colima version is 0.5.2.

I tried it with the {ABSOLUTE_DIR}, leading to the same result as in my original post.

I also don't think that the -v flag is an issue, because when I run docker inspect [container_id], then I can see that:

        "HostConfig": {
            "Binds": [
                "[correct directory path, in which flags.json lives]/:/etc/flagd/"
            ],
...
        }
...
        "Mounts": [
            {
                "Type": "bind",
                "Source": "[correct directory path, in which flags.json lives]",
                "Destination": "/etc/flagd",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],

I will try to download the flagd binary and run it next.

PB-TW commented 1 year ago

The binary is sadly not usable on my system since it is not signed and therefore I may not open it on my Mac.

Covered by: https://github.com/open-feature/flagd/issues/328

PB-TW commented 1 year ago

I installed flagd via homebrew and ran flagd start --uri file:./flags.json. This is working as expected now!

But of course would be more happy to use it dockerized.

toddbaert commented 1 year ago

@PB-TW this sounds a lot like your problem. I'm not familiar enough with Colima, but maybe this could be helpful?

We will keep troubleshooting on our end.

skyerus commented 1 year ago

I'm using macOS Ventura 13.2.

I could not reproduce this issue, these are the steps I took:

  1. Created flags.json in my working directory
  2. Ran colima start (version 0.5.2)
  3. Ran docker run -p 8013:8013 -v $(pwd)/:/etc/flagd/ -it ghcr.io/open-feature/flagd:latest start --uri file:/etc/flagd/flags.json
Unable to find image 'ghcr.io/open-feature/flagd:latest' locally
latest: Pulling from open-feature/flagd
5f80a38cb015: Pull complete
de3ec0d85b60: Pull complete
Digest: sha256:91515407e8527b8a0dc8857efebfbcba291bc3cd498085e99a7d5c5cddd97440
Status: Downloaded newer image for ghcr.io/open-feature/flagd:latest

         ______   __       ________   _______    ______
        /_____/\ /_/\     /_______/\ /______/\  /_____/\
        \::::_\/_\:\ \    \::: _  \ \\::::__\/__\:::_ \ \
         \:\/___/\\:\ \    \::(_)  \ \\:\ /____/\\:\ \ \ \
          \:::._\/ \:\ \____\:: __  \ \\:\\_  _\/ \:\ \ \ \
           \:\ \    \:\/___/\\:.\ \  \ \\:\_\ \ \  \:\/.:| |
            \_\/     \_____\/ \__\/\__\/ \_____\/   \____/_/

{"level":"info","ts":1675346378.0725162,"caller":"service/connect_service.go:108","msg":"metrics listening at 8014","component":"service"}
{"level":"info","ts":1675346378.0725548,"caller":"file/filepath_sync.go:29","msg":"Starting filepath sync notifier","component":"sync","sync":"filepath"}
{"level":"info","ts":1675346378.0742724,"caller":"file/filepath_sync.go:49","msg":"Watching filepath: /etc/flagd/flags.json","component":"sync","sync":"filepath"}
PB-TW commented 1 year ago

Thanks a lot for the support! @toddbaert Your link helped. Clearing out the ~/.colima/ folder made it work for me now as well! So nothing wrong on your side and just one of Colima's quirks.

toddbaert commented 1 year ago

@PB-TW great news! Thanks for your interest in the project. Please don't hesitate to reach out if you need any more help or support, or you'd like to provide feedback.