Skip to content

When checking for Power Admin State, ignore FRU component slots that are empty#5254

Open
mnp-juniper wants to merge 2 commits intoopenconfig:mainfrom
mnp-juniper:invent
Open

When checking for Power Admin State, ignore FRU component slots that are empty#5254
mnp-juniper wants to merge 2 commits intoopenconfig:mainfrom
mnp-juniper:invent

Conversation

@mnp-juniper
Copy link
Copy Markdown
Contributor

@mnp-juniper mnp-juniper commented Mar 24, 2026

Issue: In DefaultPowerAdminState test, the script gathers all Linecards/Fabrics/Supervisors based on Component Type and checks for the PowerAdminState leaf of the first entry in each of the three lists. If the slot in the first entry is empty, the PowerAdminState leaf may not be available causing the script to fail.

Fix: Add isEmpty() check and include only the non-empty slots only to the lists.

@mnp-juniper mnp-juniper requested a review from a team as a code owner March 24, 2026 17:47
@gemini-code-assist
Copy link
Copy Markdown
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 test instability issue in the DefaultPowerAdminState test. Previously, the test could fail if it attempted to access the PowerAdminState of an empty hardware slot. The changes introduce checks to filter out empty components (Linecards, Fabrics, Supervisors) from the lists used in the test, thereby preventing failures and improving the robustness of the test suite.

Highlights

  • Test Reliability: Ensured the DefaultPowerAdminState test correctly handles empty hardware slots by filtering them out before checking for PowerAdminState.
  • Bug Fix: Resolved an issue where the test would fail if the first entry in the Linecards, Fabrics, or Supervisors lists corresponded to an empty slot, as the PowerAdminState leaf would be unavailable.
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.

@OpenConfigBot
Copy link
Copy Markdown

OpenConfigBot commented Mar 24, 2026

Pull Request Functional Test Report for #5254 / a7dfcc9

Virtual Devices

Device Test Test Documentation Job Raw Log
Arista cEOS status
gNMI-1.4: Telemetry: Inventory
Cisco 8000E status
gNMI-1.4: Telemetry: Inventory
Cisco XRd status
gNMI-1.4: Telemetry: Inventory
Juniper ncPTX status
gNMI-1.4: Telemetry: Inventory
Nokia SR Linux status
gNMI-1.4: Telemetry: Inventory
Openconfig Lemming status
gNMI-1.4: Telemetry: Inventory

Hardware Devices

Device Test Test Documentation Raw Log
Arista 7808 status
gNMI-1.4: Telemetry: Inventory
Cisco 8808 status
gNMI-1.4: Telemetry: Inventory
Juniper PTX10008 status
gNMI-1.4: Telemetry: Inventory
Nokia 7250 IXR-10e status
gNMI-1.4: Telemetry: Inventory

Help

@mnp-juniper mnp-juniper changed the title code changes to fix the empty slot issue When checking for Power Admin State, ignore FRU component slots that are empty Mar 24, 2026
Copy link
Copy Markdown
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 modifies telemetry_inventory_test.go to ensure that only non-empty Fabric, Linecard, and Supervisor components are appended to their respective slices. The review feedback suggests improving readability and adhering to Go's idiomatic style by simplifying the boolean expression c.GetEmpty() == false to !c.GetEmpty(), as recommended by the repository's style guide which references Effective Go and Go Code Review Comments.

Comment on lines +1046 to +1056
if c.GetEmpty() == false {
fabrics = append(fabrics, c)
}
case "Linecard":
linecards = append(linecards, c)
if c.GetEmpty() == false {
linecards = append(linecards, c)
}
case "Supervisor":
supervisors = append(supervisors, c)
if c.GetEmpty() == false {
supervisors = append(supervisors, c)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and to adhere to Go's idiomatic style, it's recommended to avoid explicit comparisons to false. The expression if c.GetEmpty() == false can be simplified to if !c.GetEmpty(). This applies to all three checks for Fabric, Linecard, and Supervisor components.

This follows the guidance from the repository style guide, which recommends following Effective Go and Go Code Review Comments.

				if !c.GetEmpty() {
					fabrics = append(fabrics, c)
				}
			case "Linecard":
				if !c.GetEmpty() {
					linecards = append(linecards, c)
				}
			case "Supervisor":
				if !c.GetEmpty() {
					supervisors = append(supervisors, c)
				}
References
  1. The repository style guide specifies following 'Effective Go' and 'Go Code Review Comments'. 'Effective Go' suggests simplifying boolean expressions by removing explicit comparisons to true or false. (link)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants