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

Add Dynamic Config Service to Core Service #7194

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

huyaboo
Copy link
Member

@huyaboo huyaboo commented Jul 8, 2024

Description

This PR adds a DynamicConfigService to core, enabling a subset of configs to be dynamically determined at request time. See #7111 for detailed design. By default, the feature is "disabled", meaning that when calling client.getConfig(...), the dynamicConfigService will return the static config in opensearch_dashboards.yml. The service will still exist as part of core

TODO

There are several TODO items outside the scope of this PR:

  • Register routes to make the client accessible to the service (this PR will not affect configs since the client will default to yml configs
  • Limit configs that are exposeToBrowser
  • Validation logic when creating configs
  • Determine logic for clearing the cache. Right now, the cache will not be deleted
  • Add migration logic to deprecations, much like how saved objects are migrated

Issues Resolved

Partially addresses #7111

Screenshot

The below recording shows csp.rules being added as a document in the config store index .opensearch_dashboards_config (alias for .opensearch_dashboards_config_1). The site will intentionally break when the csp.rules is set to default-src 'none'.

Screen.Recording.2024-07-08.at.2.36.38.PM.mov

Note: in the recording, I had routes registered to add routes. This is PoC code and is not included in this PR. This is to help demonstrate changes using the OpenSearch client.

Testing the changes

Changelog

  • feat: Add DynamicConfigService as a new Core service

Check List

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

Copy link
Contributor

github-actions bot commented Jul 8, 2024

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

Attention: Patch coverage is 72.14286% with 78 lines in your changes missing coverage. Please review.

Project coverage is 64.19%. Comparing base (a5c3dc2) to head (a473473).
Report is 7 commits behind head on main.

Files Patch % Lines
src/core/server/config/dynamic_config_service.ts 57.14% 19 Missing and 5 partials ⚠️
...server/config/service/configuration_client.mock.ts 42.30% 15 Missing ⚠️
...g/service/internal_dynamic_configuration_client.ts 71.42% 7 Missing and 3 partials ⚠️
src/core/server/config/utils/utils.ts 62.96% 10 Missing ⚠️
...e/config_store_client/dummy_config_store_client.ts 0.00% 7 Missing ⚠️
src/core/server/core_route_handler_context.ts 20.00% 4 Missing ⚠️
...ver/config/service/dynamic_configuration_client.ts 25.00% 3 Missing ⚠️
...ig_store_client/opensearch_config_store_factory.ts 0.00% 2 Missing ⚠️
.../core/server/config/dynamic_config_service.mock.ts 94.44% 0 Missing and 1 partial ⚠️
...fig_store_client/opensearch_config_store_client.ts 98.70% 0 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7194      +/-   ##
==========================================
+ Coverage   63.83%   64.19%   +0.36%     
==========================================
  Files        3661     3671      +10     
  Lines       81343    81072     -271     
  Branches    12978    12898      -80     
==========================================
+ Hits        51924    52044     +120     
+ Misses      26234    25838     -396     
- Partials     3185     3190       +5     
Flag Coverage Δ
Linux_1 30.22% <12.04%> (+0.07%) ⬆️
Linux_2 56.05% <70.60%> (+0.17%) ⬆️
Linux_3 40.52% <14.18%> (+0.13%) ⬆️
Linux_4 31.35% <12.04%> (+0.01%) ⬆️
Windows_1 30.23% <12.04%> (+0.07%) ⬆️
Windows_2 56.00% <70.60%> (+0.17%) ⬆️
Windows_3 40.52% <14.18%> (+0.13%) ⬆️
Windows_4 31.35% <12.04%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Jul 8, 2024

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
@huyaboo huyaboo force-pushed the huyaboo-dev branch 4 times, most recently from 60c9a4c to af2890a Compare August 27, 2024 20:54
BionIT
BionIT previously approved these changes Aug 27, 2024
zhyuanqi
zhyuanqi previously approved these changes Aug 27, 2024
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
@BionIT BionIT merged commit 8a96664 into opensearch-project:main Aug 28, 2024
67 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 28, 2024
* Add dynamic config service to core

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add opensearch client implementation

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add descriptions for the DAO clients

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor DynamicConfigService

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor dynamic config service start

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
(cherry picked from commit 8a96664)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@huyaboo huyaboo mentioned this pull request Aug 29, 2024
7 tasks
@SuZhou-Joe
Copy link
Member

SuZhou-Joe commented Aug 29, 2024

#7911 The latest artifact of OSD is not able to run, could we mitigate it?

huyaboo added a commit to huyaboo/OpenSearch-Dashboards that referenced this pull request Sep 2, 2024
* Add dynamic config service to core

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add opensearch client implementation

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add descriptions for the DAO clients

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor DynamicConfigService

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor dynamic config service start

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
(cherry picked from commit 8a96664)

Fix issue when bootstrapping on 2.x (opensearch-project#7901)

* Fix issue bootstrapping dynamic config service

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Changeset file for PR opensearch-project#7901 created/updated

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 07504f6)

Fix mock import (opensearch-project#7922)

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
(cherry picked from commit b370871)
BionIT pushed a commit that referenced this pull request Sep 3, 2024
* Add dynamic config service to core

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add opensearch client implementation

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add descriptions for the DAO clients

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor DynamicConfigService

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor dynamic config service start

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
(cherry picked from commit 8a96664)

Fix issue when bootstrapping on 2.x (#7901)

* Fix issue bootstrapping dynamic config service

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Changeset file for PR #7901 created/updated

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 07504f6)

Fix mock import (#7922)

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
(cherry picked from commit b370871)

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
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