Skip to content

bugfix: set cluster-ip when mapping host to vCluster service #2331

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/controllers/servicesync/servicesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,17 @@ func (e *ServiceSyncer) syncServiceAndEndpoints(ctx context.Context, fromService
},
},
Spec: corev1.ServiceSpec{
Ports: fromService.Spec.Ports,
ClusterIP: corev1.ClusterIPNone,
Ports: fromService.Spec.Ports,
},
}

// Check if ClusterIP is not "None"
if fromService.Spec.ClusterIP != corev1.ClusterIPNone {
toService.Spec.ClusterIP = fromService.Spec.ClusterIP
} else {
toService.Spec.ClusterIP = corev1.ClusterIPNone
}
Comment on lines +222 to +231
Copy link
Contributor

@zerbitx zerbitx Feb 11, 2025

Choose a reason for hiding this comment

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

Thank you for this! I haven't had a moment to see if this is the correct fix for the issue, but since this conditional sets to service to none if from service is none, or the value of from service it should be the same as

Suggested change
Ports: fromService.Spec.Ports,
},
}
// Check if ClusterIP is not "None"
if fromService.Spec.ClusterIP != corev1.ClusterIPNone {
toService.Spec.ClusterIP = fromService.Spec.ClusterIP
} else {
toService.Spec.ClusterIP = corev1.ClusterIPNone
}
Ports: fromService.Spec.Ports,
ClusterIP: fromService.Spec.ClusterIP,
},
}


if e.IsVirtualToHostSyncer {
e.Log.Infof("Add owner reference to host target service %s", to.Name)
toService.OwnerReferences = translate.GetOwnerReference(nil)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/servicesync/servicesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func testMapping(ctx context.Context, fromClient kubernetes.Interface, fromNames
framework.ExpectEqual(toService.Spec.Selector[translate.NamespaceLabel], fromNamespace)
framework.ExpectEqual(toService.Spec.Selector[translate.MarkerLabel], translate.VClusterName)
framework.ExpectEqual(toService.Spec.Selector[translate.HostLabel("test")], "test")
framework.ExpectEqual(toService.Spec.ClusterIP, fromService.Spec.ClusterIP)
}

// check service deletion
Expand Down