-
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
[ML] Update installation mechanism for Transforms in Fleet according to new specifications #140046
Conversation
Pinging @elastic/ml-ui (:ml) |
x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts
Outdated
Show resolved
Hide resolved
Pinging @elastic/fleet (Team:Fleet) |
@qn895 thank you for working on this and adding the legacy support for the Endpoint package! I checked out the code locally and have been testing with our legacy schema. The installation is working great! However, I think we're missing the cleanup of the older, legacy transforms. More below:
I think the problem is just that when we check for transforms to remove, the code is only looking for transforms with the new naming convention in their IDs. I see this in the logs:
And in the Transforms UI, you can see that 4 transforms are installed on upgrade, while there should be 2. The Endpoint's legacy transforms will have id/names like the below which differ from the new naming convention.
When doing cleanup of old transforms we would also need to make sure we delete those for users who are upgrading from before the new schema was in place. Let me know if the above makes sense - happy to answer any questions and help test/debug further |
@kevinlog As a reminder, this piece of work is an initial iteration. It is only intended to create a reference package for transforms in Fleet in staging - we do not intend for this to move into production it its current form. We had initially wanted to use sample data, but we found we could make faster progress by following the endpoint source for reasons concerning index privileges. Sorry to get your hopes up so early. Our next steps will be
In order to get this PR moving, we will ensure it is clearly labeled for non-production. We do not expect to be working on the clean up of old endpoint transforms, although we expect to provide best practice guidelines in follow up iterations. |
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.
Went through the code with an eye for performance/stability improvements and I think everything looks good except for one minor improvement. 🚀
x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts
Outdated
Show resolved
Hide resolved
As a companion to elastic/kibana#140046 an example transform package is being created in elastic/integrations#4138. Initially the intention was that this example would use the Kibana sample data. Then, after realising that wouldn't work due to lack of permissions, it was changed to reinstall a transform that is created by the security solution. However, it has been pointed out that this is dangerous because even if we tell people not to install the example in production it could somehow happen by mistake and then we'd have created objects that clash with production code. Therefore, it is best that the example transform package be switched back to the original idea of using the Kibana sample data, so that there is no risk of it ever clashing with a production package.
@elasticmachine merge upstream |
I checked out the branch again after the refactors and the Endpoint package still installs correctly. I also ran through some upgrade scenarios with particular focus on ensuring the existing functionality for installing and upgrading legacy transforms still works (i.e. maintaining existing Endpoint package support). Some details on the scenarios I tested below, I don't see anything that should stop this PR from merging in terms of functionality. I tested the following scenarios and they work as expected:
Upgrade scenarios:
|
@qn895 I took a closer look at the 3rd upgrade scenario I referenced above.
I originally thought that this was part of more advanced upgrade capabilities that was mentioned in the "out of scope" section in the original ticket. However, I took a closer look at the Kibana logs I had locally. It looks like to me that we just need to delete any existing index patterns along with the transforms. The logs below upgrade a
Looking at this from the original description in the Fleet ticket (cc @joshdover):
Do we just need to be sure that the index templates are accounted for in Again, I don't want to increase scope of this PR beyond original expectations, but if we thought that we had already accounted for deleting older templates, then maybe this is a bug. Endpoint package can still ship using the legacy transform schema. I just wanted to be sure I called the above out as I think it would need to work to start shipping packages with the new schema. We can open a separate ticket and follow up if needed. |
@kevinlog Good catch. I had thought that we removed the old assets before we install the new ones, but that is not the case: kibana/x-pack/plugins/fleet/server/services/epm/packages/install.ts Lines 376 to 396 in 8016007
I think the solution here is to:
Was there a reason we need to have the package version in the template name? I must have missed this discussion. We don't do this for other index / data stream templates, so I'm not sure it's necessary here either. |
I don't think it's necessary to include the package version in the template names. If it helps, updating the Endpoint package following the legacy schema with a new Endpoint package following the legacy schema, transforms and templates included, is working in my tests with this PR. Are we able to follow the same logic with the new transform schema? These two upgrade scenarios were working, but both start with an Endpoint package following the legacy schema:
|
Thanks @joshdover and @kevinlog for the clarification. I've removed the version from the template names here Installing a transform with package name
Uninstalling and upgrading the package to a newer version will delete all 4 assets from the old version. To not block the PR for FF, I'll add integration tests using compliant transforms in a follow up. |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @qn895 |
@qn895 thanks for the changes! I tested the below scenarios again with the new branch and it's all working. I tested the following scenarios and they work as expected:
Upgrade scenarios:
|
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 ⚡
Summary
This PR addresses #134321 and can be tested in conjunction with the test example package elastic/integrations#4138. Changes include:
fields.yml
file is present ormanifest.yml
containsdestination_index_template
:fields.yml
file. This can be done by leveragingloadFieldsFromYaml
andgenerateMappings
manifest.yml
into a single index templateEsAssetReferences
transform.yml
file rather than a json file.manifest.yml
file containsstart: false
(the default is to start the transform if this isn't specified).Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers