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

change: [M3-7802] - Remove API caching #10219

Merged

Conversation

bnussman-akamai
Copy link
Contributor

@bnussman-akamai bnussman-akamai commented Feb 22, 2024

Description πŸ“

  • Removes all API caching from Cloud Manager
  • Creates Kernel factory
  • Updates Kernel type to match what the API actually returns
  • Fixes a handful of tests that were built under the assumption that regions would always be loaded into memory

Why ❓

  • Caching large amounts of API data increases our bundle size πŸ“¦
  • The API has gotten faster πŸ’¨
  • Allows you to run yarn build without an internet connection because we no longer need to fetch from the API πŸ›œ
  • Simplifies things because there is one less moving part to worry about and maintain 🧹

What will be removed and why ℹ️

  • src/cachedData/typesLegacy.json because it was unused
  • src/cachedData/kernels.json because it was only used for unit testing (I replaced it with a factory 🏭)
  • src/cachedData/marketplace.json because the API now responds much faster (~300ms) (use to take many seconds ⏲️ )
  • src/cachedData/regions.json because it was an over-optimization, not gitignored, and was misused as mock data - see upcoming: [M3-7756] - Placement Groups limits updatesΒ #10191 (comment) (this was recently corrected by @abailly-akamai but I don't want it to happen again in the future) πŸš“

How to test πŸ§ͺ

  • Check out this PR or use the preview link
  • Verify region data still populates correctly throughout the app
  • Verify marketplace apps load in a reasonable amount of time
  • Verify Kernel related features still work (this is found in a Linode's configuration)
  • Verify that all automated checks pass

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 Feb 22, 2024
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner February 22, 2024 16:41
@bnussman-akamai bnussman-akamai requested review from cpathipa and hkhalil-akamai and removed request for a team February 22, 2024 16:41
@bnussman-akamai bnussman-akamai changed the title poc: Remove API caching change: [M3-7802] - Remove API caching Feb 22, 2024
Copy link

github-actions bot commented Feb 22, 2024

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

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.

Great! this is a nice cleanup 🧹

As a result this API update also improved the stackscripts/community tab which was still painfully slow. πŸŽ‰

Noticed no regression βœ…
Approving pending no e2e complaints βœ…

@bnussman-akamai bnussman-akamai added the Add'tl Approval Needed Waiting on another approval! label Feb 22, 2024
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.

Great clean up 🧼. Approved with one question.

Comment on lines +29 to +37
server.use(
rest.get('*/regions', (req, res, ctx) => {
const regions = regionFactory.buildList(1, {
id: 'us-central',
label: 'Fake Region, NC',
});
return res(ctx.json(makeResourcePage(regions)));
})
);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if I fully understand why these mocks had to be added. Is the mock from serverHandlers.ts incorrect (I believe it comes from regionsData)? If so, should they be changed/removed from that file?

Copy link
Contributor

Choose a reason for hiding this comment

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

The mocks in serverHandlers.ts are the default, but in my opinion, it's best practice to explicitly define any API data that the component depends on in the test itself. This way the unit test will always pass, even if we make changes in serverHandlers.ts , which is something we do frequently.

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Feb 23, 2024
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.

Thank you for the cleanup @bnussman
Verified and no regression found.

@bnussman-akamai bnussman-akamai merged commit cbd2e1a into linode:develop Feb 23, 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! Clean Up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants