Skip to content

Conversation

@ijernoiu
Copy link
Contributor

Temporarily enabling PF counters check through CLI as per discussion in issue 454567032

@ijernoiu ijernoiu requested a review from a team as a code owner January 21, 2026 01:03
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ijernoiu, 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 enhances the testing framework by introducing a fallback mechanism for verifying Policy Forwarding (PF) counters. Previously, tests relied solely on OpenConfig (OC) for this data. With this change, if a device (specifically Arista, as implemented) does not support PF counters via OC, the system will now query the device using CLI commands. This ensures test coverage for PF counters on platforms with incomplete OC implementations, addressing a known issue.

Highlights

  • CLI Fallback for PF Counters: Implemented a mechanism to check Policy Forwarding (PF) counters via CLI for devices where OpenConfig (OC) support is lacking.
  • New Deviation Introduced: Added PolicyForwardingCountersUnsupported deviation to flag devices that do not support PF counters through OC.
  • Arista-Specific CLI Parsing: Included logic to parse CLI output for policy statistics specifically for Arista devices.
  • Protobuf and Deviation Updates: Updated protobuf definitions and deviation handling code to incorporate the new PolicyForwardingCountersUnsupported flag.

🧠 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.

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.

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 introduces the ability to check policy forwarding counters via CLI for devices that do not support OpenConfig (OC) telemetry. This is a temporary measure to enable testing on specific platforms. The changes involve adding new Go functions to execute CLI commands and parse their output, updating the metadata to reflect this deviation, and regenerating protobuf files. Overall, the approach addresses the immediate need, but some areas could be made more robust.

Comment on lines +519 to +524
if err != nil {
t.Errorf("Failed to execute CLI command '%s': %v", cliCommand, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

If the CLI command fails to execute, it's a critical issue that prevents the test from proceeding meaningfully. Using t.Fatalf here would immediately stop the test and mark it as failed, which is generally preferred for unrecoverable errors during test setup or execution.

Suggested change
if err != nil {
t.Errorf("Failed to execute CLI command '%s': %v", cliCommand, err)
if err != nil {
t.Fatalf("Failed to execute CLI command '%s': %v", cliCommand, err)
}

Comment on lines +547 to +552
if err != nil {
t.Errorf("Invalid response for CLI command '%s': %v", cliOutput, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Similar to the runCliCommand error handling, if strconv.ParseUint fails, it indicates a fundamental issue with parsing the CLI output, making further test assertions unreliable. Using t.Fatalf here would ensure the test stops immediately, preventing misleading results.

if err != nil {
		t.Fatalf("Invalid response for CLI command '%s': %v", cliOutput, err)
	}

switch dut.Vendor() {
case ondatra.ARISTA:
//extract text from CLI output between rule name and packets
policyCountersCommand := fmt.Sprintf(`show traffic-policy %s interface counters | grep %s | sed -e 's/.*%s:\(.*\)packets.*/\1/'`, trafficPolicyName, tc.policyRule, tc.policyRule)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of sed with a complex regular expression to extract data from CLI output can be brittle. CLI output formats can change, leading to test failures. Consider a more robust parsing method, such as splitting the output into lines and then fields, or using a more flexible regex if direct parsing is unavoidable. This improves maintainability and reduces the risk of future breakage.

For example, if the output format changes slightly, this regex might fail. A more resilient approach might involve:

  1. Splitting the cliOutput by newline to get individual lines.
  2. Iterating through lines to find the one containing tc.policyRule.
  3. Using strings.Fields or a simpler regex on that specific line to extract the number.

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.6
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The protoc-gen-go version has been downgraded from v1.36.7 to v1.36.6. This might indicate an unintentional change or a local environment mismatch. It's important to ensure that the protobuf generator versions are consistent across the project to avoid potential build issues or unexpected behavior. Please verify if this downgrade was intentional; otherwise, it should be reverted to v1.36.7 or updated to the latest stable version if appropriate.

Suggested change
// protoc-gen-go v1.36.6
// protoc-gen-go v1.36.7

@coveralls
Copy link

coveralls commented Jan 21, 2026

Pull Request Test Coverage Report for Build 21225941840

Details

  • 0 of 8 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 9.923%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/deviations/deviations.go 0 3 0.0%
proto/metadata_go_proto/metadata.pb.go 0 5 0.0%
Totals Coverage Status
Change from base Build 21215138038: -0.004%
Covered Lines: 2227
Relevant Lines: 22442

💛 - Coveralls

@Iosif-Jernoiu Iosif-Jernoiu force-pushed the pf-1.2-cliTelemetryUpdate branch from 2ebe96e to 901f36f Compare January 21, 2026 13:27
@dplore
Copy link
Member

dplore commented Jan 21, 2026

We cannot accept CLI for counters. Counters must always be via gnmi streaming. A deviation could be used for paths that are not openconfig (vendor native paths).

See the guide for deviations.

3. Deviations may be created to change which OC path is used for telemetry or
use an implementation's native yang path.  Deviations for telemetry
should not introduce a depedency on CLI output.

@ram-mac

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants