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-8020] – Add "Disk Encryption" section to Linode Rebuild modal #10549

Conversation

dwiley-akamai
Copy link
Contributor

@dwiley-akamai dwiley-akamai commented Jun 5, 2024

Description 📝

Add "Disk Encryption" section to Linode Rebuild modal.

Note

I came across an existing edge case where it is possible that a field absent from the Rebuild dialog can still cause the Rebuild request to fail silently. See M3-8237.

Changes 🔄

  • Add isLKELinode, linodeIsInDistributedRegion, and isInRebuildFlow props to AccessPanel.tsx
  • Several props added to RebuildFromImage & RebuildFromStackScript

Target release date 🗓️

6/24

Preview 📷

Screenshots

Standard Linode in a region that supports LDE:

Screenshot 2024-06-13 at 11 50 23 AM

Linode in Distributed region:

Screenshot 2024-06-13 at 11 27 05 AM

LKE Linode:
Screenshot 2024-06-13 at 11 49 26 AM

How to test 🧪

Prerequisites

  1. Have the linode_disk_encryption tag on your account
  2. Point at the alpha/dev environment
  3. Have the Linode Disk Encryption (LDE) flag in our dev tool toggled on

Verification steps

Without the tag and/or with the LDE flag in our dev tool toggled off, you should not see any LDE-related things in the UI. Otherwise,

  • for a non-LKE linode in Newark, the "Encrypt Disk" checkbox in the Rebuild modal should be enabled and you should be able to successfully rebuild it
  • for an LKE linode, the "Encrypt Disk" checkbox in the Rebuild modal should be disabled with:
    • section description copy reading: Secure this Linode using data at rest encryption. The disk encryption setting for Linodes added to a node pool will not be changed after rebuild.
    • tooltip text reading: The Encrypt Disk setting cannot be changed for a Linode attached to a node pool.
  • for a linode in a Distributed region, the "Encrypt Disk" checkbox in the Rebuild modal should be disabled with:
    • section description copy reading: Distributed Compute Instances are secured using disk encryption.
    • tooltip text reading: The Encrypt Disk setting cannot be changed for distributed instances.

The last two cases can be easily tested by adjusting this code block as needed and turning the MSW on:

http.get('*/linode/instances/:id', async ({ params }) => {
const id = Number(params.id);
return HttpResponse.json(
linodeFactory.build({
backups: { enabled: false },
id,
label: 'Gecko Edge Test',
region: 'us-edge-1',
})
);
}),

      linodeFactory.build({
        backups: { enabled: false },
        id,
        label: 'Gecko Edge Test',
        lke_cluster_id: null, // change to a number to see the LKE Linode state
      })

Things should work when rebuilding from an image, a Community StackScript, and an Account StackScript.

Rebuilding an encrypted linode --> the "Encrypt Disk" checkbox should be checked already in the modal to reflect the current configuration

There should be no adverse effects observed if you switch to the prod environment and turn the feature flag off.

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

@dwiley-akamai dwiley-akamai added the Linode Disk Encryption (LDE) Relating to LDE project label Jun 5, 2024
@dwiley-akamai dwiley-akamai self-assigned this Jun 5, 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.

Diff generated by linter

Comment on lines +107 to +129
const determineEncryptDiskDisabledReason = ({
isLKELinode,
linodeIsInDistributedRegion,
regionSupportsDiskEncryption,
}: {
isLKELinode: boolean | undefined;
linodeIsInDistributedRegion: boolean | undefined;
regionSupportsDiskEncryption: boolean;
}) => {
if (isLKELinode) {
return ENCRYPT_DISK_DISABLED_REBUILD_LKE_REASON;
}

if (linodeIsInDistributedRegion) {
return ENCRYPT_DISK_DISABLED_REBUILD_DISTRIBUTED_REGION_REASON;
}

if (!regionSupportsDiskEncryption) {
return DISK_ENCRYPTION_UNAVAILABLE_IN_REGION_COPY;
}

return '';
};
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 preferred this over the initial commit's nested ternaries

const encryptDiskDisabledReason = isLKELinode
    ? ENCRYPT_DISK_DISABLED_REBUILD_LKE_REASON
    : linodeIsInDistributedRegion
    ? ENCRYPT_DISK_DISABLED_REBUILD_DISTRIBUTED_REGION_REASON
    : !regionSupportsDiskEncryption
    ? DISK_ENCRYPTION_UNAVAILABLE_IN_REGION_COPY
    : '';

Copy link
Contributor

Choose a reason for hiding this comment

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

much nicer indeed :D - switch statement is also a good option for readability

@dwiley-akamai dwiley-akamai marked this pull request as ready for review June 11, 2024 20:47
@dwiley-akamai dwiley-akamai requested a review from a team as a code owner June 11, 2024 20:47
@dwiley-akamai dwiley-akamai requested review from bnussman-akamai and abailly-akamai and removed request for a team June 11, 2024 20:47
Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Nice PR! well tested and documented

Was able to confirm:

  • for a non-LKE linode in Newark, the "Encrypt Disk" checkbox in the Rebuild modal should be enabled and you should be able to successfully rebuild it ✅
  • for an LKE linode, the "Encrypt Disk" checkbox in the Rebuild modal should be disabled with tooltip text reading: The Encrypt Disk setting cannot be changed for a Linode attached to a node pool. ✅
  • for a linode in a Distributed region, the "Encrypt Disk" checkbox in the Rebuild modal should be disabled with tooltip text reading: The Encrypt Disk setting cannot be changed for distributed instances. ✅

and confirmed it is also still disabled in unsupported regions (ex: London)

Comment on lines +107 to +129
const determineEncryptDiskDisabledReason = ({
isLKELinode,
linodeIsInDistributedRegion,
regionSupportsDiskEncryption,
}: {
isLKELinode: boolean | undefined;
linodeIsInDistributedRegion: boolean | undefined;
regionSupportsDiskEncryption: boolean;
}) => {
if (isLKELinode) {
return ENCRYPT_DISK_DISABLED_REBUILD_LKE_REASON;
}

if (linodeIsInDistributedRegion) {
return ENCRYPT_DISK_DISABLED_REBUILD_DISTRIBUTED_REGION_REASON;
}

if (!regionSupportsDiskEncryption) {
return DISK_ENCRYPTION_UNAVAILABLE_IN_REGION_COPY;
}

return '';
};
Copy link
Contributor

Choose a reason for hiding this comment

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

much nicer indeed :D - switch statement is also a good option for readability

@@ -51,11 +57,24 @@ export const LinodeRebuildDialog = (props: Props) => {
const unauthorized = isReadOnly;
const disabled = hostMaintenance || unauthorized;

// LDE-related checks
const isEncrypted = linode?.disk_encryption === 'enabled' ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isEncrypted = linode?.disk_encryption === 'enabled' ? true : false;
const isEncrypted = Boolean(linode?.disk_encryption === 'enabled' );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for bringing this to my attention, upon second look we should be fine with just the equality check

Copy link

github-actions bot commented Jun 12, 2024

Coverage Report:
Base Coverage: 82.76%
Current Coverage: 82.81%

@carrillo-erik
Copy link
Contributor

Good job catching this edge case. I was able to follow the Verification Steps and did not notice find any issues with functionality or the UI. Approved ✅.

@dwiley-akamai dwiley-akamai merged commit b18db95 into linode:develop Jun 14, 2024
18 checks passed
@dwiley-akamai dwiley-akamai deleted the M3-8020-disk-encryption-linode-rebuild branch June 14, 2024 14:32
nikhagra-akamai pushed a commit to nikhagra-akamai/manager that referenced this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linode Disk Encryption (LDE) Relating to LDE project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants