Skip to content

feat: [M3-7063] - Provide dynamic price error handling for DC-specific pricing#9660

Merged
mjac0bs merged 61 commits intolinode:developfrom
cpathipa:M3-7063
Oct 20, 2023
Merged

feat: [M3-7063] - Provide dynamic price error handling for DC-specific pricing#9660
mjac0bs merged 61 commits intolinode:developfrom
cpathipa:M3-7063

Conversation

@cpathipa
Copy link
Contributor

@cpathipa cpathipa commented Sep 11, 2023

Description 📝

  • Handles pricing error scenario
  • Renders Errored state TableCell for price column
  • Enhanced TableCell component to handle errored state cell data

Preview 📷

Add a Node Pool Drawer Resize Pool
image image
Add Node Pools Migrate Linode
image image
Linodes Plan panel Resize Linode
image image

Enable Backups Modal

image

How to test 🧪

  1. To test this locally, we need to tweak the mock API response or modify the code accordingly for scenarios where regionId | type | price are not available. (Refer to the ticket for context.)
  2. Validate all the components that render dynamic pricing, pricing column in plan selection table's (example: getDCSpecificPrice).
  3. More specifically:

Here is a list of DC-specific pricing PRs. When testing this PR, first ensure that there are no regressions from prod in pricing behavior matches prod in all cases where there are NOT errors. (PRs that were copy changes, not price calculations, are already checked off.)
Then verify the error handling in the screenshots above is triggered when prices cannot be calculated correctly:

  • Introduce dynamic pricing utils and constants (#9564)
  • Add DC Specific Pricing Notices and Docs Links (#9572)
  • Update DC Specific Pricing Notices (#9690)
  • Add DC-specific pricing to Invoices (#9597)
  • Add Region label to DC-specific pricing invoices (#9663)
  • Standardize "region" and "data center" copy for DC-specific pricing (#9670)
  • Add DC-specific pricing to Linode Create (#9598)
    • In serverHandlers.ts, modify nanodeTypes to include a region_prices object with monthly and hourly prices of null.
    • Observe that placeholder for unknown prices ($--.--) displays in the table.
  • Add DC dynamic pricing information for Linode migration flow (#9570)
    • Block network requests to https://api.linode.com/v4/linode/types/g6-standard-1.
    • Make a new region selection in the Migrate modal.
    • Observe the error.
  • Add DC-specific pricing to Kubernetes node pools (#9606)
  • Add DC-specific transfer pools and linode usage displays (#9620)
  • Update Monthly Network Transfer Pool dialog copy and typography (#9692)
  • Add DC Specific Pricing to NodeBalancer Create (#9566)
  • Add DC-specific pricing to Kubernetes HA (#9568)
  • Add DC-specific pricing to Linode backups (#9588)
  • Added DC specific pricing to Volumes create flows (#9569)
  1. Verify e2e tests.

@cpathipa cpathipa self-assigned this Sep 11, 2023
@cpathipa cpathipa marked this pull request as draft September 11, 2023 16:26
@cpathipa cpathipa marked this pull request as ready for review September 12, 2023 17:03
@mjac0bs mjac0bs self-requested a review September 12, 2023 18:20
@mjac0bs mjac0bs added DC-Specific Pricing UX/UI Changes for UI/UX to review labels Sep 12, 2023
@cpathipa cpathipa requested a review from a team as a code owner September 19, 2023 18:14
@cpathipa cpathipa requested review from cliu-akamai and jaalah-akamai and removed request for a team September 19, 2023 18:14
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.

For others who may be looking at this PR: there is an associated UX ticket (UX-427) discussion and we're going to incorporate those changes here.

That should result in some clean up in components like Currency and DisplayPrice, so the price doesn't have to accept a string. And in dynamicPricing.ts, we'd return undefined instead of unknown.

In places where we have display text with "unknown", (e.g. the resize pool component), we can display an error message like below, rather than rendering something like Resized pool: $unknown/month.
image

For table cells with pricing data, where we'd fall back on unknown if there was an error, we will instead display $--.-- with an tooltip error icon. This could be a new ErrorCell component that accepts the error text and tooltip text as props.

(Formatting subject to change so wrapping issue would be fixed.)
Screenshot 2023-09-20 at 7 24 36 AM

@cpathipa cpathipa marked this pull request as draft September 21, 2023 14:28
@jdamore-linode
Copy link
Contributor

Because the functions are now checking if type exists and returning undefined if not, I had to add a type id to the mock DC pricing linode types.

Ah, nice catch @mjac0bs! I'll circle back and take another look soon

I also updated the total. I don't understand how we were passing that test with $7.74 before... the sum of those three values is $9.74. 😅

Haha I noticed that too -- I'm guessing I added it up before adding the $2.00 entry to the list... or maybe I'm just bad at basic math 😅

@jdamore-linode
Copy link
Contributor

(@mjac0bs Should've mentioned above, but all of the failures can be disregarded!)

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.

Thanks for all your work on this!

It's hard to test every scenario but I could confirm most of them except for volumes create but I think it's because I was using null values for monthly & hourly VS an undefined data set.

@cpathipa cpathipa added the Add'tl Approval Needed Waiting on another approval! label Oct 17, 2023
@cpathipa cpathipa requested a review from mjac0bs October 19, 2023 13:53
@coliu-akamai
Copy link
Contributor

coliu-akamai commented Oct 19, 2023

Gonna check these off as I go through them:

  • Introduce dynamic pricing utils and constants (#9564)
  • Add DC Specific Pricing Notices and Docs Links (#9572)
  • Update DC Specific Pricing Notices (#9690)
  • Add DC-specific pricing to Invoices (#9597)
  • Add Region label to DC-specific pricing invoices (#9663)
  • Standardize "region" and "data center" copy for DC-specific pricing (#9670)
  • Add DC-specific pricing to Linode Create (#9598)
    • In serverHandlers.ts, modify nanodeTypes to include a region_prices object with monthly and hourly prices of null.
    • Observe that placeholder for unknown prices ($--.--) displays in the table.
  • Add DC dynamic pricing information for Linode migration flow (#9570)
    • Block network requests to https://api.linode.com/v4/linode/types/g6-standard-1.
    • Make a new region selection in the Migrate modal.
    • Observe the error.
  • Add DC-specific pricing to Kubernetes node pools (#9606)
  • Add DC-specific transfer pools and linode usage displays (#9620)
  • Update Monthly Network Transfer Pool dialog copy and typography (#9692)
  • Add DC Specific Pricing to NodeBalancer Create (#9566)
  • Add DC-specific pricing to Kubernetes HA (#9568)
  • Add DC-specific pricing to Linode backups (#9588)
  • Added DC specific pricing to Volumes create flows (#9569)

Comment on lines +421 to +425
summaryItems.unshift({
title: `$${
renderMonthlyPriceToCorrectDecimalPlace(Number(price)) ?? UNKNOWN_PRICE
}/month`,
});
Copy link
Member

Choose a reason for hiding this comment

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

I understand the intention here, but I'm not a fan of the extra complexity. Because the NodeBalancer price is hard-coded I don't see why we'd have to handle an unknown price.

Also, I'm not sure if the fallback logic makes sense here.

Suggested change
summaryItems.unshift({
title: `$${
renderMonthlyPriceToCorrectDecimalPlace(Number(price)) ?? UNKNOWN_PRICE
}/month`,
});
summaryItems.unshift({
title: `$${
renderMonthlyPriceToCorrectDecimalPlace(Number(price))
}/month`,
});

Also, it looks like renderMonthlyPriceToCorrectDecimalPlace won't properly handle a service that is $0. (not that we're going to many free products)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, you're right that we really wouldn't end up needing to handle displaying an unknown price in this case because although price can be undefined, we're only displaying price in the summary once there is a valid region.
(And other than that, the fallback logic was just unnecessary there with the render function, and I probably just wasn't paying attention when doing some clean up, and missed it.)

As for:

looks like renderMonthlyPriceToCorrectDecimalPlace won't properly handle a service that is $0. (not that we're going to many free products)

In this case and in any other instances where we're using this in Cloud, I wouldn't expect these products to be free. Unless there's a likely situation that we'd encounter that, I think it's safer to leave as is so we don't risk inaccurately advertising free products.

@coliu-akamai
Copy link
Contributor

Awesome work! Tested the functionality, had the following questions:

  • couldn't get the region column in the Invoice label to show up -- thinking this might be because of the magic date constant thing though, as I can see the code for the region column is there
  • For Kubernetes node pool, just wanted to confirm that there shouldn't be any error icons (could also be an issue with my MSW which has happened before 😅 ) ? I see this after changing nanodeType in serverHandlers.ts (line 470) to include region_prices object with null monthly/hourly prices, and modifying the kubernetesAPIResponse and kubernetesClusterFactory factories and replaces region: 'us-central' with region: 'id-cgk'.
    • Alternatively, are there additional steps I should follow?
      image

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.

Didn't find any regressions on any of the flows I checked!

@jaalah-akamai
Copy link
Contributor

jaalah-akamai commented Oct 19, 2023

  • Introduce dynamic pricing utils and constants (#9564)
  • Add DC Specific Pricing Notices and Docs Links (#9572)
  • Update DC Specific Pricing Notices (#9690)
  • Add DC-specific pricing to Invoices (#9597)
  • Add Region label to DC-specific pricing invoices (#9663)
  • Standardize "region" and "data center" copy for DC-specific pricing (#9670)
  • Add DC-specific pricing to Linode Create (#9598)
    • In serverHandlers.ts, modify nanodeTypes to include a region_prices object with monthly and hourly prices of null.
    • Observe that placeholder for unknown prices ($--.--) displays in the table.
  • Add DC dynamic pricing information for Linode migration flow (#9570)
    • Block network requests to https://api.linode.com/v4/linode/types/g6-standard-1.
    • Make a new region selection in the Migrate modal.
    • Observe the error.
  • Add DC-specific pricing to Kubernetes node pools (#9606)
  • Add DC-specific transfer pools and linode usage displays (#9620)
  • Update Monthly Network Transfer Pool dialog copy and typography (#9692)
  • Add DC Specific Pricing to NodeBalancer Create (#9566)
  • Add DC-specific pricing to Kubernetes HA (#9568)
  • Add DC-specific pricing to Linode backups (#9588)
  • Added DC specific pricing to Volumes create flows (#9569)

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Oct 19, 2023
@mjac0bs
Copy link
Contributor

mjac0bs commented Oct 19, 2023

  • For Kubernetes node pool, just wanted to confirm that there shouldn't be any error icons (could also be an issue with my MSW which has happened before 😅 ) ? I see this after changing nanodeType in serverHandlers.ts (line 470) to include region_prices object with null monthly/hourly prices, and modifying the kubernetesAPIResponse and kubernetesClusterFactory factories and replaces region: 'us-central' with region: 'id-cgk'.

@coliu-akamai Thanks for raising this and including your repro steps -- super helpful and I appreciate it! You were right; this was missed, because I forgot that the Kube plan table is a separate component. It has been fixed now. I've also disabled the add button if a row has a pricing error (not visible in this screenshot; made that change afterwards).

Using the same mock/factory edits quoted above, just returning null for hourly:
Screenshot 2023-10-19 at 1 17 22 PM

Modifying price to return undefined in code:
Screenshot 2023-10-19 at 1 19 46 PM

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.

My review doesn't really count here, but @cpathipa - all feedback has been addressed and this should be good to merge once the e2es finish.

@coliu-akamai
Copy link
Contributor

@mjac0bs awesome thanks! One other quick thing, the add button for the Shared CPU row on the Create Kubernetes flow doesn't get disabled (errors showing up now though! 🎉):
(To reproduce, same setup as above + then on the /kubernetes/create page, choose Jakarta)

image
image

@mjac0bs
Copy link
Contributor

mjac0bs commented Oct 20, 2023

One other quick thing, the add button for the Shared CPU row on the Create Kubernetes flow doesn't get disabled (errors showing up now though! 🎉)

@coliu-akamai - Thanks, fixed now in 4646b77. Also made a minor change to only disable + and Add buttons if the monthly price is not available, since that's what we use to calculate the totals in our drawers and create flow.

@mjac0bs
Copy link
Contributor

mjac0bs commented Oct 20, 2023

The last e2e run failed for unrelated reasons: a database-create spec and a pipeline error (one that prevents the entire runner from executing tests). I ran lke-update.spec.ts, lke-create.spec.ts, and smoke-create-nodebal.spec.ts locally, since those are the flows where changes have occurred since all (non-DB tests) ran and passed. Local tests passed. I'm going to merge. (cc @cpathipa)

@mjac0bs mjac0bs merged commit 0fb7b36 into linode:develop Oct 20, 2023
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! DC-Specific Pricing UX/UI Changes for UI/UX to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants