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

feat: [M3-6731] – Add VPC and Firewall sections in Linode Create flow #9635

Conversation

dwiley-akamai
Copy link
Contributor

@dwiley-akamai dwiley-akamai commented Sep 5, 2023

Description πŸ“

  • Add VPC section in Linode Create flow
  • Add Firewall section in Linode Create flow

Major Changes πŸ”„

  • VPCs added to region capabilities
  • linodeInterfaceSchema for individual interfaces, linodeInterfacesSchema for the actual interfaces property in Linode Create payload
  • refetchOnWindowFocus added to useVPCsQuery
  • New VPCPanel & SelectFirewallPanel components that are present in Linode Create flow
    • New linodeCreateWithFirewall feature flag that determines whether SelectFirewallPanel is displayed or not in Linode Create flow
  • Conditional copy for "Private IP" in "Add-ons" panel in Linode Create flow

Preview πŸ“·

VPC and Firewall panels

Screenshot 2023-09-21 at 2 10 29 PM

"Private IP" conditional copy

Screenshot 2023-09-21 at 2 11 36 PM

"VPC Assigned" in summary paper

Screenshot 2023-09-21 at 2 23 18 PM

How to test πŸ§ͺ

With a properly-tagged account or with the VPC feature flag on,

  1. Confirm the presence of the VPC & Firewall panels in the Linode Create flow
  2. For the VPC panel:
    a) Nothing below the "Create VPC" link shows when the VPC dropdown is set to "None"
    b) the VPC dropdown options are only those from the same region as the region selected for the Linode
    c) the Subnet dropdown options are only those subnets belonging to the selected VPC
    d) the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox is checked by default
    e) unchecking the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox reveals a "VPC IPv4" text field which must be filled out (attempting to create the linode without this should yield a field error)
    f) expectations for the payload based on the checkboxes: a checked "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox should result in ipv4.vpc not being present in the payload, while an unchecked one should result in the contents of the "VPC IPv4" text field populating ipv4.vpc in the payload; a checked "Assign a public IPv4 address for this Linode" should result in ipv4.nat_1_1 being set to any, while an unchecked one should result in ipv4.nat_1_1 not being present in the payload the original tab: the VPC dropdown should have your newly-created VPC included
    g) Clicking the "Create VPC" link and completing that flow in the new tab, then returning to the Linode Create flow in
  3. For the Firewall panel:
    a) Your firewalls should be listed as options
    b) You can add linodeCreateWithFirewall: false somewhere between L30-L33 in withFeatureFlagConsumer.container.ts to confirm the Firewall panel is not visible without the feature flag being on
  4. The Summary paper at the bottom should say "VPC Assigned" if you've assigned a VPC
  5. Creating a non-VPC, non-firewalled linode with and without a VLAN
  6. Creating a linode with both a VPC and a VLAN

With a non-tagged account & the VPC feature flag off, confirm (1) above is not present, and confirm normal Linode creation functionality works as expected.

@dwiley-akamai dwiley-akamai added Work in Progress @linode/api-v4 Changes are made to the @linode/api-v4 package @linode/validation Changes are made to the @linode/validation package VPC Relating to VPC project labels Sep 5, 2023
@dwiley-akamai dwiley-akamai self-assigned this Sep 5, 2023
@dwiley-akamai dwiley-akamai marked this pull request as draft September 5, 2023 22:08
…b and the VPC dropdown list in the Linode Create flow refreshes upon successful VPC creation (given the newly-created VPC is in the same region as the to-be created Linode)
options={firewallsDropdownOptions}
placeholder={''}
/>
<StyledCreateLink to={`${APP_ROOT}/firewalls/create`}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

APP_ROOT is used to ensure the link opens up in a new tab (can't be done with a relative path without adding the external prop which would be misleading)

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 could've sworn we had this file already, but perhaps it got deleted sometime in the past year. This allows us to pull in account data in class components.

WithAccountProps &
WithDisplayData &
WithLinodesProps &
WithTypesProps;
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 alphabetically sorted and added WithAccountProps

const payload = {
authorized_users: this.props.authorized_users,
backup_id: this.props.selectedBackupID,
backups_enabled: this.props.backupsEnabled,
booted: true,
firewall_id:
this.props.firewallId !== -1 ? this.props.firewallId : undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check prevents the firewall_id from being shown in the "Create Using Command Line" modal if a firewall isn't selected.

const vpcInterfaceData: InterfacePayload = {
ipam_address: null,
ipv4: {
nat_1_1: this.props.assignPublicIPv4Address ? 'any' : undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the "Assign a public IPv4 address for this Linode" checkbox is checked, send any in the payload (otherwise, send nothing).

nat_1_1: this.props.assignPublicIPv4Address ? 'any' : undefined,
vpc: this.props.autoassignIPv4WithinVPC
? undefined
: this.props.vpcIPv4AddressOfLinode,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox is checked, send nothing – otherwise, send the contents of the "VPC IPv4" input field.


interfaces.push(vpcInterfaceData);
}

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 VLAN logic below had to be reworked to account for VPC's impact on the interfaces property of the payload.

Essentially:

  1. Define interfaces earlier in the file as any empty array
  2. If there's VPC data, push it to interfaces
  3. If there's VLAN data, push it to interfaces
  4. If there's VLAN data but no VPC data, also add a default public interface in interfaces[0] (maintains parity with previous logic)

attachedVLANLabel: '',
authorized_users: [],
autoassignIPv4WithinVPCEnabled: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default, the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox should be checked.

{
enabled,
keepPreviousData: true,
refetchOnWindowFocus: alwaysRefetch ? 'always' : 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.

This allows for users to click the "Create VPC" link, complete that flow in the newly-opened tab, and come back to the Linode Create flow and have a refreshed VPC dropdown that includes the newly-created VPC.

purpose: mixed().oneOf(
['public', 'vlan', 'vpc'],
'Purpose must be public, vlan, or vpc.'
export const linodeInterfaceSchema = object().shape({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously the interfaces property would be either a public interface + a VLAN, or omitted from the payload. Now an interface can be a VPC as well, so I've separated out individual interface validation and defined linodeInterfacesSchema as an array of these.

@dwiley-akamai
Copy link
Contributor Author

Going ahead and opening this up for review but I will still be working on adding unit tests between now and tomorrow

@dwiley-akamai dwiley-akamai marked this pull request as ready for review September 21, 2023 18:29
@dwiley-akamai dwiley-akamai requested a review from a team as a code owner September 21, 2023 18:29
@dwiley-akamai dwiley-akamai requested review from jaalah-akamai and removed request for a team September 21, 2023 18:29
@dwiley-akamai
Copy link
Contributor Author

We should send focus back to the fields that error. For example:

unchecking the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox reveals a "VPC IPv4" text field which must be filled out (attempting to create the linode without this should yield a field error)

We need to scroll back up the page to know something failed.

I do have the scrollErrorIntoView(); in there for the VPC validation errors (Validation for VPC fields section in LinodeCreateContainer.tsx), but that function seems to be hit-or-miss -- field errors for the "Root Password" field aren't scrolled to either. Will investigate it a bit more.

@coliu-akamai
Copy link
Contributor

coliu-akamai commented Sep 26, 2023

Will also be checking these off as I get to them

  • Confirm the presence of the VPC & Firewall panels in the Linode Create flow
  • For the VPC panel:
    • Nothing below the "Create VPC" link shows when the VPC dropdown is set to "None"
    • the VPC dropdown options are only those from the same region as the region selected for the Linode
    • the Subnet dropdown options are only those subnets belonging to the selected VPC
    • the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox is checked by default
    • unchecking the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox reveals a "VPC IPv4" text field which must be filled out (attempting to create the linode without this should yield a field error)
    • expectations for the payload based on the checkboxes: a checked "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox should result in ipv4.vpc not being present in the payload, while an unchecked one should result in the contents of the "VPC IPv4" text field populating ipv4.vpc in the payload; a checked "Assign a public IPv4 address for this Linode" should result in ipv4.nat_1_1 being set to any, while an unchecked one should result in ipv4.nat_1_1 not being present in the payload the original tab: the VPC dropdown should have your newly-created VPC included
    • Clicking the "Create VPC" link and completing that flow in the new tab, then returning to the Linode Create flow in
  • For the Firewall panel:
    • Your firewalls should be listed as options
  • The Summary paper at the bottom should say "VPC Assigned" if you've assigned a VPC
  • Creating a non-VPC, non-firewalled linode with and without a VLAN
  • Creating a linode with both a VPC and a VLAN
  • With a non-tagged account & the VPC feature flag off, confirm (1) above is not present, and confirm normal Linode creation functionality works as expected.Confirm the presence of the VPC & Firewall panels in the Linode Create flow

Additional checks (ty Tyler & Hana!)

  • Create firewall link brings you to the create firewall drawer
  • After creating a firewall, that firewall now appears in the list of available firewalls
  • Confirmed that after creating a Linode with an assigned VPC, the VPC details page lists the linode as one of the assigned Linodes
  • Confirmed that VPC details appear on linode page and they appear without having to reload
  • The firewall gets assigned to the Linode
  • Creating linode with vpc, vlan, and firewall
  • With a non-tagged account & the VPC feature flag off, requests to the vpc endpoint should not be made

@tyler-akamai
Copy link
Contributor

tyler-akamai commented Sep 26, 2023

Will check this off as well:

  • Confirm the presence of the VPC & Firewall panels in the Linode Create flow
  • For the VPC panel:
    • Nothing below the "Create VPC" link shows when the VPC dropdown is set to "None"
    • the VPC dropdown options are only those from the same region as the region selected for the Linode
    • the Subnet dropdown options are only those subnets belonging to the selected VPC
    • the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox is checked by default
    • unchecking the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox reveals a "VPC IPv4" text field which must be filled out (attempting to create the linode without this should yield a field error)
    • expectations for the payload based on the checkboxes: a checked "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox should result in ipv4.vpc not being present in the payload, while an unchecked one should result in the contents of the "VPC IPv4" text field populating ipv4.vpc in the payload; a checked "Assign a public IPv4 address for this Linode" should result in ipv4.nat_1_1 being set to any, while an unchecked one should result in ipv4.nat_1_1 not being present in the payload the original tab: the VPC dropdown should have your newly-created VPC included
    • Clicking the "Create VPC" link and completing that flow in the new tab, then returning to the Linode Create flow in
  • For the Firewall panel:
    • Your firewalls should be listed as options
  • The Summary paper at the bottom should say "VPC Assigned" if you've assigned a VPC
  • Creating a non-VPC, non-firewalled linode with and without a VLAN
  • Creating a linode with both a VPC and a VLAN
  • With a non-tagged account & the VPC feature flag off, confirm (1) above is not present, and confirm normal Linode creation functionality works as expected.Confirm the presence of the VPC & Firewall panels in the Linode Create flow

Additional checks:

  • Create firewall link brings you to the create firewall drawer
  • Confirmed that after creating a Linode with an assigned VPC, the VPC details page lists the linode as one of the assigned Linodes
  • The firewall gets assigned to the Linode

@tyler-akamai
Copy link
Contributor

tyler-akamai commented Sep 26, 2023

Maybe make the spacing consistent between the two boxes when you uncheck "Auto-assign a VPC IPv4 address for this Linode in the VPC"

Screenshot 2023-09-26 at 1 34 06 PM

Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

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

Firewall assignment doesn't seem to be working πŸ€”

Screen.Recording.2023-09-26.at.1.32.51.PM.mov

@tyler-akamai
Copy link
Contributor

In the summary paper, should we also include if we assigned any firewalls like how we do it for VPCs and VLANs?

however, I can see the paper easily getting crowded and hard to quickly read.
ex.
Debian 11 | Newark, NJ, USA | VLAN Attached | VPC Assigned | Firewall Assigned

@dwiley-akamai
Copy link
Contributor Author

dwiley-akamai commented Sep 26, 2023

Firewall assignment doesn't seem to be working πŸ€”

Screen.Recording.2023-09-26.at.1.32.51.PM.mov

It's feature flagged separately (apart from VPC) on the back-end now. It's not working from the command line either so I've reached out to API about the issue

edit: the flag is off on the back-end presently
edit 2: the flag on the back-end should be on now

…y on validation for subnet error, update example IP address
…inodeCreate.tsx to retain test coverage of that aspect
Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

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

  • Confirm the presence of the VPC & Firewall panels in the Linode Create flow
  • For the VPC panel:
    • Nothing below the "Create VPC" link shows when the VPC dropdown is set to "None"
    • the VPC dropdown options are only those from the same region as the region selected for the Linode
    • the Subnet dropdown options are only those subnets belonging to the selected VPC
    • the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox is checked by default
    • unchecking the "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox reveals a "VPC IPv4" text field which must be filled out (attempting to create the linode without this should yield a field error)
    • expectations for the payload based on the checkboxes: a checked "Auto-assign a VPC IPv4 address for this Linode in the VPC" checkbox should result in ipv4.vpc not being present in the payload, while an unchecked one should result in the contents of the "VPC IPv4" text field populating ipv4.vpc in the payload; a checked "Assign a public IPv4 address for this Linode" should result in ipv4.nat_1_1 being set to any, while an unchecked one should result in ipv4.nat_1_1 not being present in the payload the original tab: the VPC dropdown should have your newly-created VPC included
    • Clicking the "Create VPC" link and completing that flow in the new tab, then returning to the Linode Create flow in
  • For the Firewall panel:
    • Your firewalls should be listed as options
  • The Summary paper at the bottom should say "VPC Assigned" if you've assigned a VPC
  • Creating a non-VPC, non-firewalled linode with and without a VLAN
  • Creating a linode with both a VPC and a VLAN
  • With a non-tagged account & the VPC feature flag off, confirm (1) above is not present, and confirm normal Linode creation functionality works as expected.

Additional checks:

  • Create firewall link brings you to the create firewall drawer
  • Confirmed that after creating a Linode with an assigned VPC, the VPC details page lists the linode as one of the assigned Linodes
  • The firewall gets assigned to the Linode
  • With a non-tagged account & the VPC feature flag off, requests to the vpc endpoint should not be made
    image

It would be nice if the errors scrolled

…rors; ensure VPC details in LinodeEntityDetail show upupon Linode creation for linodes assigned to a VPC
@coliu-akamai
Copy link
Contributor

coliu-akamai commented Sep 28, 2023

will be going through the functionality again (using my old comment to check things off)
edit: having dev issues so unable to fully test right now, will be back!

Copy link
Contributor

@hana-akamai hana-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 work! πŸš€

@hana-akamai hana-akamai added the Add'tl Approval Needed Waiting on another approval! label Sep 28, 2023
Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

Functionality looks good, awesome work!! πŸŽ‰

@coliu-akamai coliu-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Sep 28, 2023
@dwiley-akamai dwiley-akamai merged commit d642c62 into linode:develop Sep 28, 2023
11 checks passed
@dwiley-akamai dwiley-akamai deleted the M3-6731-vpc-firewall-sections-linode-create branch September 28, 2023 18:20
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! @linode/api-v4 Changes are made to the @linode/api-v4 package @linode/validation Changes are made to the @linode/validation package VPC Relating to VPC project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants