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

feat(flags): Fetch flags and team from database #23120

Merged
merged 32 commits into from
Jul 24, 2024
Merged

Conversation

neilkakkar
Copy link
Collaborator

@neilkakkar neilkakkar commented Jun 20, 2024

Problem

Pipeline-folks, would love some eyes on the CI changes, if its fine with you, and if you have any comments on the db handling here :)

TODO:

  1. Setup CI to run db migrations
  2. For some small tests, would be ideal to also do the flag inserts via django, and fetch via sqlx. Slower, but makes solid any assumptions around specialised django inserts
  3. lots more validation tests
  4. clean up error handling, it's a mess currently.

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

@neilkakkar neilkakkar marked this pull request as ready for review June 20, 2024 16:04
@neilkakkar neilkakkar requested a review from a team June 20, 2024 16:05
@neilkakkar neilkakkar requested a review from a team June 20, 2024 16:06
pub payloads: Option<serde_json::Value>,
pub super_groups: Option<Vec<FlagGroupType>>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct FeatureFlag {
pub id: i64,
pub team_id: i64,
pub id: i32,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

switched types here to reflect db type, otherwise it'd complain about the conversion

pub team_id: i32,
pub name: Option<String>,
pub key: String,
pub filters: serde_json::Value,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've opted to first parse filters out as just a json value, and then deserialise that into FlagFilters for better handling, and because it was getting pretty hard to try and coerce directly into the struct form I want.

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot posthog-bot removed the stale label Jul 2, 2024
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

I'm going to conditionally approve this to see if CI behaves in the way I expect – we're getting this odd "status could not be reported" error from the Rust services test, but each of the test jobs themselves have run correctly. I want to see if that job reporting a yellow status blocks our ability to merge (my guess is that it does not), but just checking here.

dmarticus
dmarticus previously approved these changes Jul 16, 2024
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

I'm going to conditionally approve this to see if CI behaves in the way I expect – we're getting this odd "status could not be reported" error from the Rust services test, but each of the test jobs themselves have run correctly. I want to see if that job reporting a yellow status blocks our ability to merge (my guess is that it does), but just checking here.

@dmarticus dmarticus dismissed their stale review July 16, 2024 20:30

turns out this hanging job is actually blocking our ability to merge, how dumb.

@neilkakkar
Copy link
Collaborator Author

(this is happening because I updated CI to use a matrix which changes the names of the test 😮‍💨 ) - you can remove this test requirement for now, merge, and then re-add it to branch protection rules with the (flags / others) suffix ✅

@neilkakkar
Copy link
Collaborator Author

@dmarticus
Copy link
Contributor

(this is happening because I updated CI to use a matrix which changes the names of the test 😮‍💨 ) - you can remove this test requirement for now, merge, and then re-add it to branch protection rules with the (flags / others) suffix ✅

Hi Neil, I hope this didn't bother you too much during your break! I chatted with Jams about this and we came to a similar conclusion, but thank you for weighing in :)

Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

Shipping what we have in the interest of keeping the change sets small. The next PR will contain the validation tests and the django inserts + sqlx reads.

@fuziontech fuziontech merged commit 50adf3b into master Jul 24, 2024
85 checks passed
@fuziontech fuziontech deleted the flag-from-db branch July 24, 2024 15:40
@@ -22,3 +22,39 @@ where
.route("/flags", post(v0_endpoint::flags).get(v0_endpoint::flags))
.with_state(state)
}

// TODO, eventually we can differentiate read and write postgres clients, if needed
// I _think_ everything is read-only, but I'm not 100% sure yet
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there shall cometh a write client too 🫠

see the part below this line: https://github.com/PostHog/posthog/blob/master/posthog/models/feature_flag/flag_matching.py#L797

silentninja pushed a commit to silentninja/posthog that referenced this pull request Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants