[Fleet] Create API to report status of integrations synchronization#216178
Conversation
|
@elasticmachine merge upstream |
| if (!installedIntegrations) { | ||
| return { | ||
| items: [], | ||
| error: `No integrations installed on remote` |
There was a problem hiding this comment.
it's not necessarily an error if the main cluster doesn't have any integrations either
|
|
||
| try { | ||
| const installedPipelines = await getPipeline(esClient, abortController); | ||
| const installedComponentTemplates = await getComponentTemplate(esClient, abortController); |
There was a problem hiding this comment.
I went for the solution of fetching all the pipelines and component templates and keep them on memory, instead of doing a call for each one in the loop below. @juliaElastic do you think it could become a performance issue?
There was a problem hiding this comment.
We should only compare pipelines and component templates that match '*@custom', like it's done in custom_assets.ts. The other assets are already installed when the package is installed, no need to compare them.
| Object.entries(ccrCustomAssets).forEach(([ccrCustomName, ccrCustomAsset]) => { | ||
| if (ccrCustomAsset.type === 'ingest_pipeline') { | ||
| const installedAsset = installedPipelines[ccrCustomAsset?.name]; | ||
| if (isEqual(installedAsset?.processors, ccrCustomAsset?.pipeline?.processors)) { |
There was a problem hiding this comment.
pipelines have an optional version which we can use to compare like here
we should probably have a common logic to compare here and
custom_assets.ts
|
@elasticmachine merge upstream |
|
Pinging @elastic/fleet (Team:Fleet) |
|
@juliaElastic based on the new requirements in #217025 we should be able to query by output_id:
In a previous commit it was already by output_id. Do you think we'll need to keep the general status? Otherwise I'll change it directly in this PR. |
|
@elasticmachine merge upstream |
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/dashboards --update'
We can keep as is in the current pr, as it collects the status in the remote cluster. The new API by |
|
@elasticmachine merge upstream |
| return { info: res.follower_indices[0] }; | ||
| } catch (err) { | ||
| if (err?.body?.error?.type === 'index_not_found_exception') | ||
| throw new IndexNotFoundError(`Index not found`); |
There was a problem hiding this comment.
should we return the error message instead of throwing an error?
There was a problem hiding this comment.
It's handled here: https://github.com/elastic/kibana/pull/216178/files#diff-f8de6a6d308d65b9d61c400a2fdbebe1078e67eaf036537c028476260be254f5R312-R315
I left the throw block and handled outside because we might need this function elsewhere, this is a basic utility for the ccr case.
There was a problem hiding this comment.
okay, then shouldn't we return the error in the catch there? https://github.com/elastic/kibana/pull/216178/files#diff-f8de6a6d308d65b9d61c400a2fdbebe1078e67eaf036537c028476260be254f5R324
There was a problem hiding this comment.
Fixed, I added some unit tests to cover these cases
| }; | ||
| } else if ( | ||
| installedPipeline?.version && | ||
| installedPipeline.version < ccrCustomAsset.pipeline.version |
There was a problem hiding this comment.
the version comparison should be done before the equality check, so we can skip the equality check if the version is not equal
| if (ccrCustomAsset.is_deleted === true && installedPipeline) { | ||
| return { | ||
| ...result, | ||
| sync_status: 'failed' as SyncStatus.FAILED, |
There was a problem hiding this comment.
should this be synchronizing (the deletion might not have happened yet) unless we know there was an error deleting?
| if (ccrCustomAsset.is_deleted === true && installedCompTemplate) { | ||
| return { | ||
| ...result, | ||
| sync_status: 'failed' as SyncStatus.FAILED, |
There was a problem hiding this comment.
same here, should these be synchronizing unless we know there was an error deleting?
|
@elasticmachine merge upstream |
| @@ -255,6 +250,11 @@ const compareCustomAssets = ({ | |||
| sync_status: 'failed' as SyncStatus.FAILED, | |||
There was a problem hiding this comment.
this should be synchronizing too
| return { | ||
| ...ccrIntegration, | ||
| sync_status: 'failed' as SyncStatus.FAILED, | ||
| error: `Installation status: ${localIntegrationSO?.attributes.install_status}`, |
There was a problem hiding this comment.
can we return the error message if install_status: install_failed from latest_install_failed_attempts or latest_executed_state?
juliaElastic
left a comment
There was a problem hiding this comment.
LGTM, thanks for the updates
💛 Build succeeded, but was flaky
Failed CI StepsTest FailuresMetrics [docs]Module Count
History
cc @criamico |
…ut ID (#217799) Part II of #217025 ## Summary Create API that queries remote kibana sync status API by output ID. From the main cluster we call the remote kibana (simply using node-fetch) and query the endpoint added in #216178; this way the main cluster can have the status of the synced integrations on the remote cluster. ### Testing Note that dev_docs now have a guide to setup locally the remote clusters: https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/fleet/dev_docs/local_setup/remote_clusters_ccr.md - Follow the testing steps from [this PR](#216178) - Install some integrations on cluster A (main) and wait 5 minutes to get `SyncIntegrationsTask` running - Verify that cluster B (remote) has the same integrations installed. From dev tools, run ``` GET kbn:/api/fleet/remote_synced_integrations/status ``` - Go on dev tools on cluster A and run the new endpoint - `remote_id` is the id of the remote output configured on cluster A: ``` GET kbn:/api/fleet/remote_synced_integrations/<remote_id>/remote_status ``` The response should be the same as above ### Screenshot On Remote cluster (Cluster B): <img width="1183" alt="Screenshot 2025-04-10 at 15 40 46" src="https://github.com/user-attachments/assets/60ea1c1e-9ccf-4bcf-8637-bc4079483e61" /> On main cluster (Cluster A): <img width="1690" alt="Screenshot 2025-04-11 at 11 10 30" src="https://github.com/user-attachments/assets/e72fd729-3486-41b0-9194-487233415a75" /> ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Closes #192363
Summary
Add endpoint that compares integrations installed on remote cluster with integrations in ccr index
fleet-synced-integrations-ccr-<outputId>. Feature flag:enableSyncIntegrationsOnRemoteTesting
Setup local env with the guide added in dev_docs (preview)
systemsystemChecklist