Repository: kubernetes-sigs/cloud-provider-azure
Pull request #3658 (2023-03-27 05:08:43)

[release-1.24] Deprecate numberOfProbes and adopt ProbeThreshold to address a probe issue in nrp
This is an automated cherry-pick of #3623

/assign MartinForReal

```release-note
Deprecate numberOfProbes and adopt ProbeThreshold in network api to address a probe issue in nrp
```


Patch:
diff --git a/pkg/provider/azure_loadbalancer.go b/pkg/provider/azure_loadbalancer.go
index 4abc010f6..f2818b537 100644
--- a/pkg/provider/azure_loadbalancer.go
+++ b/pkg/provider/azure_loadbalancer.go
@@ -2260,7 +2260,7 @@ func (az *Cloud) buildHealthProbeRulesForPort(serviceManifest *v1.Service, port
 		return nil, fmt.Errorf("total probe should be less than 120, please adjust interval and number of probe accordingly")
 	}
 	properties.IntervalInSeconds = probeInterval
-	properties.NumberOfProbes = numberOfProbes
+	properties.ProbeThreshold = numberOfProbes
 	probe := &network.Probe{
 		Name:                  &lbrule,
 		ProbePropertiesFormat: properties,
@@ -2296,7 +2296,7 @@ func (az *Cloud) getExpectedLBRules(
 				Protocol:          network.ProbeProtocolHTTP,
 				Port:              pointer.Int32(podPresencePort),
 				IntervalInSeconds: pointer.Int32(consts.HealthProbeDefaultProbeInterval),
-				NumberOfProbes:    pointer.Int32(consts.HealthProbeDefaultNumOfProbe),
+				ProbeThreshold:    pointer.Int32(consts.HealthProbeDefaultNumOfProbe),
 			},
 		}
 		expectedProbes = append(expectedProbes, *nodeEndpointHealthprobe)
@@ -3259,7 +3259,7 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
 			strings.EqualFold(string(existingProbe.Protocol), string(probe.Protocol)) &&
 			strings.EqualFold(pointer.StringDeref(existingProbe.RequestPath, ""), pointer.StringDeref(probe.RequestPath, "")) &&
 			pointer.Int32Deref(existingProbe.IntervalInSeconds, 0) == pointer.Int32Deref(probe.IntervalInSeconds, 0) &&
-			pointer.Int32Deref(existingProbe.NumberOfProbes, 0) == pointer.Int32Deref(probe.NumberOfProbes, 0) {
+			pointer.Int32Deref(existingProbe.ProbeThreshold, 0) == pointer.Int32Deref(probe.ProbeThreshold, 0) {
 			return true
 		}
 	}


Test patch:
diff --git a/pkg/provider/azure_loadbalancer_test.go b/pkg/provider/azure_loadbalancer_test.go
index be0411419..e6e5be509 100644
--- a/pkg/provider/azure_loadbalancer_test.go
+++ b/pkg/provider/azure_loadbalancer_test.go
@@ -2654,7 +2654,7 @@ func getTestProbe(protocol, path string, interval, servicePort, probePort, numOf
 			Protocol:          network.ProbeProtocol(protocol),
 			Port:              probePort,
 			IntervalInSeconds: interval,
-			NumberOfProbes:    numOfProbe,
+			ProbeThreshold:    numOfProbe,
 		},
 	}
 	if (strings.EqualFold(protocol, "Http") || strings.EqualFold(protocol, "Https")) && len(strings.TrimSpace(path)) > 0 {
@@ -2799,7 +2799,7 @@ func getTestLoadBalancer(name, rgName, clusterName, identifier *string, service
 						Port:              pointer.Int32(10080),
 						Protocol:          network.ProbeProtocolTCP,
 						IntervalInSeconds: pointer.Int32(5),
-						NumberOfProbes:    pointer.Int32(2),
+						ProbeThreshold:    pointer.Int32(2),
 					},
 				},
 			},
@@ -3072,7 +3072,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
 				RequestPath:       pointer.String("/healthz"),
 				Protocol:          network.ProbeProtocolHTTP,
 				IntervalInSeconds: pointer.Int32(5),
-				NumberOfProbes:    pointer.Int32(2),
+				ProbeThreshold:    pointer.Int32(2),
 			},
 		},
 	}
@@ -3100,7 +3100,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
 				Port:              pointer.Int32(10080),
 				Protocol:          network.ProbeProtocolTCP,
 				IntervalInSeconds: pointer.Int32(5),
-				NumberOfProbes:    pointer.Int32(2),
+				ProbeThreshold:    pointer.Int32(2),
 			},
 		},
 	}
diff --git a/tests/e2e/network/service_annotations.go b/tests/e2e/network/service_annotations.go
index ad4f0e127..1b0db24b6 100644
--- a/tests/e2e/network/service_annotations.go
+++ b/tests/e2e/network/service_annotations.go
@@ -567,8 +567,8 @@ var _ = Describe("Service with annotation", Label(utils.TestSuiteLabelServiceAnn
 		By("Validating health probe configs")
 		var numberOfProbes *int32
 		for _, probe := range targetProbes {
-			if probe.NumberOfProbes != nil {
-				numberOfProbes = probe.NumberOfProbes
+			if probe.ProbeThreshold != nil {
+				numberOfProbes = probe.ProbeThreshold
 			}
 		}
 		Expect(*numberOfProbes).To(Equal(int32(3)))
@@ -663,8 +663,8 @@ var _ = Describe("Service with annotation", Label(utils.TestSuiteLabelServiceAnn
 		var numberOfProbes *int32
 		var intervalInSeconds *int32
 		for _, probe := range targetProbes {
-			if probe.NumberOfProbes != nil {
-				numberOfProbes = probe.NumberOfProbes
+			if probe.ProbeThreshold != nil {
+				numberOfProbes = probe.ProbeThreshold
 			}
 			if probe.IntervalInSeconds != nil {
 				intervalInSeconds = probe.IntervalInSeconds