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-8279] - Conditionally disable regions based on the selected image #10607

Conversation

bnussman-akamai
Copy link
Member

@bnussman-akamai bnussman-akamai commented Jun 24, 2024

Description 📝

  • This is for Image Service Gen2 💾
  • Same changes were made to both Linode Create v1 and v2 flows in this PR
  • On the Linode Create flow, certain regions will be disabled depending on the Image's capabilities 🌐
    • Images with the distributed capability can be deployed to both distributed and core sites
    • Images without the distributed capability can only be deployed to core sites
  • The Region value should be cleared automatically if the user changes the Image and the currently selected region is not compatible
  • Note that this behavior is somewhat temporary. Once all customers images are migrated to image service gen2, all images will be edge and core compatible, allowing us to remove this code 🗒️

Preview 📷

Screenshot 2024-06-24 at 2 38 00 PM

How to test 🧪

Prerequisites

  • Turn the MSW on

Verification steps

Warning

Test with both Linode Create and Linode Create v2

  • Verify that when a distributed compatible image is selected any region can be selected
  • Verify that when a non-distributed capable image is selected, only core regions can be selected
  • Verify that if the user changes the Image, the region field is cleared if there is an incompatibility

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

@bnussman-akamai bnussman-akamai self-assigned this Jun 24, 2024
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner June 24, 2024 15:22
@bnussman-akamai bnussman-akamai requested review from mjac0bs and abailly-akamai and removed request for a team June 24, 2024 15:22
@bnussman-akamai bnussman-akamai force-pushed the M3-8279-conditionally-disable-regions-based-on-the-selected-image branch from b49b73d to 0aeb0bd Compare June 24, 2024 15:24
@bnussman-akamai bnussman-akamai force-pushed the M3-8279-conditionally-disable-regions-based-on-the-selected-image branch from 0aeb0bd to 68bfd23 Compare June 24, 2024 15:28
Copy link

github-actions bot commented Jun 24, 2024

Coverage Report:
Base Coverage: 82.39%
Current Coverage: 82.43%

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Verified all functionality in create v1 and v2:

✅ Edge sites are disabled when selecting a core image
✅ Edge sites are enabled when selecting a distributed image
✅ Switching from a distributed image to a core image clears regions field if a core region is selected

Approved pending some minor feedback and one failing unit test. (CI test failures appear to be flake).

Comment on lines +36 to +37
selection: string | undefined,
image: Image | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

selection is just the image label right? If so, can we just provide the image?

Copy link
Member Author

@bnussman-akamai bnussman-akamai Jun 24, 2024

Choose a reason for hiding this comment

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

Selection is the image id.

I chose to just pass the whole image as the second parameter to minimize having to touch tons of other files.

ImageSelect should be removed soon in favor of ImageSelect2, which addresses this, so I think this is okay for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep in mind that <ImageSelect /> won't be deprecated by switching over to the Linode Create v2 flow alone (it's also used in Rebuild flows) so we may live with this for a while. We should at least have a code comment about this here and below for the non-null assertion

Comment on lines +114 to +117
const supportedDistributedRegionTypes = [
'Distributions',
'StackScripts',
'Images',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a top-level constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will let @hana-linode handle that with Gecko

selectedImageID:
this.params.imageID ?? this.params.type !== 'Images'
? DEFAULT_IMAGE
: undefined,
// @todo: Abstract and test. UPDATE 5/21/20: lol what does this mean. UPDATE 3/16/23 lol what
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't wait to switch to create v2 so we can finally remove this comment 😆

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.

Logic looks good and confirmed the region select is behaving properly according to the image selection ✅

Comment on lines +36 to +37
selection: string | undefined,
image: Image | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep in mind that <ImageSelect /> won't be deprecated by switching over to the Linode Create v2 flow alone (it's also used in Rebuild flows) so we may live with this for a while. We should at least have a code comment about this here and below for the non-null assertion

return disabledRegions;
},
{}
);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am starting to get worried about seeing a lot of of various logic bits for checking against distributed regions. Not something this PR should necessarily address but it would be nice to start seeing those checks in utils and unit tested in isolation (glad to see it's still tested below! tho there seems to be a failure). This same duplicated is Region.tsx which I assume is intentional?

CC @hana-linode

if (
image &&
!image.capabilities.includes('distributed-images') &&
selectedRegion?.site_type === 'distributed'
Copy link
Contributor

Choose a reason for hiding this comment

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

similar comment here - tho this one isn't unit tested

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Ready for Review labels Jun 25, 2024
Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

🚢 I just pulled latest and confirmed:

Create Flow v1:

  • When a distributed compatible image is selected any region can be selected
  • When a non-distributed capable image is selected, only core regions can be selected
  • If the user changes the Image, the region field is cleared if there is an incompatibility

Create Flow v2:

  • When a distributed compatible image is selected any region can be selected
  • When a non-distributed capable image is selected, only core regions can be selected
  • If the user changes the Image, the region field is cleared if there is an incompatibility

@bnussman-akamai bnussman-akamai merged commit 449c20f into linode:develop Jun 25, 2024
18 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! Image Service Gen2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants