Skip to content

Commit

Permalink
fix: IPFamilyPolicy not synced for default vcluster service
Browse files Browse the repository at this point in the history
Signed-off-by: Rohan CJ <rohantmp@gmail.com>
  • Loading branch information
rohantmp committed Mar 14, 2024
1 parent 416b991 commit 774abc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/specialservices/proxy_service_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func SyncVclusterProxyService(ctx *synccontext.SyncContext,
newService.Spec.ClusterIP = pObj.Spec.ClusterIP
newService.Spec.ClusterIPs = pObj.Spec.ClusterIPs
newService.Spec.IPFamilies = pObj.Spec.IPFamilies
newService.Spec.IPFamilyPolicy = pObj.Spec.IPFamilyPolicy

// delete & create with correct ClusterIP
err = vClient.Delete(ctx.Context, vObj)
Expand Down
8 changes: 6 additions & 2 deletions pkg/specialservices/service_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ func SyncKubernetesService(
return err
}

// detect if cluster ips changed
clusterIPsChanged := vObj.Spec.ClusterIP != pObj.Spec.ClusterIP || !equality.Semantic.DeepEqual(vObj.Spec.ClusterIPs, pObj.Spec.ClusterIPs)

translatedPorts := svcPortTranslator(pObj.Spec.Ports)
if vObj.Spec.ClusterIP != pObj.Spec.ClusterIP || !equality.Semantic.DeepEqual(vObj.Spec.Ports, translatedPorts) {
if clusterIPsChanged || !equality.Semantic.DeepEqual(vObj.Spec.Ports, translatedPorts) {
newService := vObj.DeepCopy()
newService.Spec.ClusterIP = pObj.Spec.ClusterIP
newService.Spec.ClusterIPs = pObj.Spec.ClusterIPs
newService.Spec.IPFamilies = pObj.Spec.IPFamilies
newService.Spec.IPFamilyPolicy = pObj.Spec.IPFamilyPolicy
newService.Spec.Ports = translatedPorts
if vObj.Spec.ClusterIP != pObj.Spec.ClusterIP || !equality.Semantic.DeepEqual(vObj.Spec.ClusterIPs, pObj.Spec.ClusterIPs) {
if clusterIPsChanged {
// delete & create with correct ClusterIP
err = ctx.VirtualClient.Delete(ctx.Context, vObj)
if err != nil {
Expand Down

0 comments on commit 774abc9

Please sign in to comment.