Skip to content

MLE-21691: fix bug for service not updated when added new port #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

pengzhouml
Copy link
Collaborator

No description provided.

@Copilot Copilot AI review requested due to automatic review settings June 17, 2025 06:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that existing Kubernetes Service resources are updated when new ports are added by introducing patch-based diffing and refactoring service generation.

  • Use k8s-objectmatcher to calculate and apply patches in ReconcileServices, updating Services when specs differ.
  • Add StsName to serviceParameters and switch selector logic to getSelectorLabels(params.StsName).
  • Remove deprecated helper methods (getService, CreateOrUpdateService) and refine import and label merging logic.
Comments suppressed due to low confidence (4)

pkg/k8sutil/service.go:18

  • [nitpick] The field name 'StsName' is an unclear abbreviation; consider renaming it to 'StatefulSetName' for clarity.
StsName     string

pkg/k8sutil/service.go:106

  • [nitpick] The declaration of svcParams could be simplified by directly using a short variable declaration (e.g., svcParams := generateServiceParams(cr)), removing the redundant zero-value initialization.
var svcParams serviceParameters = serviceParameters{}

pkg/k8sutil/service.go:125

  • Consider adding unit or integration tests for the service reconciliation logic, especially covering the update path when new ports are added to verify the patch and update behavior.
svcDef := generateService(service, cr)

pkg/k8sutil/service.go:17

  • Add a doc comment for the StsName field in serviceParameters to explain its purpose and usage.
type serviceParameters struct {

@@ -3,6 +3,7 @@ package k8sutil
import (
"strings"

"github.com/cisco-open/k8s-objectmatcher/patch"
Copy link
Preview

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider reorganizing imports to follow the project's style guide (e.g., grouping standard library, third-party, and local imports separately) for consistency.

Copilot uses AI. Check for mistakes.

@pengzhouml pengzhouml merged commit b62461b into develop Jun 17, 2025
3 checks passed
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.

2 participants