Repository: envoyproxy/gateway
Pull request #4063 (2024-08-16 04:21:04)

fix: rename ServiceName to Service in the gRPC active health check structure.
**What this PR does / why we need it**:
Renames the field `ServiceName` to `Service` in the active health check configuration structure for gRPC health checks.

**Which issue(s) this PR fixes**:
As requested in the comments in #4046 


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/envoyproxy/gateway/pull/4063?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 67.92%. Comparing base [(`27de4b1`)](https://app.codecov.io/gh/envoyproxy/gateway/commit/27de4b1e19ad56a759db9d1c8ac8f8b88c51a806?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy) to head [(`5d519f0`)](https://app.codecov.io/gh/envoyproxy/gateway/commit/5d519f0e8e2dcc2e9ca300525e908607c8aa2b0e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #4063      +/-   ##
==========================================
+ Coverage   67.90%   67.92%   +0.02%     
==========================================
  Files         187      187              
  Lines       23023    23023              
==========================================
+ Hits        15633    15639       +6     
+ Misses       6272     6269       -3     
+ Partials     1118     1115       -3     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/envoyproxy/gateway/pull/4063?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy).

liorokman: /retest

Patch:
diff --git a/api/v1alpha1/healthcheck_types.go b/api/v1alpha1/healthcheck_types.go
index d8e8339e2..990c95f14 100644
--- a/api/v1alpha1/healthcheck_types.go
+++ b/api/v1alpha1/healthcheck_types.go
@@ -169,11 +169,11 @@ type TCPActiveHealthChecker struct {
 
 // GRPCActiveHealthChecker defines the settings of the GRPC health check.
 type GRPCActiveHealthChecker struct {
-	// ServiceName to send in the health check request.
+	// Service to send in the health check request.
 	// If this is not specified, then the health check request applies to the entire
 	// server and not to a specific service.
 	// +optional
-	ServiceName *string `json:"serviceName,omitempty" yaml:"serviceName,omitempty"`
+	Service *string `json:"service,omitempty" yaml:"service,omitempty"`
 }
 
 // ActiveHealthCheckPayloadType is the type of the payload.
diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go
index af9983b64..6e9f41f77 100644
--- a/api/v1alpha1/zz_generated.deepcopy.go
+++ b/api/v1alpha1/zz_generated.deepcopy.go
@@ -2345,8 +2345,8 @@ func (in *FilterPosition) DeepCopy() *FilterPosition {
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *GRPCActiveHealthChecker) DeepCopyInto(out *GRPCActiveHealthChecker) {
 	*out = *in
-	if in.ServiceName != nil {
-		in, out := &in.ServiceName, &out.ServiceName
+	if in.Service != nil {
+		in, out := &in.Service, &out.Service
 		*out = new(string)
 		**out = **in
 	}
diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
index 6867e0285..2190e6235 100644
--- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
+++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
@@ -231,9 +231,9 @@ spec:
                           GRPC defines the configuration of the GRPC health checker.
                           It's optional, and can only be used if the specified type is GRPC.
                         properties:
-                          serviceName:
+                          service:
                             description: |-
-                              ServiceName to send in the health check request.
+                              Service to send in the health check request.
                               If this is not specified, then the health check request applies to the entire
                               server and not to a specific service.
                             type: string
diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml
index a4e83c8dc..5b88ec482 100644
--- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml
+++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml
@@ -332,9 +332,9 @@ spec:
                                     GRPC defines the configuration of the GRPC health checker.
                                     It's optional, and can only be used if the specified type is GRPC.
                                   properties:
-                                    serviceName:
+                                    service:
                                       description: |-
-                                        ServiceName to send in the health check request.
+                                        Service to send in the health check request.
                                         If this is not specified, then the health check request applies to the entire
                                         server and not to a specific service.
                                       type: string
diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml
index 99a445558..436a33314 100644
--- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml
+++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml
@@ -10595,9 +10595,9 @@ spec:
                                                       GRPC defines the configuration of the GRPC health checker.
                                                       It's optional, and can only be used if the specified type is GRPC.
                                                     properties:
-                                                      serviceName:
+                                                      service:
                                                         description: |-
-                                                          ServiceName to send in the health check request.
+                                                          Service to send in the health check request.
                                                           If this is not specified, then the health check request applies to the entire
                                                           server and not to a specific service.
                                                         type: string
@@ -11485,9 +11485,9 @@ spec:
                                                       GRPC defines the configuration of the GRPC health checker.
                                                       It's optional, and can only be used if the specified type is GRPC.
                                                     properties:
-                                                      serviceName:
+                                                      service:
                                                         description: |-
-                                                          ServiceName to send in the health check request.
+                                                          Service to send in the health check request.
                                                           If this is not specified, then the health check request applies to the entire
                                                           server and not to a specific service.
                                                         type: string
@@ -12447,9 +12447,9 @@ spec:
                                                 GRPC defines the configuration of the GRPC health checker.
                                                 It's optional, and can only be used if the specified type is GRPC.
                                               properties:
-                                                serviceName:
+                                                service:
                                                   description: |-
-                                                    ServiceName to send in the health check request.
+                                                    Service to send in the health check request.
                                                     If this is not specified, then the health check request applies to the entire
                                                     server and not to a specific service.
                                                   type: string
@@ -13349,9 +13349,9 @@ spec:
                                           GRPC defines the configuration of the GRPC health checker.
                                           It's optional, and can only be used if the specified type is GRPC.
                                         properties:
-                                          serviceName:
+                                          service:
                                             description: |-
-                                              ServiceName to send in the health check request.
+                                              Service to send in the health check request.
                                               If this is not specified, then the health check request applies to the entire
                                               server and not to a specific service.
                                             type: string
diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml
index fd6a6e893..da5eed296 100644
--- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml
+++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml
@@ -534,9 +534,9 @@ spec:
                                       GRPC defines the configuration of the GRPC health checker.
                                       It's optional, and can only be used if the specified type is GRPC.
                                     properties:
-                                      serviceName:
+                                      service:
                                         description: |-
-                                          ServiceName to send in the health check request.
+                                          Service to send in the health check request.
                                           If this is not specified, then the health check request applies to the entire
                                           server and not to a specific service.
                                         type: string
@@ -1337,9 +1337,9 @@ spec:
                                       GRPC defines the configuration of the GRPC health checker.
                                       It's optional, and can only be used if the specified type is GRPC.
                                     properties:
-                                      serviceName:
+                                      service:
                                         description: |-
-                                          ServiceName to send in the health check request.
+                                          Service to send in the health check request.
                                           If this is not specified, then the health check request applies to the entire
                                           server and not to a specific service.
                                         type: string
diff --git a/internal/gatewayapi/clustersettings.go b/internal/gatewayapi/clustersettings.go
index 2c3d8f7b7..1d5c1a3d6 100644
--- a/internal/gatewayapi/clustersettings.go
+++ b/internal/gatewayapi/clustersettings.go
@@ -428,7 +428,7 @@ func buildActiveHealthCheck(policy egv1a1.HealthCheck) *ir.ActiveHealthCheck {
 		irHC.TCP = buildTCPActiveHealthChecker(hc.TCP)
 	case egv1a1.ActiveHealthCheckerTypeGRPC:
 		irHC.GRPC = &ir.GRPCHealthChecker{
-			ServiceName: ptr.Deref(hc.GRPC, egv1a1.GRPCActiveHealthChecker{}).ServiceName,
+			Service: ptr.Deref(hc.GRPC, egv1a1.GRPCActiveHealthChecker{}).Service,
 		}
 	}
 
diff --git a/internal/ir/xds.go b/internal/ir/xds.go
index ea1d18b6c..ec3441e3b 100644
--- a/internal/ir/xds.go
+++ b/internal/ir/xds.go
@@ -2108,10 +2108,10 @@ func (h HTTPStatus) Validate() error {
 // GRPCHealthChecker defines the settings of the gRPC health check.
 // +k8s:deepcopy-gen=true
 type GRPCHealthChecker struct {
-	// ServiceName is the name of a specific service hosted by the server for
+	// Service is the name of a specific service hosted by the server for
 	// which the health check should be requested. If not specified, then the default
 	// is to send a health check request for the entire server.
-	ServiceName *string `json:"serviceName,omitempty" yaml:"serviceName,omitempty"`
+	Service *string `json:"service,omitempty" yaml:"service,omitempty"`
 }
 
 // TCPHealthChecker defines the settings of tcp health check.
diff --git a/internal/ir/zz_generated.deepcopy.go b/internal/ir/zz_generated.deepcopy.go
index 1065ddf8f..8fd979609 100644
--- a/internal/ir/zz_generated.deepcopy.go
+++ b/internal/ir/zz_generated.deepcopy.go
@@ -998,8 +998,8 @@ func (in *GRPCExtAuthService) DeepCopy() *GRPCExtAuthService {
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *GRPCHealthChecker) DeepCopyInto(out *GRPCHealthChecker) {
 	*out = *in
-	if in.ServiceName != nil {
-		in, out := &in.ServiceName, &out.ServiceName
+	if in.Service != nil {
+		in, out := &in.Service, &out.Service
 		*out = new(string)
 		**out = **in
 	}
diff --git a/internal/xds/translator/cluster.go b/internal/xds/translator/cluster.go
index e229caedc..90d005a8b 100644
--- a/internal/xds/translator/cluster.go
+++ b/internal/xds/translator/cluster.go
@@ -264,7 +264,7 @@ func buildXdsHealthCheck(healthcheck *ir.ActiveHealthCheck) []*corev3.HealthChec
 	case healthcheck.GRPC != nil:
 		hc.HealthChecker = &corev3.HealthCheck_GrpcHealthCheck_{
 			GrpcHealthCheck: &corev3.HealthCheck_GrpcHealthCheck{
-				ServiceName: ptr.Deref(healthcheck.GRPC.ServiceName, ""),
+				ServiceName: ptr.Deref(healthcheck.GRPC.Service, ""),
 			},
 		}
 	}


Test patch:
diff --git a/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.in.yaml b/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.in.yaml
index ee8720097..0ea537711 100644
--- a/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.in.yaml
+++ b/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.in.yaml
@@ -296,5 +296,5 @@ backendTrafficPolicies:
         healthyThreshold: 1
         type: GRPC
         grpc:
-          serviceName: foo-service
+          service: foo-service
 
diff --git a/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.out.yaml b/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.out.yaml
index c9bf22910..4d1cc89bc 100644
--- a/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.out.yaml
+++ b/internal/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.out.yaml
@@ -188,7 +188,7 @@ backendTrafficPolicies:
     healthCheck:
       active:
         grpc:
-          serviceName: foo-service
+          service: foo-service
         healthyThreshold: 1
         interval: 3s
         timeout: 1s
@@ -676,7 +676,7 @@ xdsIR:
           healthCheck:
             active:
               grpc:
-                serviceName: foo-service
+                service: foo-service
               healthyThreshold: 1
               interval: 3s
               timeout: 1s
diff --git a/internal/xds/translator/testdata/in/xds-ir/health-check.yaml b/internal/xds/translator/testdata/in/xds-ir/health-check.yaml
index 769a3b3dc..12f62f864 100644
--- a/internal/xds/translator/testdata/in/xds-ir/health-check.yaml
+++ b/internal/xds/translator/testdata/in/xds-ir/health-check.yaml
@@ -136,7 +136,7 @@ http:
           unhealthyThreshold: 3
           healthyThreshold: 3
           grpc:
-            serviceName: my-service
+            service: my-service
     destination:
       name: "fifth-route-dest"
       protocol: GRPC
diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md
index fa525ea82..b7d7b7607 100644
--- a/site/content/en/latest/api/extension_types.md
+++ b/site/content/en/latest/api/extension_types.md
@@ -1713,7 +1713,7 @@ _Appears in:_
 
 | Field | Type | Required | Description |
 | ---   | ---  | ---      | ---         |
-| `serviceName` | _string_ |  false  | ServiceName to send in the health check request.<br />If this is not specified, then the health check request applies to the entire<br />server and not to a specific service. |
+| `service` | _string_ |  false  | Service to send in the health check request.<br />If this is not specified, then the health check request applies to the entire<br />server and not to a specific service. |
 
 
 #### GRPCExtAuthService
diff --git a/site/content/zh/latest/api/extension_types.md b/site/content/zh/latest/api/extension_types.md
index fa525ea82..b7d7b7607 100644
--- a/site/content/zh/latest/api/extension_types.md
+++ b/site/content/zh/latest/api/extension_types.md
@@ -1713,7 +1713,7 @@ _Appears in:_
 
 | Field | Type | Required | Description |
 | ---   | ---  | ---      | ---         |
-| `serviceName` | _string_ |  false  | ServiceName to send in the health check request.<br />If this is not specified, then the health check request applies to the entire<br />server and not to a specific service. |
+| `service` | _string_ |  false  | Service to send in the health check request.<br />If this is not specified, then the health check request applies to the entire<br />server and not to a specific service. |
 
 
 #### GRPCExtAuthService