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] Modal to allow user to force install an unverified package #136108

Merged
merged 34 commits into from
Jul 21, 2022

Conversation

hop-dev
Copy link
Contributor

@hop-dev hop-dev commented Jul 11, 2022

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

  • create new force install modal (needs design review from @bmorelli25)
  • add force install modal to the following package install locations:
    - install package assets
    - create package policy
    - create first package policy (cloud only) a.k.a ne multi page layout
  • when creating a package policy, ensure the package is installed first instead of in tandem with getting the info (this makes the verification logic a lot clearer, as opposed to having a race where the getPackageInfo call also tries to verify the package)

Known issues

  • If the user does not have the system integration installed, and the system integration fails verification, if they go to create an agent policy for the first time and enable system monitoring, the system integration would be installed without warning.

Screenshots

Install assets

Expand for screenshot Screenshot 2022-07-12 at 17 28 09

Create package policy

Expand for screenshot Screenshot 2022-07-12 at 17 28 32

Create first package policy (cloud only)

Expand for screenshot Screenshot 2022-07-12 at 17 30 48

Test steps

TBD - will add later this evening

Checklist

Delete any items that are not applicable to this PR.

@hop-dev hop-dev force-pushed the 133822-package-verification-modal branch 2 times, most recently from bd3d885 to c73ea10 Compare July 12, 2022 16:09
@hop-dev hop-dev requested a review from bmorelli25 July 12, 2022 16:35
@hop-dev hop-dev marked this pull request as ready for review July 12, 2022 16:35
@hop-dev hop-dev requested a review from a team as a code owner July 12, 2022 16:35
@hop-dev hop-dev self-assigned this Jul 12, 2022
@hop-dev hop-dev added Team:Fleet Team label for Observability Data Collection Fleet team release_note:feature Makes this part of the condensed release notes v8.4.0 labels Jul 12, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@@ -259,6 +270,7 @@ async function installPackageFromRegistry({
spaceId,
force = false,
ignoreConstraints = false,
neverIgnoreVerificationError = false,
Copy link
Contributor Author

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

Copy link
Member

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 version
  • force 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 };
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@hop-dev hop-dev changed the title [Fleet] Display confirm modal when package fails verification [Fleet] Modal to allow user to force install an unverified package Jul 12, 2022
@nchaulet nchaulet self-requested a review July 12, 2022 18:35
@@ -33,7 +33,7 @@ export interface GetOnePackagePolicyResponse {
}

export interface CreatePackagePolicyRequest {
body: NewPackagePolicy;
body: NewPackagePolicy & { force?: boolean };
Copy link
Contributor Author

@hop-dev hop-dev Jul 13, 2022

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({
Copy link
Member

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?

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'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.

Copy link
Member

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

Copy link
Contributor Author

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 👍

Copy link
Member

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?

};
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & PackageInstallItem;
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> &
PackageInstallItem & { error?: FleetErrorResponse };

function usePackageInstall({
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'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,
Copy link
Member

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 version
  • force with an additional flag should still allow for installing any package version, but should still surface verification errors

@hop-dev hop-dev force-pushed the 133822-package-verification-modal branch from 346f889 to 221b82d Compare July 14, 2022 13:37
@@ -159,13 +186,14 @@ function usePackageInstall({
}
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor Author

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

Copy link
Member

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?

@hop-dev hop-dev force-pushed the 133822-package-verification-modal branch from 221b82d to f56b3dd Compare July 20, 2022 14:39
@kpollich kpollich self-requested a review July 20, 2022 15:12
@nchaulet nchaulet self-requested a review July 20, 2022 15:18
const { error } = await savePackagePolicy({ newPackagePolicy: packagePolicy, force });
if (error) {
if (isVerificationError(error)) {
setFormState('CONFIRM_FAILED_VERIFICATION');
Copy link
Member

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?

Copy link
Contributor Author

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 👍

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.

Things LGTM overall with the code. A few nitpicks here and there, and +1 to @nchaulet 's comments but otherwise 🚀

};
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> & PackageInstallItem;
type SetPackageInstallStatusProps = Pick<PackageInfo, 'name'> &
PackageInstallItem & { error?: FleetErrorResponse };

function usePackageInstall({
Copy link
Member

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?

@hop-dev
Copy link
Contributor Author

hop-dev commented Jul 20, 2022

@kpollich @nchaulet I've moved to using the hook for the add integration pages in b7c998d its a lot neater 👍

@hop-dev hop-dev requested a review from nchaulet July 20, 2022 20:23
Copy link
Member

@nchaulet nchaulet left a 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 🚀

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 747 749 +2

Async chunks

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

id before after diff
fleet 864.6KB 867.4KB +2.8KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 113.3KB 113.5KB +215.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
fleet 51 52 +1

Total ESLint disabled count

id before after diff
fleet 59 60 +1

History

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

cc @hop-dev

@hop-dev hop-dev merged commit 184f807 into elastic:main Jul 21, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 21, 2022
@hop-dev hop-dev deleted the 133822-package-verification-modal branch July 21, 2022 08:15
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:feature Makes this part of the condensed release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants