Skip to content

[Elastic Assistant] React to FF updates#223429

Merged
afharo merged 9 commits intoelastic:mainfrom
afharo:elastic_assistant/react-to-ff-updates
Jun 12, 2025
Merged

[Elastic Assistant] React to FF updates#223429
afharo merged 9 commits intoelastic:mainfrom
afharo:elastic_assistant/react-to-ff-updates

Conversation

@afharo
Copy link
Member

@afharo afharo commented Jun 11, 2025

Summary

Elastic Assistant currently evaluates 2 feature flags during Kibana startup. If the flag is false, it skips the registration of some features (like alerting rules). Since it's not subscribed to updates, it doesn't react if the flag is later switched to true. This PR changes the usage from the single-evaluation API to the observable subscription.

Additional fix

The Feature flags service now reacts to live changes to the dynamic config overrides.

@afharo afharo requested a review from a team as a code owner June 11, 2025 15:32
@afharo afharo requested a review from a team as a code owner June 11, 2025 17:23
'my-overridden-flag': true,
'myPlugin.myOverriddenFlag': true,
myDestructuredObjPlugin: { myOverriddenFlag: true },
'myDestructuredObjPlugin.myOverriddenFlag': true,
Copy link
Member Author

Choose a reason for hiding this comment

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

we're now flattening the object as we receive the overrides to make sure that we capture all flag names

@afharo afharo added backport:version Backport to applied version labels v8.19.0 backport:skip This PR does not require backporting Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes and removed backport:version Backport to applied version labels v8.19.0 labels Jun 11, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@afharo afharo self-assigned this Jun 11, 2025
@afharo afharo added the Team:Security Generative AI Security Generative AI label Jun 12, 2025
@afharo afharo added backport:version Backport to applied version labels and removed backport:skip This PR does not require backporting labels Jun 12, 2025
Copy link
Contributor

@e40pud e40pud left a comment

Choose a reason for hiding this comment

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

Thanks @afharo for helping us with using the observable-based API of feature flags service! 🙏
LGTM 🚀

@afharo afharo enabled auto-merge (squash) June 12, 2025 10:23
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @afharo

* @param enabled If the feature flag is enabled or not.
* @return `true` if susbscription needs to stay active, `false` if it can be unsubscribed.
*/
fn: (enabled: boolean) => boolean | Promise<boolean>;
Copy link
Contributor

Choose a reason for hiding this comment

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

The subscription/unsubscribe feels a bit complex and easy to get wrong, is it necessary or could we just keep the subscription always?

Copy link
Member Author

Choose a reason for hiding this comment

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

We covered it on Slack.
The 2 current use cases should stop the subscription as soon as the flag is true because they can't re-run the same code twice and they don't provide a path to unregister for the false path.

But this doesn't mean that future feature flags will follow this approach. The security team is free to simplify it, though, if they want to.

Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

Core changes lgtm but the code consuming it feels rather complex.

@afharo afharo merged commit 52a016f into elastic:main Jun 12, 2025
11 checks passed
@afharo afharo deleted the elastic_assistant/react-to-ff-updates branch June 12, 2025 14:34
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15613479735

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 12, 2025
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 52a016f)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 12, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [[Elastic Assistant] React to FF updates
(#223429)](#223429)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2025-06-12T14:34:24Z","message":"[Elastic
Assistant] React to FF updates (#223429)\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"52a016fc35b9f509b4398129a8354f71f20b7461","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","Team:Security
Generative AI","backport:version","v9.1.0","v8.19.0"],"title":"[Elastic
Assistant] React to FF
updates","number":223429,"url":"https://github.com/elastic/kibana/pull/223429","mergeCommit":{"message":"[Elastic
Assistant] React to FF updates (#223429)\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"52a016fc35b9f509b4398129a8354f71f20b7461"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/223429","number":223429,"mergeCommit":{"message":"[Elastic
Assistant] React to FF updates (#223429)\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"52a016fc35b9f509b4398129a8354f71f20b7461"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
iblancof pushed a commit to iblancof/kibana that referenced this pull request Jun 16, 2025
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@rudolf rudolf added the bug Fixes for quality problems that affect the customer experience label Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// Team:Security Generative AI Security Generative AI v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants