Skip to content

Fix(Telemetry): remove extra double quotes from machine_type in static_node_count metric#5947

Merged
kadupoornima merged 1 commit into
GoogleCloudPlatform:developfrom
kadupoornima:quotes
Jul 13, 2026
Merged

Fix(Telemetry): remove extra double quotes from machine_type in static_node_count metric#5947
kadupoornima merged 1 commit into
GoogleCloudPlatform:developfrom
kadupoornima:quotes

Conversation

@kadupoornima

@kadupoornima kadupoornima commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the telemetry data collection by cleaning up the format of the static_node_count metric, specifically by removing unnecessary double quotes. Additionally, it includes minor code refactoring for better error handling and test maintenance.

Changes:

  • Telemetry Formatting: Removed extra double quotes from the machine_type in the static_node_count metric to provide a cleaner output format.
  • Code Refactoring: Reordered logic in checkInputValueMatchesType to perform validation before deferring the panic recovery.
  • Test Cleanup: Updated multiple test cases in collector_test.go to reflect the new metric format and removed an unused test function in expand_test.go.

@kadupoornima
kadupoornima requested a review from a team as a code owner July 13, 2026 10:06
@kadupoornima kadupoornima added the release-bugfix Added to release notes under the "Bug fixes" heading. label Jul 13, 2026
@kadupoornima
kadupoornima enabled auto-merge (squash) July 13, 2026 10:06
@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 improves the telemetry data collection by cleaning up the format of the static_node_count metric, specifically by removing unnecessary double quotes. Additionally, it includes minor code refactoring for better error handling and test maintenance.

Highlights

  • Telemetry Formatting: Removed extra double quotes from the machine_type in the static_node_count metric to provide a cleaner output format.
  • Code Refactoring: Reordered logic in checkInputValueMatchesType to perform validation before deferring the panic recovery.
  • Test Cleanup: Updated multiple test cases in collector_test.go to reflect the new metric format and removed an unused test function in expand_test.go.
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 the 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 counterproductive. 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.

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

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.

Code Review

This pull request removes double quotes from the static node counts in telemetry metrics and updates the corresponding tests. However, two critical issues were identified in the configuration package: first, moving attemptEvalModuleInput before the defer statement in pkg/config/expand.go prevents the recovery block from catching potential panics during evaluation; second, the TestExpandGlobalLabels test suite was accidentally deleted and should be restored to maintain test coverage.

I am having trouble creating individual review comments. Click here to see my feedback.

pkg/config/expand.go (74-84)

high

Moving attemptEvalModuleInput before the defer statement prevents the recover() block from catching any panics that might occur during the evaluation of val (for example, if val is cty.NilVal or triggers other edge-case panics in cty). In Go, a defer statement must be executed before the code that panics in order to recover from it.

Please restore the original order where the defer block is registered at the very beginning of the function.

	// cty does panic on some edge cases, e.g. (cty.NilVal)
	// we don't anticipate any of those, but just in case, catch panic and return as error
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("panic during type conversion for %q: %v", input.Name, r)
		}
	}()
	v, ok := attemptEvalModuleInput(val, bp)
	if !ok || input.Type == cty.NilType {
		return nil // skip, can do nothing
	}
References
  1. Follow standard Go idioms and best practices, particularly regarding error handling and panic recovery using defer. (link)

pkg/config/expand_test.go (449-574)

medium

The entire test function TestExpandGlobalLabels (and its strings import) has been deleted. This deletion seems accidental and is unrelated to the PR's objective of fixing the telemetry double quotes. Please restore this test function to maintain test coverage.

References
  1. The repository style guide emphasizes that changes must be well-tested and existing test coverage should be maintained. (link)

Change-Id: I897cf9469f75d974fc4f995b88b1a9c39553b852
@kadupoornima

Copy link
Copy Markdown
Contributor Author

/gemini review

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

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.

Code Review

This pull request updates the getStaticNodeCounts function in pkg/telemetry/collector.go to remove double quotes from the returned static node counts string, resulting in a cleaner metric format (e.g., g4-standard-48:3 instead of "g4-standard-48":3). The corresponding unit tests in pkg/telemetry/collector_test.go have been updated to reflect this new format. I have no feedback to provide as the changes are correct and the tests have been properly updated.

@kadupoornima
kadupoornima merged commit 5deee3c into GoogleCloudPlatform:develop Jul 13, 2026
13 of 83 checks passed
@kadupoornima
kadupoornima deleted the quotes branch July 13, 2026 10:51
Neelabh94 pushed a commit to Neelabh94/cluster-toolkit that referenced this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-bugfix Added to release notes under the "Bug fixes" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants