Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(probe): Updates http probe wait duration to ms #643

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/probe/httpprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func httpGet(probe v1alpha1.ProbeAttributes, client *http.Client, resultDetails
// it contains a timeout per iteration of retry. if the timeout expires without success then it will go to next try
// for a timeout, it will run the command, if it fails wait for the interval and again execute the command until timeout expires
if err := retry.Times(uint(getAttempts(probe.RunProperties.Attempt, probe.RunProperties.Retry))).
Wait(time.Duration(probe.RunProperties.Interval) * time.Second).
Wait(time.Duration(probe.RunProperties.Interval) * time.Millisecond).
Try(func(attempt uint) error {
// getting the response from the given url
resp, err := client.Get(probe.HTTPProbeInputs.URL)
Expand Down Expand Up @@ -152,7 +152,7 @@ func httpPost(probe v1alpha1.ProbeAttributes, client *http.Client, resultDetails
// it contains a timeout per iteration of retry. if the timeout expires without success then it will go to next try
// for a timeout, it will run the command, if it fails wait for the interval and again execute the command until timeout expires
if err := retry.Times(uint(getAttempts(probe.RunProperties.Attempt, probe.RunProperties.Retry))).
Wait(time.Duration(probe.RunProperties.Interval) * time.Second).
Wait(time.Duration(probe.RunProperties.Interval) * time.Millisecond).
Try(func(attempt uint) error {
resp, err := client.Post(probe.HTTPProbeInputs.URL, probe.HTTPProbeInputs.Method.Post.ContentType, strings.NewReader(body))
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions pkg/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"bytes"
"context"
"fmt"
"html/template"
"strings"

"github.com/kyokomi/emoji"
"github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
"github.com/litmuschaos/litmus-go/pkg/cerrors"
Expand All @@ -12,9 +15,7 @@ import (
"github.com/litmuschaos/litmus-go/pkg/types"
"github.com/palantir/stacktrace"
"github.com/sirupsen/logrus"
"html/template"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
)

var err error
Expand Down Expand Up @@ -223,6 +224,7 @@ func markedVerdictInEnd(err error, resultDetails *types.ResultDetails, probe v1a
return nil
}

// getProbeByName returns the probe details of a probe given its name
func getProbeByName(name string, probeDetails []*types.ProbeDetails) *types.ProbeDetails {
for _, p := range probeDetails {
if p.Name == name {
Expand Down