From a24e526eaefed22750c139ad17aaf4c3a273d15d Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Wed, 14 Jun 2023 14:14:37 +0800 Subject: [PATCH] chore: update checkrole method from curl to httpget (#3776) --- internal/controller/component/probe_utils.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/internal/controller/component/probe_utils.go b/internal/controller/component/probe_utils.go index f7e66cf3e51..f23d15bc0a2 100644 --- a/internal/controller/component/probe_utils.go +++ b/internal/controller/component/probe_utils.go @@ -38,7 +38,7 @@ import ( const ( // http://localhost:/v1.0/bindings/ - checkRoleURIFormat = "http://localhost:%s/v1.0/bindings/%s" + checkRoleURIFormat = "/v1.0/bindings/%s?operation=checkRole" checkRunningURIFormat = "/v1.0/bindings/%s?operation=checkRunning" checkStatusURIFormat = "/v1.0/bindings/%s?operation=checkStatus" ) @@ -188,16 +188,11 @@ func buildRoleProbeContainer(characterType string, roleChangedContainer *corev1. roleChangedContainer.Name = constant.RoleProbeContainerName probe := roleChangedContainer.ReadinessProbe bindingType := strings.ToLower(characterType) - svcPort := strconv.Itoa(probeSvcHTTPPort) - roleObserveURI := fmt.Sprintf(checkRoleURIFormat, svcPort, bindingType) - probe.Exec.Command = []string{ - "curl", "-X", "POST", - "--max-time", strconv.Itoa(int(probeSetting.TimeoutSeconds)), - "--fail-with-body", "--silent", - "-H", "Content-ComponentDefRef: application/json", - roleObserveURI, - "-d", "{\"operation\": \"checkRole\", \"metadata\":{\"sql\":\"\"}}", - } + httpGet := &corev1.HTTPGetAction{} + httpGet.Path = fmt.Sprintf(checkRoleURIFormat, bindingType) + httpGet.Port = intstr.FromInt(probeSvcHTTPPort) + probe.Exec = nil + probe.HTTPGet = httpGet probe.PeriodSeconds = probeSetting.PeriodSeconds probe.TimeoutSeconds = probeSetting.TimeoutSeconds probe.FailureThreshold = probeSetting.FailureThreshold