Skip to content

Commit

Permalink
fix: Delete all trials
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
gaocegege committed Jul 28, 2020
1 parent 6e32f85 commit 2bb2957
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/controller.v1alpha3/experiment/experiment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package experiment

import (
"context"
"fmt"
"sort"

"github.com/spf13/viper"
Expand Down Expand Up @@ -368,9 +367,12 @@ func (r *ReconcileExperiment) deleteTrials(instance *experimentsv1alpha3.Experim
})

expected := int(expectedDeletions)
if len(trialSlice) < expected {
return fmt.Errorf("Expected to delete %d trials, but got %d trials",
expected, len(trialSlice))
actual := len(trialSlice)
// If the number of trials < expected, we delete all we have.
if actual < expected {
logger.Info("deleteTrials does not find enough trials, we will delete all trials instead",
"expectedDeletions", expected, "trials", actual)
expected = actual
}
for i := 0; i < expected; i++ {
if err := r.Delete(context.TODO(), &trialSlice[i]); err != nil {
Expand Down

0 comments on commit 2bb2957

Please sign in to comment.