Skip to content

refactor: unify environment variable names using util package constants#6061

Merged
zhangzujian merged 1 commit intokubeovn:masterfrom
zhangzujian:fix-const
Dec 23, 2025
Merged

refactor: unify environment variable names using util package constants#6061
zhangzujian merged 1 commit intokubeovn:masterfrom
zhangzujian:fix-const

Conversation

@zhangzujian
Copy link
Copy Markdown
Member

Pull Request

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes

Fixes #(issue-number)

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @zhangzujian, 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 focuses on a significant refactoring effort to standardize the use of environment variables and API client configurations throughout the project. By replacing hardcoded strings with centralized constants and introducing utility functions, the changes aim to enhance code consistency, improve readability, and simplify future modifications and debugging related to environment-dependent settings and Kubernetes API interactions.

Highlights

  • Standardized Environment Variable Names: Replaced numerous hardcoded environment variable names (e.g., 'KUBE_NODE_NAME', 'POD_NAMESPACE', 'POD_IP', 'ENABLE_SSL', 'KUBERNETES_SERVICE_HOST') across the codebase with consistent constants defined in the pkg/util package. This improves maintainability and reduces potential for errors.
  • Centralized Constants for Kubernetes API Client: Moved hardcoded ContentType and AcceptContentTypes strings used for Kubernetes API client configurations into pkg/util constants, ensuring uniformity in API communication settings.
  • New Utility Function for Service Environment Variables: Introduced a new utility function InjectedServiceVariables in pkg/util/k8s.go to programmatically derive Kubernetes-injected service environment variable names (e.g., SERVICE_HOST, SERVICE_PORT) from a service name, enhancing dynamic configuration.
  • OVS Database Port Constants: Added a new file pkg/ovs/const.go to define constants for OVS database ports (NB, SB, Raft), centralizing these values for better management.
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.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 16, 2025

Pull Request Test Coverage Report for Build 20420966400

Details

  • 14 of 107 (13.08%) changed or added relevant lines in 27 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.007%) to 22.607%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controller/pki.go 0 1 0.0%
pkg/controller/signer.go 0 1 0.0%
pkg/controller/vpc_nat_gateway.go 0 1 0.0%
pkg/metrics/dynamic_cert_key.go 1 2 50.0%
pkg/ovn_ic_controller/ovn_ic_controller.go 0 1 0.0%
pkg/ovnmonitor/exporter.go 0 1 0.0%
pkg/ovs/ovsdb-client.go 1 2 50.0%
pkg/pinger/ovn.go 0 1 0.0%
pkg/speaker/utils.go 0 1 0.0%
pkg/ovs/ovn.go 2 4 50.0%
Files with Coverage Reduction New Missed Lines %
pkg/ovn_leader_checker/ovn.go 1 0.0%
pkg/ovs/ovn-nb-logical_router_route.go 2 74.6%
Totals Coverage Status
Change from base Build 20420579027: 0.007%
Covered Lines: 12060
Relevant Lines: 53346

💛 - Coveralls

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 is a great refactoring effort to unify environment variable names by using constants from the util package. This improves code maintainability and consistency by reducing magic strings. The changes are applied across YAML, Go, and shell script files. I've found one critical issue in the implementation that needs to be addressed.

@zhangzujian zhangzujian force-pushed the fix-const branch 4 times, most recently from 9250de3 to 4b17a3d Compare December 20, 2025 05:01
@zhangzujian zhangzujian marked this pull request as ready for review December 21, 2025 05:54
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Dec 21, 2025
@zhangzujian zhangzujian force-pushed the fix-const branch 2 times, most recently from 118fdb3 to 5cafe44 Compare December 22, 2025 00:09
@zhangzujian
Copy link
Copy Markdown
Member Author

/gemini review

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 is a comprehensive refactoring to unify the use of environment variable names and other constants by centralizing them in the pkg/util package. The changes are applied consistently across YAML configuration files, shell scripts, and Go source code, which significantly improves maintainability and code clarity.

Key improvements include:

  • Standardizing environment variable names, such as changing KUBE_NODE_NAME to the more standard NODE_NAME.
  • Removing redundant environment variable definitions.
  • Replacing hardcoded strings for annotations, ports, and content types with shared constants.
  • Introducing helper functions like InjectedServiceVariables and CmdSSLArgs to reduce code duplication.
  • Minor but valuable improvements to error messages and test code quality.

The refactoring is well-executed and enhances the overall quality of the codebase. I have not found any issues with the implementation.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 23, 2025
@zhangzujian zhangzujian merged commit 5151eb9 into kubeovn:master Dec 23, 2025
143 of 144 checks passed
@zhangzujian zhangzujian deleted the fix-const branch December 23, 2025 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants