-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Create API to report status of integrations synchronization #216178
base: main
Are you sure you want to change the base?
Conversation
@elasticmachine merge upstream |
.../platform/plugins/shared/fleet/server/tasks/sync_integrations/sync_integrations_on_remote.ts
Outdated
Show resolved
Hide resolved
.../platform/plugins/shared/fleet/server/tasks/sync_integrations/sync_integrations_on_remote.ts
Outdated
Show resolved
Hide resolved
if (!installedIntegrations) { | ||
return { | ||
items: [], | ||
error: `No integrations installed on remote` |
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.
it's not necessarily an error if the main cluster doesn't have any integrations either
x-pack/platform/plugins/shared/fleet/server/routes/remote_synced_integrations/index.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/fleet/dev_docs/local_setup/remote_clusters_ccr.md
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.ts
Outdated
Show resolved
Hide resolved
|
||
try { | ||
const installedPipelines = await getPipeline(esClient, abortController); | ||
const installedComponentTemplates = await getComponentTemplate(esClient, abortController); |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipelines have an optional version which we can use to compare like here
kibana/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.ts
Line 241 in b438a71
(existingPipeline.version && existingPipeline.version < customAsset.pipeline.version) || |
we should probably have a common logic to compare here and
custom_assets.ts
@elasticmachine merge upstream |
Pinging @elastic/fleet (Team:Fleet) |
...form/plugins/shared/fleet/dev_docs/diagrams/remote_clusters/remote_clusters_architecture.png
Outdated
Show resolved
Hide resolved
…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'
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we return the error message instead of throwing an error?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be synchronizing too
💚 Build Succeeded
Metrics [docs]Module Count
History
cc @criamico |
return { | ||
...ccrIntegration, | ||
sync_status: 'failed' as SyncStatus.FAILED, | ||
error: `Installation status: ${localIntegrationSO?.attributes.install_status}`, |
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.
can we return the error message if install_status: install_failed
from latest_install_failed_attempts
or latest_executed_state
?
latest_install_failed_attempts?: InstallFailedAttempt[]; |
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.
LGTM, thanks for the updates
Closes #192363
Summary
Add endpoint that compares integrations installed on remote cluster with integrations in ccr index
fleet-synced-integrations-ccr-<outputId>
. Feature flag:enableSyncIntegrationsOnRemote
Testing
Setup local env with the guide added in dev_docs (preview)
system
system
Checklist