Skip to content

fix(dashboard): add FlowSchema to exempt BFF from API throttling#2121

Merged
kvaps merged 1 commit intomainfrom
fix/dashboard-apf-flowschema
Feb 28, 2026
Merged

fix(dashboard): add FlowSchema to exempt BFF from API throttling#2121
kvaps merged 1 commit intomainfrom
fix/dashboard-apf-flowschema

Conversation

@kvaps
Copy link
Member

@kvaps kvaps commented Feb 28, 2026

Summary

  • Add FlowSchema cozy-dashboard-exempt to exempt the dashboard BFF service account (incloud-web-web) from API Priority and Fairness throttling
  • BFF falls under the default service-accounts FlowSchema → workload-low priority level, which causes 429 responses under load

Test plan

  • Deploy to a cluster with dashboard enabled
  • Verify FlowSchema is created: kubectl get flowschema cozy-dashboard-exempt
  • Verify BFF no longer receives 429 errors under load

Summary by CodeRabbit

  • Chores
    • Added a new Kubernetes FlowSchema configuration for system resource access management.

The dashboard BFF service account (incloud-web-web) falls under the
default "service-accounts" FlowSchema which maps to the "workload-low"
priority level. Under load, this causes API Priority and Fairness to
return 429 (Too Many Requests) responses to the BFF, resulting in 500
errors for dashboard users.

Add a FlowSchema that maps the BFF service account to the "exempt"
priority level to prevent APF throttling of dashboard API requests.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
@kvaps kvaps added the backport Should change be backported on previus release label Feb 28, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical performance issue where the dashboard's Backend For Frontend (BFF) service was experiencing API throttling, leading to 429 errors under heavy load. By implementing a new Kubernetes FlowSchema, the BFF service account is now explicitly exempted from API Priority and Fairness, ensuring stable operation and improved responsiveness for the dashboard.

Highlights

  • API Throttling Exemption: A new FlowSchema named cozy-dashboard-exempt has been introduced to prevent the dashboard BFF service account (incloud-web-web) from being throttled by Kubernetes API Priority and Fairness.
  • Addressing 429 Errors: This change aims to resolve instances where the BFF service was receiving 429 'Too Many Requests' errors under load due to its default workload-low priority level.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/system/dashboard/templates/flowschema.yaml
    • Added a new Kubernetes FlowSchema definition to exempt the dashboard BFF service account from API throttling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kvaps kvaps marked this pull request as ready for review February 28, 2026 10:32
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Feb 28, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 28, 2026

📝 Walkthrough

Walkthrough

Adds a new Kubernetes FlowSchema manifest that grants the incloud-web-web ServiceAccount broad API access permissions across all resources and namespaces, linked to the exempt PriorityLevelConfiguration with a matchingPrecedence of 2.

Changes

Cohort / File(s) Summary
Kubernetes FlowSchema Addition
packages/system/dashboard/templates/flowschema.yaml
New manifest defining cozy-dashboard-exempt FlowSchema with wildcard verb permissions for the incloud-web-web ServiceAccount, enabling cluster-wide API access tied to the exempt PriorityLevelConfiguration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A flow through the cluster, so exempt and so free,
With verbs that are wild as they possibly can be,
The dashboard dances in precedence's glow,
Where permissions and priorities gracefully flow! 🌊

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a FlowSchema to exempt the dashboard BFF from API throttling. It is clear, specific, and directly reflects the changeset's primary purpose.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/dashboard-apf-flowschema

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a FlowSchema to exempt the dashboard's backend-for-frontend (BFF) service account from API server throttling. While this addresses the issue of 429 Too Many Requests errors, the implementation introduces potential stability and security risks. The FlowSchema uses overly permissive resource rules, matching all possible API requests, which goes against the principle of least privilege. Additionally, it assigns the requests to the exempt priority level, which is generally discouraged for workloads as it completely bypasses API server protection mechanisms. My review includes suggestions to tighten the resource rules and to consider using a custom priority level with a high limit instead of complete exemption.

Comment on lines +15 to +20
resourceRules:
- verbs: ["*"]
apiGroups: ["*"]
resources: ["*"]
namespaces: ["*"]
clusterScope: true
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The resourceRules are configured to match all possible API requests (verbs: ["*"], apiGroups: ["*"], resources: ["*"], namespaces: ["*"], clusterScope: true). This is overly permissive and goes against the principle of least privilege. While this FlowSchema doesn't grant permissions, it exempts the service account from API throttling entirely. In case of a compromise or a bug in the BFF, this could be abused to flood the API server with requests, potentially leading to a denial-of-service condition for other components in the cluster.

Please scope down these rules to only match the API requests that the incloud-web-web service account is authorized to make and needs exemption for. You should define more specific rules based on the actual permissions granted to the service account via its RBAC roles.

spec:
matchingPrecedence: 2
priorityLevelConfiguration:
name: exempt
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using the exempt priority level completely bypasses API Priority and Fairness for these requests. This level is typically reserved for the most critical system components. For a workload like the dashboard BFF, it's recommended to create a dedicated PriorityLevelConfiguration with a high concurrency limit instead. This would still prevent throttling under normal load while retaining a safety net against request floods that could impact the API server's stability.

Consider creating a new PriorityLevelConfiguration and referencing it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/system/dashboard/templates/flowschema.yaml (2)

6-6: matchingPrecedence: 2 collides with built-in probes FlowSchema.

The built-in probes FlowSchema also uses precedence 2. When two FlowSchemas share the same precedence, the one with the lexicographically smaller name wins. Since cozy-dashboard-exempt < probes, this FlowSchema will take priority for any overlapping requests. This is likely fine, but consider using a slightly higher number (e.g., 3-10) to avoid ambiguity and potential conflicts with future built-in FlowSchemas.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/system/dashboard/templates/flowschema.yaml` at line 6, The
FlowSchema "cozy-dashboard-exempt" currently sets matchingPrecedence: 2 which
collides with the built-in "probes" FlowSchema; update the matchingPrecedence
for "cozy-dashboard-exempt" to a higher value (e.g., 3–10) so it no longer
shares precedence with "probes" and avoids lexicographic tie-breaker ambiguity.

1-20: Consider adding nonResourceRules for complete throttling exemption.

The FlowSchema only defines resourceRules, which matches requests to Kubernetes resources. If the BFF also makes non-resource requests (e.g., discovery endpoints like /api, /apis, /openapi/v2, or health checks), those requests will still fall through to other FlowSchemas and could be throttled.

To fully exempt the BFF from throttling, consider adding a nonResourceRules entry:

Proposed fix to add nonResourceRules
   rules:
     - subjects:
         - kind: ServiceAccount
           serviceAccount:
             name: incloud-web-web
             namespace: {{ .Release.Namespace }}
       resourceRules:
         - verbs: ["*"]
           apiGroups: ["*"]
           resources: ["*"]
           namespaces: ["*"]
           clusterScope: true
+      nonResourceRules:
+        - verbs: ["*"]
+          nonResourceURLs: ["*"]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/system/dashboard/templates/flowschema.yaml` around lines 1 - 20, The
FlowSchema named "cozy-dashboard-exempt" currently only lists resourceRules so
non-resource endpoints remain subject to throttling; update the spec for
FlowSchema "cozy-dashboard-exempt" (the block that targets ServiceAccount
incloud-web-web in namespace {{ .Release.Namespace }}) to add an appropriate
nonResourceRules entry (mirroring the exemption intent of resourceRules) that
matches non-resource paths (e.g., "*" or health/discovery paths) so the BFF's
non-resource requests are also exempted from throttling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/system/dashboard/templates/flowschema.yaml`:
- Line 6: The FlowSchema "cozy-dashboard-exempt" currently sets
matchingPrecedence: 2 which collides with the built-in "probes" FlowSchema;
update the matchingPrecedence for "cozy-dashboard-exempt" to a higher value
(e.g., 3–10) so it no longer shares precedence with "probes" and avoids
lexicographic tie-breaker ambiguity.
- Around line 1-20: The FlowSchema named "cozy-dashboard-exempt" currently only
lists resourceRules so non-resource endpoints remain subject to throttling;
update the spec for FlowSchema "cozy-dashboard-exempt" (the block that targets
ServiceAccount incloud-web-web in namespace {{ .Release.Namespace }}) to add an
appropriate nonResourceRules entry (mirroring the exemption intent of
resourceRules) that matches non-resource paths (e.g., "*" or health/discovery
paths) so the BFF's non-resource requests are also exempted from throttling.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between daa3905 and 161b5be.

📒 Files selected for processing (1)
  • packages/system/dashboard/templates/flowschema.yaml

@kvaps kvaps merged commit dec1501 into main Feb 28, 2026
12 checks passed
@kvaps kvaps deleted the fix/dashboard-apf-flowschema branch February 28, 2026 10:55
@github-actions
Copy link

Successfully created backport PR for release-1.0:

kvaps added a commit that referenced this pull request Feb 28, 2026
…rom API throttling (#2124)

# Description
Backport of #2121 to `release-1.0`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Should change be backported on previus release bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant