Skip to content

Commit

Permalink
[probes] Return an error if interval is smaller than timeout (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
manugarg committed Oct 9, 2023
1 parent 5cb8096 commit e85d339
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions probes/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func BuildProbeOptions(p *configpb.ProbeDef, ldLister endpoint.Lister, globalTar
}
}

if intervalDuration < timeoutDuration && p.GetType() != configpb.ProbeDef_UDP {
return nil, fmt.Errorf("interval (%v) cannot be smaller than timeout (%v)", intervalDuration, timeoutDuration)
}

if p.GetNegativeTest() && !negativeTestSupported[p.GetType()] {
return nil, fmt.Errorf("negative_test is not supported by %s probes", p.GetType().String())
}
Expand Down
2 changes: 1 addition & 1 deletion probes/options/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestStatsExportInterval(t *testing.T) {
name: "Timeout bigger than intervalMsec",
intervalMsec: 10,
timeoutMsec: 12,
want: 12,
wantError: true,
},
{
name: "Interval and timeout less than default",
Expand Down

0 comments on commit e85d339

Please sign in to comment.