Skip to content

Fix to ensure that at least one fc is active when total fcs < 3#5259

Open
aks03dev wants to merge 1 commit intoopenconfig:mainfrom
b4firex:fix/gnmi-1.18
Open

Fix to ensure that at least one fc is active when total fcs < 3#5259
aks03dev wants to merge 1 commit intoopenconfig:mainfrom
b4firex:fix/gnmi-1.18

Conversation

@aks03dev
Copy link

Brief Description

Previously, for setups with fewer than 3 FCs, the existing shutdown formula could end up shutting down all FCs.

The number of FCs to shut down was calculated as:

n/2 + 1

For example, when n = 2:

2/2 + 1 = 2

This shuts down both FCs, which would not be a valid test scenario

Change Made

Updated the logic so that if the calculated shutdown count would bring down all FCs, the test shuts down n - 1 FCs instead.

@aks03dev aks03dev requested a review from a team as a code owner March 25, 2026 10:39
@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 refines the test for sampled backplane capacity counters by addressing an edge case where the test could inadvertently shut down all Fabric Cards (FCs) in systems with a small number of FCs. The changes ensure that the test always maintains at least one active FC, thereby preserving the validity of the test scenario and preventing unintended system states. Additionally, a check was added to ensure the test only runs when a sufficient number of FCs are available.

Highlights

  • Test Logic Enhancement: Modified the test logic to prevent scenarios where all Fabric Cards (FCs) are shut down during testing, ensuring at least one FC remains active for valid test execution.
  • Minimum FC Requirement: Introduced a new skip condition for the test, requiring a minimum of two removable Fabric Cards to proceed, preventing test execution in insufficient hardware configurations.
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.

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.

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 enhances the TestOnChangeBackplaneCapacityCounters test by adding a pre-condition to skip the test if fewer than two fabric cards are available. It also introduces logic to ensure that at least one fabric card remains active during the test by capping the number of cards to be disabled. A review comment suggests improving the robustness of this capping logic by using a >= comparison instead of == for better future-proofing and clarity.

Comment on lines +150 to +153
if fc == len(fabrics) {
fc = len(fabrics) - 1
t.Logf("Capping fabric cards to disable at %d to keep at least 1 active", fc)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For robustness and to better express the intent of never disabling all fabric cards, it's slightly better to use >= instead of == in your condition. While with the current logic fc cannot be greater than len(fabrics) for 2 or more fabrics, using >= makes the condition's purpose—to prevent shutting down all cards—more explicit and robust against potential future changes to the calculation of fc.

Suggested change
if fc == len(fabrics) {
fc = len(fabrics) - 1
t.Logf("Capping fabric cards to disable at %d to keep at least 1 active", fc)
}
if fc >= len(fabrics) {
fc = len(fabrics) - 1
t.Logf("Capping fabric cards to disable at %d to keep at least 1 active", fc)
}

@AmrNJ
Copy link
Contributor

AmrNJ commented Mar 25, 2026

/fptest all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants