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

[Refractor] Feature flag #102

Merged
merged 9 commits into from
Aug 28, 2023

Conversation

SuZhou-Joe
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe commented Aug 23, 2023

Description

Issues Resolved

Screenshot

Testing the changes

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@SuZhou-Joe SuZhou-Joe marked this pull request as draft August 23, 2023 10:19
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2023

Codecov Report

Merging #102 (979015a) into workspace (a058a37) will decrease coverage by 11.03%.
The diff coverage is n/a.

@@              Coverage Diff               @@
##           workspace     #102       +/-   ##
==============================================
- Coverage      65.75%   54.72%   -11.03%     
==============================================
  Files           3336     3038      -298     
  Lines          64493    60368     -4125     
  Branches       10264     9632      -632     
==============================================
- Hits           42406    33038     -9368     
- Misses         19541    25211     +5670     
+ Partials        2546     2119      -427     
Flag Coverage Δ
Linux_1 34.75% <ø> (ø)
Linux_3 42.64% <ø> (-0.01%) ⬇️
Windows_1 34.77% <ø> (?)
Windows_2 ?
Windows_3 ?
Windows_4 34.74% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 702 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@SuZhou-Joe SuZhou-Joe marked this pull request as ready for review August 24, 2023 02:55
path: `${WORKSPACES_API_BASE_URL}/is_workspace_enabled`,
validate: {},
},
router.handleLegacyErrors(async (context, req, res) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Should it call context.core.uiSettings.client.get(FEATURE_FLAG_KEY_IN_UI_SETTING) to get the flag directly from saved objects?

Copy link
Collaborator Author

@SuZhou-Joe SuZhou-Joe Aug 24, 2023

Choose a reason for hiding this comment

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

I think that the flag in browser side should be consistent to the flag in server side, but not the opensearch side. The flag in server side may not be consistent to the flag in kibana index because user may call index update API to update the flag directly.

Copy link
Owner

Choose a reason for hiding this comment

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

I see, so if changing the flag in the index but not via setWorkspaceFeatureFlag will require a server restart?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, and that is not a expected behavior to update flag.

private config$: Observable<ConfigSchema>;
private enabled$: BehaviorSubject<boolean> = new BehaviorSubject(false);
private loopRequestTimer?: NodeJS.Timeout;
Copy link
Owner

Choose a reason for hiding this comment

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

Was this used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, my fault. There was a timer to check the flag in kibana index and try to keep the enabled$ consistent with the real flag in kibana index. Done for removing this.

@@ -396,7 +396,7 @@ export class WorkspaceSavedObjectsClientWrapper {

const isDashboardAdmin = this.isDashboardAdmin(wrapperOptions.request);

if (isDashboardAdmin) {
if (isDashboardAdmin || !this.options.enabled$.getValue()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The #scopedSavedObjectsClient in src/core/server/core_route_handler_context.ts won't be re-initialized which means will always use the wrapperOptions.client after enabled$ changed. Is this could be an issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, did not know that but it is fine because savedObjectsClient does not rely on enabled$.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the client wrapper won't work as expect after enabled change. Such as we can test if the ACL check will be by passed after enabled change.

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 see what you mean, when we enable the feature flag, the client is generated with internalRepository, and after we switch the flag, the savedObjectsClient will still be internalSavedObjectsClient, is this what you want to point out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wanglam I did some changes to generate savedObjectsClient in runtime, please help to take a look. It should fix the client cache problem.

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@SuZhou-Joe SuZhou-Joe merged commit e2f277c into ruanyl:workspace Aug 28, 2023
44 of 47 checks passed
SuZhou-Joe added a commit that referenced this pull request Aug 31, 2023
* feat: add some flag

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* refractor: add enabled$ in server side

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add logic check in public side

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feature: remove useless property

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: some modify

* feat: merge

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
SuZhou-Joe added a commit that referenced this pull request Aug 31, 2023
* feat: add some flag

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* refractor: add enabled$ in server side

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add logic check in public side

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feature: remove useless property

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: some modify

* feat: merge

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
ruanyl added a commit that referenced this pull request Sep 5, 2023
ruanyl added a commit that referenced this pull request Sep 6, 2023
ruanyl added a commit that referenced this pull request Sep 6, 2023
* Revert "[Refractor] Feature flag (#102)"

This reverts commit e2f277c.
SuZhou-Joe pushed a commit that referenced this pull request Sep 6, 2023
* Revert "[Refractor] Feature flag (#102)"

This reverts commit e2f277c.
SuZhou-Joe pushed a commit that referenced this pull request Sep 11, 2023
* Revert "[Refractor] Feature flag (#102)"

This reverts commit e2f277c.
ruanyl pushed a commit that referenced this pull request Sep 15, 2023
* feat: add some flag

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* refractor: add enabled$ in server side

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add logic check in public side

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feature: remove useless property

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: some modify

* feat: merge

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
ruanyl added a commit that referenced this pull request Sep 15, 2023
* Revert "[Refractor] Feature flag (#102)"

This reverts commit e2f277c.
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