-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Adding post create package callback #128744
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
Conversation
|
I'm curious if we could instead move the current callback to be executed after the package policy is created rather than before. It's current name even indicates it would be executed after: @paul-tavares It looks like you added these back in #69428, do you remember why the hook is called before the package policy is created? |
|
Re:
So the name is certainly confusing - the For Endpoint, we do need an extension point before the package policy is saved. Thats because we need to retrieve the latest endpoint artifact manifest in order to include it in the package policy being created. |
|
Thanks, Paul. Makes sense. Ido, I think it makes sense to proceed with this PR. Maybe we should change some of the naming and not use the word |
|
yeah, renaming would be good. names like |
|
Hey @joshdover and @paul-tavares - thanks for your comments, I will take them into account while working on it. |
079da5d to
a4a6033
Compare
|
Hey @joshdover, @paul-tavares - updating that I added the new callback type For now, I leave the naming of the existing callback One known gap: I still didn't solve typescript issue that can be found also in the CI output |
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.
FYI Calling this in the handler means this will not work for preconfigured package policies, we already have the bug for other callbacks so it should probably not be addressed here #129383
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.
Great callout, agreed it'd be ok to defer on this and fix it for all callbacks in the same PR. That way they're all at least consistent.
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.
🤔 because the extension points are executed from the PackagePolicy service, I'm assuming the fix to the mentioned issue is to call the service method (runExternalCallbacks()) from the location where the preconfigured packages policies are added/updated while still leaving this code here in place.
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 think the idea would be to have packagePolicyService.create call runExternalCallbacks before returning the newly created policy to the caller. That way there is only a single call site that always runs regardless of how the package policy was created.
|
Pinging @elastic/fleet (Team:Fleet) |
kfirpeled
left a comment
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, fills our requirement: having integration's assets available on post-create callback
paul-tavares
left a comment
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.
Thanks for including me on this. The changes look good to me 👍 , but I defer approval to the fleet team on this.
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.
🤔 because the extension points are executed from the PackagePolicy service, I'm assuming the fix to the mentioned issue is to call the service method (runExternalCallbacks()) from the location where the preconfigured packages policies are added/updated while still leaving this code here in place.
a4a6033 to
c637bc6
Compare
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 think the idea would be to have packagePolicyService.create call runExternalCallbacks before returning the newly created policy to the caller. That way there is only a single call site that always runs regardless of how the package policy was created.
56bff9b to
11ac705
Compare
| ...PackagePolicyInputsSchema, | ||
| compiled_input: schema.maybe(schema.any()), | ||
| }) | ||
| ), |
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.
Hey @joshdover, I re-request your review according to this change, I tried to use this scheme for validation and found that is not aligned with the PackagePolicy type.
export interface PackagePolicy extends Omit<NewPackagePolicy, 'inputs'> {
id: string;
inputs: PackagePolicyInput[];
version?: string;
revision: number;
updated_at: string;
updated_by: string;
created_at: string;
created_by: string;
}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.
Thanks for the ping, this change makes sense. At first I thought that maybe the elasticsearch key should be duplicated / moved to CreatePackagePolicyProps as well but that would allow setting it on the API which we explicitly do not support. Everything else LGTM, thanks @CohenIdo
In the future, we may want to try refactoring this to derive the TS types from the config schema using the TypeOf helper from kbn/config-schema.
@paul-tavares, @joshdover already approved, (I re-request his review again according to one more change), please have a look:) |
| ...PackagePolicyInputsSchema, | ||
| compiled_input: schema.maybe(schema.any()), | ||
| }) | ||
| ), |
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.
Thanks for the ping, this change makes sense. At first I thought that maybe the elasticsearch key should be duplicated / moved to CreatePackagePolicyProps as well but that would allow setting it on the API which we explicitly do not support. Everything else LGTM, thanks @CohenIdo
In the future, we may want to try refactoring this to derive the TS types from the config schema using the TypeOf helper from kbn/config-schema.
a03e724 to
c213090
Compare
💚 Build SucceededMetrics [docs]Public APIs missing comments
Public APIs missing exports
History
To update your PR or re-run it, just comment with: |
Add a new call-back type that will be executed after the package policy is created.