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

upcoming: [M3-8465] – Add "Volume Encryption" section to "Create and Attach Volume" drawer #10837

Conversation

dwiley-akamai
Copy link
Contributor

@dwiley-akamai dwiley-akamai commented Aug 26, 2024

Description πŸ“

Add "Volume Encryption" section to "Create and Attach Volume" drawer

Changes πŸ”„

  • Add useVolumeQuery
    • (tangential refactor for useDetachVolumeMutation to accommodate invalidation of useVolumeQuery)
  • VolumeSelect refactor to use our custom Autocomplete component rather than MUI's directly
  • Conditionally-displayed reboot notice in LinodeVolumeAddDrawer
    • E2E test coverage for this
  • "Volume Encryption" section added in LinodeVolumeCreateForm
    • Unit test coverage for this

Target release date πŸ—“οΈ

9/16/24

Preview πŸ“·

Before After
Screenshot 2024-08-29 at 4 30 47β€―PM Screenshot 2024-08-29 at 4 31 17β€―PM
Screenshot 2024-08-29 at 4 31 45β€―PM Screenshot 2024-08-29 at 4 32 06β€―PM

How to test πŸ§ͺ

Prerequisites

Point at the dev environment with the blockstorage-encryption tag on your account. The linode you use should have a capabilities array that does not contain blockstorage_encryption. Without one or both of those, you should not observe any of the below.

Verification steps

  • "Create and Attach Volume" view
    • check the "Encrypt Volume" checkbox --> observe: reboot notice below radio buttons & caveats in notice above checkbox, disabled "Create Volume" button
  • "Attach Existing Volume" view
    • select an encrypted volume --> observe: reboot notice below radio buttons, disabled "Attach Volume" button
  • Test the volume queries that were changed in this PR

As an Author I have considered πŸ€”

  • πŸ‘€ Doing a self review
  • ❔ Our contribution guidelines
  • 🀏 Splitting feature into small PRs
  • βž• Adding a changeset
  • πŸ§ͺ Providing/Improving test coverage
  • πŸ” Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • πŸ‘£ Providing comprehensive reproduction steps
  • πŸ“‘ Providing or updating our documentation
  • πŸ•› Scheduling a pair reviewing session
  • πŸ“± Providing mobile support
  • β™Ώ Providing accessibility support

…TORAGE_CLIENT_LIBRARY_UPDATE_REQUIRED_COPY; add Volume Encryption section to LinodeVolumeCreateForm
@dwiley-akamai dwiley-akamai added the Block Storage Encryption (BSE) Relating to Block Storage (Volumes) encryption label Aug 26, 2024
@dwiley-akamai dwiley-akamai self-assigned this Aug 26, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just linter changes

@@ -19,7 +19,7 @@ export interface Linode {
id: number;
alerts: LinodeAlerts;
backups: LinodeBackups;
bs_encryption_supported?: boolean; // @TODO BSE: Remove optionality once BSE is fully rolled out
capabilities?: string[]; // @TODO BSE: Remove optionality once BSE is fully rolled out
Copy link
Contributor Author

Choose a reason for hiding this comment

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

May not be reflected in the API spec (yet), but this is how it was actually implemented. Reach out for Slack convo if needed.

ui.autocompletePopper
.findByTitle(volume.label)
.should('be.visible')
.click();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jdamore-linode It seems that everything is good up until this point, and then the assertion on L228 causes the failure. Did some console.log'ing with the Cypress test running and clientLibraryCopyVisible in LinodeVolumeAddDrawer.tsx was never getting set to true for the "Attach Existing Volume" flow. I'm not sure why that is; it definitely works using the actual UI πŸ€”

Copy link
Contributor

Choose a reason for hiding this comment

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

I see! When Cypress selects the Volume, Cloud fires off a GET request to /volumes/:id for the selected Volume. Since we're using a mock Volume, the response is 404ing so the attach form doesn't know that the Volume is encrypted.

Mocking that request fixes the issue, but surprisingly we don't have a mock util for that endpoint. You can add one to cypress/support/intercepts/volumes.ts:

/**
 * Intercepts GET request to fetch a Volume and mocks response.
 *
 * @param volume - Volume with which to mock response.
 *
 * @returns Cypress chainable.
 */
export const mockGetVolume = (volume: Volume): Cypress.Chainable<null> => {
  return cy.intercept('GET', apiMatcher(`volumes/${volume.id}`), makeResponse(volume));
};

Then you can set it up right around where you mock the other Volumes request at line ~198:

mockGetVolumes([volume]).as('getVolumes');
mockGetVolume(volume);

That caused the library update message to display for me and allowed the test to pass!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome, thanks for helping get to the bottom of that!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just linter changes aside from L187-190

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just linter changes

@dwiley-akamai dwiley-akamai marked this pull request as ready for review August 30, 2024 16:54
@dwiley-akamai dwiley-akamai requested review from a team as code owners August 30, 2024 16:54
@dwiley-akamai dwiley-akamai requested review from jdamore-linode, carrillo-erik and cpathipa and removed request for a team August 30, 2024 16:54
Copy link

github-actions bot commented Aug 30, 2024

Coverage Report: βœ…
Base Coverage: 86.4%
Current Coverage: 86.4%

Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

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

We can also add invalidations in packages/manager/src/queries/volumes/events.ts for the new query key

packages/manager/src/queries/volumes/volumes.ts Outdated Show resolved Hide resolved
packages/manager/src/queries/volumes/volumes.ts Outdated Show resolved Hide resolved
packages/manager/src/queries/volumes/volumes.ts Outdated Show resolved Hide resolved
Comment on lines 288 to 292
// Invalidate the volume
queryClient.invalidateQueries({
queryKey: volumeQueries.volume(volumeId).queryKey,
});
},
Copy link
Member

Choose a reason for hiding this comment

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

Because volume detaches take time to happen on the backend, I don't think we get any value from invalidating the Volume immediately. We can probably remove this.

The invalidation should happen when the volume detaches finishes in packages/manager/src/queries/volumes/events.ts

Copy link
Contributor Author

@dwiley-akamai dwiley-akamai Sep 6, 2024

Choose a reason for hiding this comment

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

@bnussman-akamai From my testing, I've only seen volume_detach events come through with a status of notification.

To clarify, do you think adding an invalidation for something like the event.action === 'volume_detach' && event.status === 'notification' case is sufficient in packages/manager/src/queries/volumes/events.ts, or are you proposing changes beyond that?

Copy link
Member

Choose a reason for hiding this comment

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

Adding the following to line 18ish of events.ts should cover it

    if (event.entity) {
      invalidateQueries({
        queryKey: volumeQueries.volume(event.entity.id).queryKey,
      });
    }

@carrillo-erik
Copy link
Contributor

I was able to test the user journey as described in the PR description and verified the UI updates.

The following feedback is not related to the code changes in this PR. I feel that the user should be able to reboot the Linode from within the Create Volume drawer. With this current implementation, the user is able to configure the Volume they want to Create and Attach, but after checking the box for encryption, the Create Volume button is disabled and we essentially make the customer close the drawer, reboot the Linode, and configure the Volume all over again.

Copy link
Contributor

@cpathipa cpathipa left a comment

Choose a reason for hiding this comment

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

Nice work confirming the UX changes and functionality as mentioned in the PR description.

Question - To be consistent should we show the notice "This Linode requires client libraries... " in this flow as well ? Ignore the above one I see this is included in this PR

image

@bnussman-akamai bnussman-akamai added the Approved Multiple approvals and ready to merge! label Sep 9, 2024
@dwiley-akamai dwiley-akamai merged commit 48ec392 into linode:develop Sep 9, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Block Storage Encryption (BSE) Relating to Block Storage (Volumes) encryption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants