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
chore: remove deprecated strategies and allow deprecate default #3575
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
exports.up = function (db, callback) { | ||
db.runSql( | ||
` | ||
-- delete deprecated strategies still present in v4 | ||
delete from strategies | ||
where name in ('gradualRolloutUserId', 'gradualRolloutRandom', 'gradualRolloutSessionId') | ||
and deprecated | ||
and not exists (select * from feature_strategies where strategy_name = name limit 1); | ||
|
||
-- deprecate strategies on v5 | ||
update strategies set deprecated = true where name in ('userWithId'); | ||
|
||
-- update strategy descriptions and sort order | ||
update strategies set sort_order = 1, description = 'This strategy turns on / off for your entire userbase. Prefer using "Gradual rollout" strategy (100%=on, 0%=off).' WHERE name = 'default'; | ||
update strategies set sort_order = 0 WHERE name = 'flexibleRollout'; | ||
update strategies set description = 'Enable the feature for a specific set of userIds. Prefer using "Gradual rollout" strategy with user id constraints.' WHERE name = 'userWithId'; | ||
`, | ||
callback, | ||
); | ||
}; | ||
|
||
exports.down = function (db, callback) { | ||
db.runSql( | ||
` | ||
-- restore deleted strategies | ||
insert into strategies (name, description, parameters, deprecated, sort_order) values | ||
('gradualRolloutRandom', 'Randomly activate the feature toggle. No stickiness.', [ | ||
{ | ||
"name": "percentage", | ||
"type": "percentage", | ||
"description": "", | ||
"required": false | ||
} | ||
], true, 3), | ||
('gradualRolloutSessionId', 'Gradually activate feature toggle. Stickiness based on session id.', [ | ||
{ | ||
"name": "percentage", | ||
"type": "percentage", | ||
"description": "", | ||
"required": false | ||
}, | ||
{ | ||
"name": "groupId", | ||
"type": "string", | ||
"description": "Used to define a activation groups, which allows you to correlate across feature toggles.", | ||
"required": true | ||
} | ||
], true, 4), | ||
('gradualRolloutUserId', 'Gradually activate feature toggle for logged in users. Stickiness based on user id.', [ | ||
{ | ||
"name": "percentage", | ||
"type": "percentage", | ||
"description": "", | ||
"required": false | ||
}, | ||
{ | ||
"name": "groupId", | ||
"type": "string", | ||
"description": "Used to define a activation groups, which allows you to correlate across feature toggles.", | ||
"required": true | ||
} | ||
], true, 5); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to reverse the deprecation of userWithId because the user can change that manually and there might be cases where the customer could have manually deprecated this strategy and we don't want to enable it back |
||
-- revert sort order | ||
update strategies set sort_order = 0 WHERE name = 'default'; | ||
update strategies set sort_order = 1 WHERE name = 'flexibleRollout'; | ||
`, | ||
callback, | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,14 +122,14 @@ test('returns calculated hash', async () => { | |
.get('/api/client/features') | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
expect(res.headers.etag).toBe('"ae443048:19"'); | ||
expect(res.body.meta.etag).toBe('"ae443048:19"'); | ||
expect(res.headers.etag).toBe('"ae443048:16"'); | ||
expect(res.body.meta.etag).toBe('"ae443048:16"'); | ||
Comment on lines
+125
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Min version changed because of the way we're creating strategies. We removed 3 of them from a fresh installation: https://github.com/Unleash/unleash/pull/3575/files#diff-46265b0d51725a5acbf251589b98a8970e45d3a1c6f3d7ea77bdcc3714e672d8L31-L78, therefore, we expect to have minus 3 events in the eventlog. |
||
}); | ||
|
||
test('returns 304 for pre-calculated hash', async () => { | ||
return app.request | ||
.get('/api/client/features') | ||
.set('if-none-match', '"ae443048:19"') | ||
.set('if-none-match', '"ae443048:16"') | ||
.expect(304); | ||
}); | ||
|
||
|
@@ -146,9 +146,9 @@ test('returns 200 when content updates and hash does not match anymore', async ( | |
|
||
const res = await app.request | ||
.get('/api/client/features') | ||
.set('if-none-match', 'ae443048:19') | ||
.set('if-none-match', 'ae443048:16') | ||
.expect(200); | ||
|
||
expect(res.headers.etag).toBe('"ae443048:20"'); | ||
expect(res.body.meta.etag).toBe('"ae443048:20"'); | ||
expect(res.headers.etag).toBe('"ae443048:17"'); | ||
expect(res.body.meta.etag).toBe('"ae443048:17"'); | ||
}); |
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.
This migration only deletes the strategies if they match the happy path. As we discussed there are two blockers here for deleting them:
For 1. we can probably migrate the use into using gradualRollout with the same parameters as before.
For 2. we can change the name and make it clear that its handled by the user and not unleash anymore just like other custom strategies.
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.
This is a very good comment. Ideally, we'd like to get rid of them, but there might be unexpected side effects that make me worry.
Yes, but we need to merge 3 strategies into one, which might be doable in some situations, but still won't cover all cases. I'm also not that sure how stickiness will behave if we change the strategy, because even if the strategy implementation is the same, because of the name change we might reassign users to another treatment. So I rather keep it like this
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.
I feel like this deletion should be safe, since we're explciitly checking if the strategy is in use.