Skip to content

Commit

Permalink
Adds HasProbeCompleted check for onChaos
Browse files Browse the repository at this point in the history
Signed-off-by: nagesh bansal <[email protected]>
  • Loading branch information
Nageshbansal committed Dec 20, 2023
1 parent e35d355 commit b9f0187
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/probe/cmdprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,20 @@ func triggerInlineOnChaosCmdProbe(probe v1alpha1.ProbeAttributes, clients client

var endTime <-chan time.Time
timeDelay := time.Duration(duration) * time.Second

endTime = time.After(timeDelay)
// it trigger the inline cmd probe for the entire duration of chaos and it fails, if any err encounter
// it marked the error for the probes, if any
loop:
for {
endTime = time.After(timeDelay)
select {
case <-endTime:
log.Infof("[Chaos]: Time is up for the %v probe", probe.Name)
endTime = nil
for index := range chaosresult.ProbeDetails {
if chaosresult.ProbeDetails[index].Name == probe.Name {
chaosresult.ProbeDetails[index].HasProbeCompleted = true
}
}
break loop
default:
// record the error inside the probeDetails, we are maintaining a dedicated variable for the err, inside probeDetails
Expand Down Expand Up @@ -449,6 +453,11 @@ loop:
case <-endTime:
log.Infof("[Chaos]: Time is up for the %v probe", probe.Name)
endTime = nil
for index := range chaosresult.ProbeDetails {
if chaosresult.ProbeDetails[index].Name == probe.Name {
chaosresult.ProbeDetails[index].HasProbeCompleted = true
}
}
break loop
default:
// record the error inside the probeDetails, we are maintaining a dedicated variable for the err, inside probeDetails
Expand Down
5 changes: 5 additions & 0 deletions pkg/probe/httpprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ loop:
case <-endTime:
log.Infof("[Chaos]: Time is up for the %v probe", probe.Name)
endTime = nil
for index := range chaosresult.ProbeDetails {
if chaosresult.ProbeDetails[index].Name == probe.Name {
chaosresult.ProbeDetails[index].HasProbeCompleted = true
}
}
break loop
default:
err = triggerHTTPProbe(probe, chaosresult)
Expand Down
5 changes: 5 additions & 0 deletions pkg/probe/k8sprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ loop:
select {
case <-endTime:
log.Infof("[Chaos]: Time is up for the %v probe", probe.Name)
for index := range chaosresult.ProbeDetails {
if chaosresult.ProbeDetails[index].Name == probe.Name {
chaosresult.ProbeDetails[index].HasProbeCompleted = true
}
}
break loop
default:
err = triggerK8sProbe(probe, clients, chaosresult)
Expand Down
5 changes: 5 additions & 0 deletions pkg/probe/promProbe.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ loop:
select {
case <-endTime:
log.Infof("[Chaos]: Time is up for the %v probe", probe.Name)
for index := range chaosresult.ProbeDetails {
if chaosresult.ProbeDetails[index].Name == probe.Name {
chaosresult.ProbeDetails[index].HasProbeCompleted = true
}
}
endTime = nil
break loop
default:
Expand Down

0 comments on commit b9f0187

Please sign in to comment.