Skip to content

Commit 1ec871a

Browse files
authored
chore(httpProbe): Remove responseTimeout field, use the global probeTimeout field instead (litmuschaos#574)
Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io> Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io>
1 parent 50920be commit 1ec871a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/aws/aws-sdk-go v1.38.59
1010
github.com/containerd/cgroups v1.0.1
1111
github.com/kyokomi/emoji v2.2.4+incompatible
12-
github.com/litmuschaos/chaos-operator v0.0.0-20220927085333-f70f80b9e75f
12+
github.com/litmuschaos/chaos-operator v0.0.0-20220929101337-868b2827f820
1313
github.com/pkg/errors v0.9.1
1414
github.com/sirupsen/logrus v1.7.0
1515
github.com/spf13/cobra v1.1.1

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9
767767
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
768768
github.com/lightstep/lightstep-tracer-go v0.18.0/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
769769
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
770-
github.com/litmuschaos/chaos-operator v0.0.0-20220927085333-f70f80b9e75f h1:+XNBeF13Adana2gfOIMsisLsA8QtR6H1/AOk78/ouWQ=
771-
github.com/litmuschaos/chaos-operator v0.0.0-20220927085333-f70f80b9e75f/go.mod h1:CJGiHqC06PQkIBySk/JroB7B2zFebDbkhQ1A6ZbYmHA=
770+
github.com/litmuschaos/chaos-operator v0.0.0-20220929101337-868b2827f820 h1:xMlb6eMbWzdR/2IB6F095p0NDadccZIkiovJBE9fg9I=
771+
github.com/litmuschaos/chaos-operator v0.0.0-20220929101337-868b2827f820/go.mod h1:CJGiHqC06PQkIBySk/JroB7B2zFebDbkhQ1A6ZbYmHA=
772772
github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c/go.mod h1:DsbHGNUq/78NZozWVVI9Q6eBei4I+JjlkkD5aibJ3MQ=
773773
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
774774
github.com/lovoo/gcloud-opentracing v0.3.0/go.mod h1:ZFqk2y38kMDDikZPAK7ynTTGuyt17nSPdS3K5e+ZTBY=

pkg/probe/httpprobe.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func triggerHTTPProbe(probe v1alpha1.ProbeAttributes, resultDetails *types.Resul
5858
method := getHTTPMethodType(probe.HTTPProbeInputs.Method)
5959

6060
// initialize simple http client with default attributes
61-
timeout := time.Duration(probe.HTTPProbeInputs.ResponseTimeout) * time.Millisecond
61+
timeout := time.Duration(probe.RunProperties.ProbeTimeout) * time.Millisecond
6262
client := &http.Client{Timeout: timeout}
6363
// impose properties to http client with cert check disabled
6464
if probe.HTTPProbeInputs.InsecureSkipVerify {
@@ -75,7 +75,7 @@ func triggerHTTPProbe(probe v1alpha1.ProbeAttributes, resultDetails *types.Resul
7575
"URL": probe.HTTPProbeInputs.URL,
7676
"Criteria": probe.HTTPProbeInputs.Method.Get.Criteria,
7777
"ResponseCode": probe.HTTPProbeInputs.Method.Get.ResponseCode,
78-
"ResponseTimeout": probe.HTTPProbeInputs.ResponseTimeout,
78+
"ResponseTimeout": probe.RunProperties.ProbeTimeout,
7979
})
8080
if err := httpGet(probe, client, resultDetails); err != nil {
8181
return err
@@ -87,7 +87,7 @@ func triggerHTTPProbe(probe v1alpha1.ProbeAttributes, resultDetails *types.Resul
8787
"Body": probe.HTTPProbeInputs.Method.Post.Body,
8888
"BodyPath": probe.HTTPProbeInputs.Method.Post.BodyPath,
8989
"ContentType": probe.HTTPProbeInputs.Method.Post.ContentType,
90-
"ResponseTimeout": probe.HTTPProbeInputs.ResponseTimeout,
90+
"ResponseTimeout": probe.RunProperties.ProbeTimeout,
9191
})
9292
if err := httpPost(probe, client, resultDetails); err != nil {
9393
return err
@@ -111,9 +111,8 @@ func httpGet(probe v1alpha1.ProbeAttributes, client *http.Client, resultDetails
111111
// it contains a timeout per iteration of retry. if the timeout expires without success then it will go to next try
112112
// for a timeout, it will run the command, if it fails wait for the interval and again execute the command until timeout expires
113113
return retry.Times(uint(probe.RunProperties.Retry)).
114-
Timeout(int64(probe.RunProperties.ProbeTimeout)).
115114
Wait(time.Duration(probe.RunProperties.Interval) * time.Second).
116-
TryWithTimeout(func(attempt uint) error {
115+
Try(func(attempt uint) error {
117116
// getting the response from the given url
118117
resp, err := client.Get(probe.HTTPProbeInputs.URL)
119118
if err != nil {
@@ -146,9 +145,8 @@ func httpPost(probe v1alpha1.ProbeAttributes, client *http.Client, resultDetails
146145
// it contains a timeout per iteration of retry. if the timeout expires without success then it will go to next try
147146
// for a timeout, it will run the command, if it fails wait for the interval and again execute the command until timeout expires
148147
return retry.Times(uint(probe.RunProperties.Retry)).
149-
Timeout(int64(probe.RunProperties.ProbeTimeout)).
150148
Wait(time.Duration(probe.RunProperties.Interval) * time.Second).
151-
TryWithTimeout(func(attempt uint) error {
149+
Try(func(attempt uint) error {
152150
resp, err := client.Post(probe.HTTPProbeInputs.URL, probe.HTTPProbeInputs.Method.Post.ContentType, strings.NewReader(body))
153151
if err != nil {
154152
return err

0 commit comments

Comments
 (0)