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

fix: [M3-7718] - Stale assigned Firewall data displaying on Linode and NodeBalancer details pages #10534

Merged

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented May 31, 2024

Description 📝

useAllFirewallDevicesQuery was not always being invalidated when modifying a Firewall.

As a result, without refreshing the page, adding/deleting rules or enabling/disabling a Firewall with assigned device(s) will not show the Firewall's most accurate status or rules on the NodeBalancer Details > Settings or Linode Details > Network tab if the query for that Firewall has already been cached because the page was previously visited.

Changes 🔄

  • Added query invalidation on submission of the Firewall Dialog for enabling and disabling a Firewall.
  • Added query invalidation on submission of updated Firewall rules.
  • Cleaned up naming of query keys for consistency (capitalization; made query key plural for nodebalancers).

Target release date 🗓️

6/10

Preview 📷

Before After
Screen.Recording.2024-05-31.at.8.42.11.AM.mov
Screen.Recording.2024-05-31.at.8.43.26.AM.mov

How to test 🧪

Prerequisites

(How to setup test environment)

  • Have/create a device (Linode and/or NodeBalancer) on your account.

Reproduction steps

(How to reproduce the issue, if applicable)

  1. Go to https://cloud.linode.com/firewalls and create a new Firewall.
  2. Attach your device to that Firewall.
  3. Click on the label of the device to navigate to the Details page.
  4. Go to the Linode Details > Network tab or NodeBalancer Details > Settings tab. Observe under the Firewalls section that the Firewall from step 2 is listed and there are "No rules" and it is Enabled.
  5. Click on the Firewall label to navigate to the Firewall's details page and add a new inbound or outbound rule. (Can be a preset rule; it's fastest.) Save the changes.
  6. Switch the Firewall's Status from Enabled to Disabled via the Firewall landing page.
  7. Navigate back to the device with the Firewall, either via nav bar or via the Firewall details page > device tab.
  8. Go back to the Network or Settings tab where the Firewalls table is shown for that device.
  9. Observe the bug: the Firewall listed in the table will not have the newly added rule and its status will not have updated.
  10. Refresh the page.
  11. Observe the rule now shows up. (e.g. "1 inbound rule" or "1 outbound rule") and the status has changed.

Verification steps

(How to verify changes)

  • Check out this PR.
  • Repeat the steps above to modify the Firewall's rules and status.
  • Confirm that no page refresh is needed to see the device's accurate Firewall data due to RQ correctly invalidating as expected when the Firewall is modified, and then refetching once the user navigates to the Firewalls table on the Linode Network tab or NodeBalancer Settings tab.

As an Author I have considered 🤔

Check all that apply

  • 👀 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

@mjac0bs mjac0bs self-assigned this May 31, 2024
@mjac0bs mjac0bs requested a review from a team as a code owner May 31, 2024 15:25
@mjac0bs mjac0bs requested review from jdamore-linode and jaalah-akamai and removed request for a team May 31, 2024 15:25
@mjac0bs mjac0bs changed the title fix: - [M3-7718] - Firewalls not updating for assigned Linodes and NodeBalancers due to lack of query invalidation fix: [M3-7718] - Firewalls not updating for assigned Linodes and NodeBalancers due to lack of query invalidation May 31, 2024
@mjac0bs mjac0bs changed the title fix: [M3-7718] - Firewalls not updating for assigned Linodes and NodeBalancers due to lack of query invalidation fix: [M3-7718] - Stale assigned Firewall data displaying on Linode and NodeBalancer details pages May 31, 2024
@@ -66,17 +66,19 @@ export const FirewallDialog = React.memo((props: Props) => {

const onSubmit = async () => {
await requestMap[mode]();
// Invalidate Firewalls assigned to NodeBalancers and Linodes when Firewall is enabled, disabled, or deleted.
// eslint-disable-next-line no-unused-expressions
devices?.forEach((device) => {
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, we were only invalidating the Firewalls assigned to a device when deleting the Firewall. Updating the status of the Firewall (e.g. enabling it or disabling it) should be reason to invalidate the Firewall too.

@@ -193,6 +201,19 @@ export const FirewallRulesLanding = React.memo((props: Props) => {
updateFirewallRules(finalRules)
.then((_rules) => {
setSubmitting(false);
// Invalidate Firewalls assigned to NodeBalancers and Linodes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No invalidation was happening on Firewall rule updates, which was the initial issue identified in the ticket.

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 some linting and renaming in this file. The query key for nodebalancers is plural, so updated the name of the import accordingly. This is done in a few other files, too.

Copy link

github-actions bot commented May 31, 2024

Coverage Report:
Base Coverage: 82.34%
Current Coverage: 82.34%

@mjac0bs
Copy link
Contributor Author

mjac0bs commented May 31, 2024

The CI test failure on linode-config.spec.ts is unrelated to this PR and it passes locally.

image

@mjac0bs mjac0bs added the Add'tl Approval Needed Waiting on another approval! label Jun 4, 2024
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.

Thank you for the fixes! 🧰

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jun 4, 2024
@mjac0bs mjac0bs merged commit ae81ee3 into linode:develop Jun 4, 2024
17 of 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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants