-
Notifications
You must be signed in to change notification settings - Fork 222
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
Add import append flag to import new flags/segments only not existing in DB yet #3299
Conversation
93318ec
to
90452d2
Compare
Our developers keep flags and segments as code in flipt.yaml config in import format. So, it's convenient to add new flags to the same file. In some way it becomes a way to roll out migration of new flags and segments only without changing state of already existing flags and segments. |
90452d2
to
a2b583b
Compare
Hey @wtertius. Thank you for your contribution! Your use case is fascinating, and it would be helpful to understand it better. Since you already have a file containing all the flags, have you considered using a declarative storage? Is there any blocker? |
Flipt is deployed to Kubernetes namespace with the service itself and its Posgres DB. We chose to use Postgres as Flipt storage basically because we have it already. But also there are other reasons:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3299 +/- ##
==========================================
+ Coverage 64.18% 64.22% +0.03%
==========================================
Files 168 168
Lines 13506 13559 +53
==========================================
+ Hits 8669 8708 +39
- Misses 4174 4184 +10
- Partials 663 667 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
a2b583b
to
396a49d
Compare
5f817f2
to
817d611
Compare
Thank you for your contribution @wtertius !! It makes a lot of sense to me. Correct me if Im wrong but this PR seems like it's very close to whats being asked for in #2114 ? What do you think about instead changing this to an upsert operation? So that it adds any new flags/segments but also updates any that have changed? I guess that would also require us to go through each of the subrecords too (like variants, rules, rollouts, constraints, etc) and check to see if they already exist as well and if so we do an update, and if not we do an create WDYT @erka ? |
I think this will resolve that issue.
I am not sure about upsert. It looks like the database is the state of truth for a specific environment. This means product teams can directly modify flag rules and segments through the UI. While developers appreciate an easy way to introduce new flags/segments. I see it as mixin of declarative and relational storages or better to say a continuous deployment of Flipt for relational databases. Upsert the flags from file could revert the changes introduced by product teams and impact evaluation results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i think maybe we should rename the internal value from newFlagsOnly
to append
or insertOnly
like you have for the external facing command and update the description of the flag
yeah I think this will complete part of #2114, it wont fix the 'update' part requested in this comment:
However it will fix the overall issue of not having the import fail for existing data. Im good with keeping this change as is then, just want to make sure we come up with the best name possible for the user facing CLI option and description |
204519b
to
116d6e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great @wtertius ! one minor suggestion about err messages
@all-contributors please add @wtertius for code |
I've put up a pull request to add @wtertius! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @wtertius !!!
027b769
to
ad38bcd
Compare
…sting in DB yet Signed-off-by: WTertius <wtertius@gmail.com>
ad38bcd
to
3881ba8
Compare
Closes: #2114