Skip to content

[Fleet] Migrate inputs when migrate_from field is found#242934

Merged
criamico merged 26 commits intoelastic:mainfrom
criamico:poc_migrate_inputs
Mar 20, 2026
Merged

[Fleet] Migrate inputs when migrate_from field is found#242934
criamico merged 26 commits intoelastic:mainfrom
criamico:poc_migrate_inputs

Conversation

@criamico
Copy link
Copy Markdown
Contributor

@criamico criamico commented Nov 13, 2025

Related to elastic/package-spec#956
Package-spec PR: elastic/package-spec#1021

Summary

Migrate inputs and vars when migrate_from field is found.

Please note: for some integrations this migration path will require a change at elastic agent level. See elastic/package-spec#956 (comment)

  • Enable the new input and carries over its values from the old one
  • Inputs and variables that were enabled are now carried to the new version; however the state is maintained: if a variable is disabled, it stays disabled
  • Modified the secret handling so the existing secret references get carried over to the new inputs
  • Verified that this logic only run on package policy upgrade, when there is migrate_from present and Fleet detects a difference in input type
  • Add visual information about the migration

Example with a test integration:
https://github.com/user-attachments/assets/aaa56904-05d7-47b2-955b-5ae7a2c26c97

Testing

This was tested with a test version of sentinelOne (not finalized yet): https://github.com/elastic/integrations/compare/main...kcreddy:sentinel_one-migrate-inputs?expand=1

Screenshots

Screenshot 2026-03-19 at 17 07 17 Screenshot 2026-03-19 at 17 07 43

Checklist

Reviewers should verify this PR satisfies this list as well.

@criamico criamico self-assigned this Nov 13, 2025
@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Nov 13, 2025
@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico criamico marked this pull request as ready for review February 25, 2026 10:22
@criamico criamico requested a review from a team as a code owner February 25, 2026 10:22
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner February 25, 2026 10:35
@criamico criamico added release_note:feature Makes this part of the condensed release notes backport:skip This PR does not require backporting v9.4.0 labels Feb 25, 2026
@criamico criamico requested a review from jsoriano February 25, 2026 11:11
@criamico criamico added the ci:cloud-deploy Create or update a Cloud deployment label Feb 26, 2026
@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico criamico added ci:cloud-deploy Create or update a Cloud deployment and removed ci:cloud-deploy Create or update a Cloud deployment labels Feb 27, 2026
// input should never be auto-enabled or have user configuration carried into it.

let originalInputToMigrate: NewPackagePolicyInput | undefined;
if (update.migrate_from !== undefined && !update.deprecated) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it would be nice to break down this logic to smaller functions

update.streams = update.streams.map((newStream, idx) => {
let oldStream;

// Migrate stream-level vars by position since datasets differ between input types.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do I understand this correctly in that we assume that the old and new input types have an equivalent set of streams in the same order? Or could it happen that the new input type has more or fewer streams than the old one? Should there be an explicit check for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question, I assumed that the migration is to an equivalent set of streams, but I have to ask the integration team. There was a similar discussion here but I'm not 100% sure about the streams.

// input should never be auto-enabled or have user configuration carried into it.

let originalInputToMigrate: NewPackagePolicyInput | undefined;
if (update.migrate_from !== undefined && !update.deprecated) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For my understanding: migrate_from doesn't seem to be cleaned up after migration, but that shouldn't be a concern on a future upgrade?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

migrate_from comes directly from the package and it's not stored anywhere, so if the next version doesn't have it anymore it shouldn't be a concern.

Copy link
Copy Markdown
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Mar 5, 2026

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

⏳ Build in-progress

History

cc @criamico

@criamico criamico merged commit fa0af58 into elastic:main Mar 20, 2026
18 checks passed
jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Mar 26, 2026
Related to elastic/package-spec#956
Package-spec PR: elastic/package-spec#1021


## Summary

Migrate inputs and vars when `migrate_from` field is found. 

**Please note:** for some integrations this migration path will require
a change at elastic agent level. See
elastic/package-spec#956 (comment)

- Enable the new input and carries over its values from the old one
- Inputs and variables that were enabled are now carried to the new
version; however the state is maintained: if a variable is disabled, it
stays disabled
- Modified the secret handling so the existing secret references get
carried over to the new inputs
- Verified that this logic only run on package policy upgrade, when
there is migrate_from present and Fleet detects a difference in input
type
- Add visual information about the migration

Example with a test integration:

https://github.com/user-attachments/assets/aaa56904-05d7-47b2-955b-5ae7a2c26c97

### Testing
This was tested with a test version of sentinelOne (not finalized yet):
https://github.com/elastic/integrations/compare/main...kcreddy:sentinel_one-migrate-inputs?expand=1



### Screenshots
<img width="1641" height="1540" alt="Screenshot 2026-03-19 at 17 07 17"
src="https://github.com/user-attachments/assets/819e46cd-823a-47df-8ef2-4fbce8900b53"
/>

<img width="1628" height="1524" alt="Screenshot 2026-03-19 at 17 07 43"
src="https://github.com/user-attachments/assets/c5f97183-bcfd-496a-9882-e170323246e3"
/>

### Checklist

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[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: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:cloud-deploy Create or update a Cloud deployment release_note:feature Makes this part of the condensed release notes Team:Fleet Team label for Observability Data Collection Fleet team v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants