Skip to content
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

feat: set appProtocol based on target service #2094

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yapcheekian
Copy link

@Yapcheekian Yapcheekian commented Apr 21, 2024

Why are these changes needed?

#668 always set app protocol to tcp. This change dynamically adjusts the port protocol based on the target service.

Related issue number

#1946

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@Yapcheekian
Copy link
Author

@rueian

for name, port := range ports_int {
svcPort := corev1.ServicePort{Name: name, Port: port, AppProtocol: &defaultAppProtocol}
for svc, portInfo := range serviceMapPortInfo {
svcPort := corev1.ServicePort{Name: svc, Port: portInfo.PortNumber, AppProtocol: &portInfo.Protocol}
Copy link
Contributor

@rueian rueian Apr 21, 2024

Choose a reason for hiding this comment

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

Is it possible that the &portInfo.Protocol here points to an empty value? I think in that case we should still use the &defaultAppProtocol

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@@ -203,7 +202,7 @@ func BuildServeService(ctx context.Context, rayService rayv1.RayService, rayClus
ports := []corev1.ServicePort{}
for name, port := range ports_int {
if name == utils.ServingPortName {
svcPort := corev1.ServicePort{Name: name, Port: port}
svcPort := corev1.ServicePort{Name: name, Port: port.PortNumber}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set AppProtocol here?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@@ -369,35 +368,55 @@ func getServicePorts(cluster rayv1.RayCluster) map[string]int32 {

// check if metrics port is defined. If not, add default value for it.
if _, metricsDefined := ports[utils.MetricsPortName]; !metricsDefined {
ports[utils.MetricsPortName] = utils.DefaultMetricsPort
ports[utils.MetricsPortName] = portInfo{PortNumber: utils.DefaultMetricsPort}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set AppProtocol here?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@Yapcheekian Yapcheekian force-pushed the feat/set-app-protocol branch 2 times, most recently from d886490 to 4b9052f Compare April 21, 2024 10:49
@Yapcheekian Yapcheekian requested a review from rueian April 21, 2024 11:12
@@ -42,10 +42,10 @@ func BuildIngressForHeadService(ctx context.Context, cluster rayv1.RayCluster) (

var paths []networkingv1.HTTPIngressPath
pathType := networkingv1.PathTypeExact
servicePorts := getServicePorts(cluster)
serviceMapPortInfo := getServicePorts(cluster)
Copy link
Contributor

Choose a reason for hiding this comment

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

serviceMapPortInfo sounds a little wired. How about we keep it as servicePorts?

Copy link
Author

Choose a reason for hiding this comment

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

Adjusted

Comment on lines 70 to 74
if portInfo.Protocol != "" {
appProtocol = portInfo.Protocol
}

svcPort := corev1.ServicePort{Name: svc, Port: portInfo.PortNumber, AppProtocol: &appProtocol}
Copy link
Contributor

Choose a reason for hiding this comment

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

The corev1.ServicePort has two protocol fields. One is Protocol and the other one is AppProtocol.

To avoid confusion, I think we should rename the portInfo.Protocol to portInfo.AppProtocol here. That is:

Suggested change
if portInfo.Protocol != "" {
appProtocol = portInfo.Protocol
}
svcPort := corev1.ServicePort{Name: svc, Port: portInfo.PortNumber, AppProtocol: &appProtocol}
if portInfo.Protocol != "" {
appProtocol = portInfo.AppProtocol
}
svcPort := corev1.ServicePort{Name: svc, Port: portInfo.PortNumber, AppProtocol: &appProtocol}

Copy link
Author

Choose a reason for hiding this comment

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

Got it

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