-
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] Modal to allow user to force install an unverified package #136108
[Fleet] Modal to allow user to force install an unverified package #136108
Conversation
bd3d885
to
c73ea10
Compare
Pinging @elastic/fleet (Team:Fleet) |
@@ -259,6 +270,7 @@ async function installPackageFromRegistry({ | |||
spaceId, | |||
force = false, | |||
ignoreConstraints = false, | |||
neverIgnoreVerificationError = false, |
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.
From an API point of view, force means "ignore version check and verification check" However internally sometimes we want to skip the version check but not the verification check. For example on install when we allow a user to install an outdated package if they dont have a leter version installed https://github.com/elastic/kibana/pull/136108/files#diff-cf9cec44de2ad0a6a3b74cca05e5308231d57d5c3e180ae4bc5114c2bf9af4ebR134
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 neverIgnore
naming here seems a little confusing with the kind of double negative in place. Could this be a "positive" condition defaulting to true instead to make this more clear? Maybe like surfaceVerificationErrors
or forceVerificationErrors
or something along those lines?
I understand the idea here is something like
force
by itself will suppress verification errors and allow installing outdated package versionforce
with an additional flag should still allow for installing any package version, but should still surface verification errors
}; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & PackageInstallItem; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & | ||
PackageInstallItem & { error?: FleetErrorResponse }; |
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 have added the latest install error to the package install status in order to display the modal based on the error response.
: i18n.translate('xpack.fleet.unverifiedPackageModal.calloutTitleNoPkg', { | ||
defaultMessage: 'The integration has failed verification', | ||
}); | ||
// TODO: add link to docs |
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.
covered in the implementation list of the parent ticket.
@@ -33,7 +33,7 @@ export interface GetOnePackagePolicyResponse { | |||
} | |||
|
|||
export interface CreatePackagePolicyRequest { | |||
body: NewPackagePolicy; | |||
body: NewPackagePolicy & { force?: boolean }; |
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.
force
is not a new parameter, its just the typing didn't have it
}; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & PackageInstallItem; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & | ||
PackageInstallItem & { error?: FleetErrorResponse }; | ||
|
||
function usePackageInstall({ |
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 am wondering if we should show the confirm modal here using the overlay service, I see the useInstallPackage
is used in a few different place and for upgrade too, I think it will make consuming that hook easier. What do you think?
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.
Yeah I'd be interested to see if we can have a "global" modal instead of rendering it in a few different places. The hook can then toggle some context value to hide/show the global modal. Similar to how some of our flyouts work. The overlay service @nchaulet mentioned is also probably a good idea, but I haven't had experience using it yet.
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.
an example on how we use the overlay service in Fleet already, it also make testing the hook quite easy, you just have to mock that service https://github.com/hop-dev/kibana/blob/c73ea10d74cc5210dcdbae5ec4177175f49ecd94/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/hooks/index.tsx#L25
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 agree that looks better, I'll have a go 👍
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.
Seems like this went mostly well. Any gotchas we should be aware of here?
...olicy/create_package_policy_page/multi_page_layout/components/page_steps/add_integration.tsx
Show resolved
Hide resolved
}; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & PackageInstallItem; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & | ||
PackageInstallItem & { error?: FleetErrorResponse }; | ||
|
||
function usePackageInstall({ |
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.
Yeah I'd be interested to see if we can have a "global" modal instead of rendering it in a few different places. The hook can then toggle some context value to hide/show the global modal. Similar to how some of our flyouts work. The overlay service @nchaulet mentioned is also probably a good idea, but I haven't had experience using it yet.
@@ -259,6 +270,7 @@ async function installPackageFromRegistry({ | |||
spaceId, | |||
force = false, | |||
ignoreConstraints = false, | |||
neverIgnoreVerificationError = false, |
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 neverIgnore
naming here seems a little confusing with the kind of double negative in place. Could this be a "positive" condition defaulting to true instead to make this more clear? Maybe like surfaceVerificationErrors
or forceVerificationErrors
or something along those lines?
I understand the idea here is something like
force
by itself will suppress verification errors and allow installing outdated package versionforce
with an additional flag should still allow for installing any package version, but should still surface verification errors
x-pack/plugins/fleet/public/components/unverified_package_modal.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/public/components/unverified_package_modal.tsx
Outdated
Show resolved
Hide resolved
346f889
to
221b82d
Compare
x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx
Outdated
Show resolved
Hide resolved
@@ -159,13 +186,14 @@ function usePackageInstall({ | |||
} | |||
} | |||
}, | |||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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 only gnarly bit about the new code layout is that there is a cyclic dependency between optionallyForceInstall
and installPackage
, but omitting from the deps array works
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.
@hop-dev what about putting optionallyForceInstall
the installPackage
function body, as I saw this is just here to make the code more readable right?
…l.tsx Co-authored-by: Brandon Morelli <[email protected]>
…l.tsx Co-authored-by: Brandon Morelli <[email protected]>
221b82d
to
f56b3dd
Compare
const { error } = await savePackagePolicy({ newPackagePolicy: packagePolicy, force }); | ||
if (error) { | ||
if (isVerificationError(error)) { | ||
setFormState('CONFIRM_FAILED_VERIFICATION'); |
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.
There is no way to use the useConfirmForceInstall hook in this case too?
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.
Yeah just had a go and it works 👍
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.
Things LGTM overall with the code. A few nitpicks here and there, and +1 to @nchaulet 's comments but otherwise 🚀
...olicy/create_package_policy_page/multi_page_layout/components/page_steps/add_integration.tsx
Outdated
Show resolved
Hide resolved
...ications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/index.tsx
Show resolved
Hide resolved
}; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & PackageInstallItem; | ||
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & | ||
PackageInstallItem & { error?: FleetErrorResponse }; | ||
|
||
function usePackageInstall({ |
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.
Seems like this went mostly well. Any gotchas we should be aware of here?
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 addressing my comments 🚀
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @hop-dev |
Summary
Part of #133822
When installing a package which fails package verification, allow the user to opt to force install the package.
force_install_demo.mov
Changes
- install package assets
- create package policy
- create first package policy (cloud only) a.k.a ne multi page layout
Known issues
Screenshots
Install assets
Expand for screenshot
Create package policy
Expand for screenshot
Create first package policy (cloud only)
Expand for screenshot
Test steps
TBD - will add later this evening
Checklist
Delete any items that are not applicable to this PR.