Skip to content
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 a new UIExtensionPoint to replace the integration define step #149653

Merged
merged 8 commits into from
Feb 1, 2023

Conversation

orouz
Copy link
Contributor

@orouz orouz commented Jan 27, 2023

Summary

adds a new extension point to replace a package installation first step entirely.

Checklist

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:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@orouz orouz force-pushed the fleet_replace_step_ext branch from 7ca8ded to 105a50e Compare January 29, 2023 13:03
@orouz orouz force-pushed the fleet_replace_step_ext branch from 105a50e to 2499179 Compare January 29, 2023 13:07
Comment on lines 39 to 47
export type PackagePolicyReplaceDefineStepExtensionComponentProps = (
| (PackagePolicyEditExtensionComponentProps & { isEditPage: true })
| (PackagePolicyCreateExtensionComponentProps & { isEditPage: false })
) & {
validationResults?: PackagePolicyValidationResults;
agentPolicy?: AgentPolicy;
packageInfo: PackageInfo;
integrationInfo?: RegistryPolicyTemplate;
};
Copy link
Contributor Author

@orouz orouz Jan 29, 2023

Choose a reason for hiding this comment

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

since this extension replaces the first step entirely, and it slightly differs between edit and create, i've used the same props from the relevant existing extension points.

the added props are from the actual props StepDefinePackagePolicy receives, so any functionality it does inside an be replicated.

Comment on lines 275 to 280
if (replaceDefineStepView && extensionView) {
// eslint-disable-next-line no-console
console.warn(
"'package-policy-create' is ignored when 'package-policy-replace-define-step' is defined"
);
}
Copy link
Contributor Author

@orouz orouz Jan 29, 2023

Choose a reason for hiding this comment

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

not sure logging here is good enough, we could add useUIExtensions which would be typed to not allow this combination

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think useUIExtensions or adding an overload to useUIExtension that takes an array of extensions would be the path forward here. Agree that logging is not enough to prevent this, as we should prevent it entirely at compile time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kpollich

thought about this again and i believe we shouldn't overload useUIExtension, because:

  • registration is not really constrained, so we could narrow the types but that won't make them true
    • we can't fully limit registration with static types, as it can be done multiple times.
    • we can make registerExtension take an array and type-check against invalid combinations, and run a full sweep on other plugins, which would somewhat mitigate possible future risk of misuse
  • there is actually not much to do with that information. we still need to account for both cases, and when doing those we don't need the other extension anyway. after making the types work, i noticed the distinction wasn't really used
  • overloading wasn't pretty

let me know what you think is best here/follow ups:

  • add/iterate on overloading commit
  • just drop/keep the comments
  • work on registerExtension
  • something else?

thanks!

also note i'd still want to merge #149137 as soon as we can because there are other PRs depending on it

Copy link
Member

Choose a reason for hiding this comment

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

Following up on our chat offline:

Let's just throw an error when we encounter this case. This should result in the Fleet UI's error boundary being displayed and should catch the "incompatible UI extension" state during development. I don't want to silently ignore a UI extension with a browser console log/warning because it will be non-obvious to someone developing in this situation.

if (replaceDefineStepView && extensionView) { 
  throw new Error(
    "'package-policy-create' and 'package-policy-replace-define-step' cannot both be registered as UI extensions"
  )
}

Thanks for investigating here and following up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this with some test updates that were needed

@orouz orouz marked this pull request as ready for review January 30, 2023 14:53
@orouz orouz requested a review from a team as a code owner January 30, 2023 14:53
@orouz orouz requested review from kpollich and nchaulet January 30, 2023 14:53
@orouz orouz added v8.7.0 release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Jan 30, 2023
Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

No real issues for me on this - think things look pretty standard alongside the other UI extensions. The only wrinkle is the exclusivity between package-policy-create and package-policy-replace-define-step which I think we should solve via TypeScript assertions as you've suggested.

Once that's addressed I'd be more than happy to +1 this and ship. Awesome work! 🚀

Comment on lines 275 to 280
if (replaceDefineStepView && extensionView) {
// eslint-disable-next-line no-console
console.warn(
"'package-policy-create' is ignored when 'package-policy-replace-define-step' is defined"
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think useUIExtensions or adding an overload to useUIExtension that takes an array of extensions would be the path forward here. Agree that logging is not enough to prevent this, as we should prevent it entirely at compile time.

@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Jan 30, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@kfirpeled kfirpeled linked an issue Jan 31, 2023 that may be closed by this pull request
4 tasks
Comment on lines 275 to 280
if (replaceDefineStepView && extensionView) {
// eslint-disable-next-line no-console
console.warn(
"'package-policy-create' is ignored when 'package-policy-replace-define-step' is defined"
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Following up on our chat offline:

Let's just throw an error when we encounter this case. This should result in the Fleet UI's error boundary being displayed and should catch the "incompatible UI extension" state during development. I don't want to silently ignore a UI extension with a browser console log/warning because it will be non-obvious to someone developing in this situation.

if (replaceDefineStepView && extensionView) { 
  throw new Error(
    "'package-policy-create' and 'package-policy-replace-define-step' cannot both be registered as UI extensions"
  )
}

Thanks for investigating here and following up.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 923.5KB 924.4KB +926.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
fleet 25 26 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@orouz orouz merged commit f002889 into elastic:main Feb 1, 2023
kqualters-elastic pushed a commit to kqualters-elastic/kibana that referenced this pull request Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cloud Posture] Hide default integration configuration component
4 participants