Skip to content

Commit

Permalink
fix: simply fix panic when service ports changed (#7993)
Browse files Browse the repository at this point in the history
  • Loading branch information
loomts authored Aug 21, 2024
1 parent 9cb257a commit b0ea66e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/apps/transformer_cluster_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ func createOrUpdateService(ctx graph.TransformContext, dag *graph.DAG, graphCli
func resolveServiceDefaultFields(obj, objCopy *corev1.ServiceSpec) {
// TODO: how about the order changed?
for i, port := range objCopy.Ports {
if i == len(obj.Ports) {
break
}
// if the service type is NodePort or LoadBalancer, and the nodeport is not set, we should use the nodeport of the exist service
if (objCopy.Type == corev1.ServiceTypeNodePort || objCopy.Type == corev1.ServiceTypeLoadBalancer) && port.NodePort == 0 && obj.Ports[i].NodePort != 0 {
objCopy.Ports[i].NodePort = obj.Ports[i].NodePort
Expand Down

0 comments on commit b0ea66e

Please sign in to comment.