Skip to content

Commit

Permalink
bugfix: Fixes timer replacement without clearing the old one present (#…
Browse files Browse the repository at this point in the history
…141)

Signed-off-by: RaviKiran Kilingar <ravikirankilingar@gmail.com>
  • Loading branch information
rkilingr authored Mar 6, 2023
1 parent 2c2375e commit 0c55063
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion controllers/healthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,9 @@ func (r *HealthCheckReconciler) watchWorkflowReschedule(ctx context.Context, req
// reschedule next run of workflow
helper := r.createSubmitWorkflowHelper(ctx, log, wfNamespace, hc)
r.TimerLock.Lock()
if t, ok := r.RepeatTimersByName[hc.GetName()]; ok {
log.Info("Stopping timer for previous workflow", "name", wfName, "stop status", t.Stop())
}
r.RepeatTimersByName[hc.GetName()] = time.AfterFunc(time.Duration(repeatAfterSec)*time.Second, helper)
r.TimerLock.Unlock()
log.Info("Rescheduled workflow for next run", "namespace", wfNamespace, "name", wfName)
Expand Down Expand Up @@ -1031,7 +1034,7 @@ func (r *HealthCheckReconciler) createServiceAccount(clientset kubernetes.Interf
return sa.Name, nil
}

//Delete a service Account
// Delete a service Account
func (r *HealthCheckReconciler) DeleteServiceAccount(clientset kubernetes.Interface, log logr.Logger, hc *activemonitorv1alpha1.HealthCheck, name string, namespace string) error {
sa, err := clientset.CoreV1().ServiceAccounts(namespace).Get(name, metav1.GetOptions{})
// If a service account already exists just re-use it
Expand Down
2 changes: 1 addition & 1 deletion controllers/healthcheck_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _ = Describe("Active-Monitor Controller", func() {
return err
}

if instance.Status.StartedAt != nil {
if instance.Status.StartedAt != nil && instance.Status.SuccessCount+instance.Status.FailedCount >= 3 {
return nil
}
return fmt.Errorf("HealthCheck is not valid")
Expand Down

0 comments on commit 0c55063

Please sign in to comment.