open-feature / playground

OpenFeature SDK demos and experimentation
https://openfeature.dev
Apache License 2.0
50 stars 25 forks source link

feat: add Flipt to playground #293

Closed lukas-reining closed 3 months ago

lukas-reining commented 3 months ago

This PR

Adds Flipt to the playground as discussed with @markphelps.

@markphelps for being able to show "live changing" of flags I chose not to use the read-only mode with static flag definitions. I chose to use SQLite and created a copy of a DB with configured flags that can be copied before doing docker compose up. Otherwise Flipt works great with the Playground and is a great addition for showing live changes in an UI.

markphelps commented 3 months ago

cheers @lukas-reining !! thank you very much for adding Flipt to the playground!

I'm having trouble finding Flipt in the list of providers in the playground to switch between, am I doing something wrong?

CleanShot 2024-05-18 at 08 57 48

Note: I can access the Flipt UI and see that the flags / sqlite data has been imported correctly

CleanShot 2024-05-18 at 08 59 07

lukas-reining commented 3 months ago

cheers @lukas-reining !! thank you very much for adding Flipt to the playground!

I'm having trouble finding Flipt in the list of providers in the playground to switch between, am I doing something wrong?

CleanShot 2024-05-18 at 08 57 48

Note: I can access the Flipt UI and see that the flags / sqlite data has been imported correctly

CleanShot 2024-05-18 at 08 59 07

Hey @markphelps, I guess you will need to comment out the image in the docker-compose.yaml for the demo and the fib service:

services:
  demo:
    image: ghcr.io/open-feature/playground-app:v0.15.2 # x-release-please-version
    # build:
    #  dockerfile: ./packages/app/Dockerfile
    #  context: .

to

services:
  demo:
    # image: ghcr.io/open-feature/playground-app:v0.15.2 # x-release-please-version
    build:
    dockerfile: ./packages/app/Dockerfile
    context: .

Does it work now? :)

markphelps commented 3 months ago

cheers @lukas-reining !! thank you very much for adding Flipt to the playground! I'm having trouble finding Flipt in the list of providers in the playground to switch between, am I doing something wrong? CleanShot 2024-05-18 at 08 57 48 Note: I can access the Flipt UI and see that the flags / sqlite data has been imported correctly CleanShot 2024-05-18 at 08 59 07

Hey @markphelps, I guess you will need to comment out the image in the docker-compose.yaml for the demo and the fib service:

services:
  demo:
    image: ghcr.io/open-feature/playground-app:v0.15.2 # x-release-please-version
    # build:
    #  dockerfile: ./packages/app/Dockerfile
    #  context: .

to

services:
  demo:
    # image: ghcr.io/open-feature/playground-app:v0.15.2 # x-release-please-version
    build:
    dockerfile: ./packages/app/Dockerfile
    context: .

Does it work now? :)

silly me, yes works great now thank you!

one idea instead of requiring users to copy over the sqlite db before running docker-compose up would be that we could take advantage of our import functionality: https://docs.flipt.io/operations/import-export#import to import the flag state from yaml.

we do this in our examples via an init service in docker-compose, ex: https://github.com/flipt-io/flipt/blob/main/examples/openfeature/docker-compose.yml#L11-L20

it might be a bit more portable this way, but im happy either way 😄

lukas-reining commented 3 months ago

cheers @lukas-reining !! thank you very much for adding Flipt to the playground! I'm having trouble finding Flipt in the list of providers in the playground to switch between, am I doing something wrong? CleanShot 2024-05-18 at 08 57 48 Note: I can access the Flipt UI and see that the flags / sqlite data has been imported correctly CleanShot 2024-05-18 at 08 59 07

Hey @markphelps, I guess you will need to comment out the image in the docker-compose.yaml for the demo and the fib service:

services:
  demo:
    image: ghcr.io/open-feature/playground-app:v0.15.2 # x-release-please-version
    # build:
    #  dockerfile: ./packages/app/Dockerfile
    #  context: .

to

services:
  demo:
    # image: ghcr.io/open-feature/playground-app:v0.15.2 # x-release-please-version
    build:
    dockerfile: ./packages/app/Dockerfile
    context: .

Does it work now? :)

silly me, yes works great now thank you!

one idea instead of requiring users to copy over the sqlite db before running docker-compose up would be that we could take advantage of our import functionality: https://docs.flipt.io/operations/import-export#import to import the flag state from yaml.

we do this in our examples via an init service in docker-compose, ex: https://github.com/flipt-io/flipt/blob/main/examples/openfeature/docker-compose.yml#L11-L20

it might be a bit more portable this way, but im happy either way 😄

Oh I have completely overseen the import function. I switched to using it, basically exactly as you did in the linked code. This is great and is even better for starters, thanks! What do you think @markphelps?

beeme1mr commented 3 months ago

I'm not able to get it working locally. Flipt errors getting the db driver for dqlite. Here's what I'm seeing the logs.

playground-flipt-1            |     _________       __ 
playground-flipt-1            |    / ____/ (_)___  / /_
playground-flipt-1            |   / /_  / / / __ \/ __/
playground-flipt-1            |  / __/ / / / /_/ / /_  
playground-flipt-1            | /_/   /_/_/ .___/\__/  
playground-flipt-1            |          /_/           
playground-flipt-1            | 
playground-flipt-1            | Version: v1.42.0
playground-flipt-1            | Commit: 5ac6a4f16e8ac9d0eb931486b06fbddc62857d0d
playground-flipt-1            | Build Date: 2024-05-15T13:58:18Z
playground-flipt-1            | Go Version: go1.22.2
playground-flipt-1            | OS/Arch: linux/amd64
playground-flipt-1            | 
playground-flipt-1            | A newer version of Flipt exists at https://github.com/flipt-io/flipt/releases/tag/v1.42.1, 
playground-flipt-1            | please consider updating to the latest version.
playground-flipt-1            | Error: getting db driver for: sqlite3: unable to open database file: no such file or directory
playground-flipt-1 exited with code 1

The init script is also trying to mount flipt.yml but that doesn't exist at the root of the project.

lukas-reining commented 3 months ago

Yes, these were wrong, I completely oversaw those after changing to the import feature @markphelps. Can you try again @beeme1mr?

beeme1mr commented 3 months ago

It runs now but the UI wasn't bootstrapped with the flags.

image

I'm looking into it now.

beeme1mr commented 3 months ago

The error message is:

playground-init_flipt-1       | 2024-05-21T19:09:25Z    DEBUG   configuration source    {"path": "/etc/flipt/config/default.yml"}
playground-init_flipt-1       | Error: getting db driver for: sqlite3: unable to open database file: no such file or directory

It looks like we're missing default.yml in the config folder.

beeme1mr commented 3 months ago

It's working for me now. Please try my changes to make sure it works for others.

lukas-reining commented 3 months ago

Works for me too @beeme1mr! :)