Skip to content

Commit

Permalink
Churning improvements
Browse files Browse the repository at this point in the history
Improve churning code and increase churning delay

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Dec 14, 2022
1 parent 9806467 commit a3f57c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pkg/burner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,23 @@ func createRequest(gvr schema.GroupVersionResource, ns string, obj *unstructured
func (ex *Executor) RunCreateJobWithChurn() {
var err error
log.Info("Starting to Churn job")
log.Infof("Churn Duration: %v", ex.Config.ChurnDuration)
log.Infof("Churn Percent: %v", ex.Config.ChurnPercent)
log.Infof("Churn Delay: %v", ex.Config.ChurnDelay)
log.Infof("Churn duration: %v", ex.Config.ChurnDuration)
log.Infof("Churn percent: %v", ex.Config.ChurnPercent)
log.Infof("Churn delay: %v", ex.Config.ChurnDelay)
// Determine the number of job iterations to churn (min 1)
numToChurn := int(math.Max(float64(ex.Config.ChurnPercent*ex.Config.JobIterations/100), 1))
now := time.Now().UTC()
// Create timer for the churn duration
timer := time.After(ex.Config.ChurnDuration)
// Patch to label namespaces for deletion
delPatch := []byte(`[{"op":"add","path":"/metadata/labels","value":{"churndelete":"delete"}}]`)

churnComplete:
for {
select {
case <-timer:
log.Info("Churn job complete")
break churnComplete
return
default:
log.Debug("Next churn loop")
log.Infof("Next churn loop, workload churning started %v ago", time.Since(now))
}
// Max amount of churn is 100% of namespaces
randStart := 1
Expand All @@ -286,6 +285,7 @@ churnComplete:
log.Info("Re-creating deleted objects")
// Re-create objects that were deleted
ex.RunCreateJob(randStart, numToChurn+randStart-1)
log.Infof("Sleeping for %v", ex.Config.ChurnDelay)
time.Sleep(ex.Config.ChurnDelay)
}
}
2 changes: 1 addition & 1 deletion pkg/workloads/cluster-density.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewClusterDensity(wh *WorkloadHelper) *cobra.Command {
cmd.Flags().IntVar(&iterations, "iterations", 0, "Cluster-density iterations")
cmd.Flags().BoolVar(&churn, "churn", true, "Enable churning")
cmd.Flags().DurationVar(&churnDuration, "churn-duration", 1*time.Hour, "Churn duration")
cmd.Flags().DurationVar(&churnDelay, "churn-delay", 30*time.Second, "Time to wait between each churn")
cmd.Flags().DurationVar(&churnDelay, "churn-delay", 2*time.Minute, "Time to wait between each churn")
cmd.Flags().IntVar(&churnPercent, "churn-percent", 10, "Percentage of job iterations that kube-burner will churn each round")
cmd.Flags().BoolVar(&extract, "extract", false, "Extract workload in the current directory")
cmd.MarkFlagRequired("iterations")
Expand Down

0 comments on commit a3f57c2

Please sign in to comment.