Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COST-4981] reset local unleash #5148

Merged
merged 8 commits into from
Jul 11, 2024
Merged

[COST-4981] reset local unleash #5148

merged 8 commits into from
Jul 11, 2024

Conversation

maskarb
Copy link
Member

@maskarb maskarb commented Jun 5, 2024

Jira Ticket

COST-4981

Description

Closes #5068

This change will:

  • hard reset unleash locally:
    • remove everything in the flags.json (this is all deprecated anyway, so we should not rely on this method to seed the db)
    • create 2 "template" flags: cost-management.backend.schema-flag-template and cost-management.backend.source-uuid-flag-template
    • these flags can be cloned to create a real flag for local testing
  • move the .unleash dir to dev/containers/unleash
    • update the docker-compose to use this new directory
  • with unleash v5, we need to use a personal access token (PAT) to use the API. Unfortunately, you need to have a PAT in the db in order to use the API to create new PAT. To get around this, I've written a python script that directly seeds the unleash db with a PAT (dev/scripts/setup_unleash.py). This script also seeds the template flags.
  • update unleash version to match the insights instance
  • several new env variables:
    • the old admin unleash token is renamed UNLEASH_ADMIN_TOKEN
    • the new UNLEASH_TOKEN is scoped to the development environment
    • UNLEASH_PAT is the user PAT used to seed the db and can be used with any API calls wanted

Testing

  1. make docker-down delete db
  2. make docker-up-db
  3. see logs:
$ make docker-up-db
/Users/mskarbek/.rd/bin/docker compose up -d db
...
[+] Running 1/0
 ✔ Container koku-db  Running                                                                                                                                                                                                                                       0.0s 
 PostgreSQL is available!
/Users/mskarbek/.rd/bin/docker compose up -d unleash
...
[+] Running 2/0
 ✔ Container koku-db       Running                                                                                                                                                                                                                                  0.0s 
 ✔ Container koku-unleash  Running                                                                                                                                                                                                                                  0.0s 
dev/scripts/setup_unleash.py <<<<<< all of this is new
waiting for unleash to become ready
unleash is ready
adding unleash personal access token to db
[('user:6188b62f2f59348f3c195b66983147111682f4bb78a3f7ed9626bd84', 'admin', 1, datetime.datetime(3000, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 6, 5, 15, 16, 14, 82000, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 6, 5, 15, 13, 17, 56355, tzinfo=datetime.timezone.utc), 1)]
creating template unleash flags
200
...
  1. log into the unleash instance and see that there exists a PAT:
    http://localhost:4242/profile/personal-api-tokens
  2. whilst in unleash, see that there are only 2 unleash flags (mentioned above)

Release Notes

  • proposed release note
* [COST-####](https://issues.redhat.com/browse/COST-####) refresh unleash locally

@maskarb maskarb requested review from a team as code owners June 5, 2024 16:05
docker-compose.yml Show resolved Hide resolved


if __name__ == "__main__":
wait_unleash_ready()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible this could be replaced by a health check in the compose file. The unleash service could benefit from adding a healthcheck for the db service as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the healthcheck be for unleash?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unleash image only has busybox, so something like this.

healthcheck:
  test:
    - "CMD"
    - "wget"
    - "-qO-"
    - "http://localhost:4242/health"

That still needs some refinement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to leverage a healthcheck here. Even when adding one, the make command just moves on, healthy or not. The DB healthcheck is good though, so I added that. I'm just not sure we can do away with the wait_unleash_ready from this script.

dev/scripts/setup_unleash.py Outdated Show resolved Hide resolved
dev/scripts/setup_unleash.py Show resolved Hide resolved
dev/scripts/setup_unleash.py Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
dev/scripts/setup_unleash.py Outdated Show resolved Hide resolved
dev/scripts/setup_unleash.py Outdated Show resolved Hide resolved
dev/scripts/setup_unleash.py Outdated Show resolved Hide resolved
.env.example Show resolved Hide resolved
@maskarb maskarb changed the title reset local unleash [COST-4981] reset local unleash Jul 11, 2024
@maskarb maskarb merged commit 1aff116 into main Jul 11, 2024
11 checks passed
@maskarb maskarb deleted the unleash-reset branch July 11, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants