Skip to content

Commit

Permalink
add PostRun for workloads
Browse files Browse the repository at this point in the history
os.exit() is removed from kube-burner helpers Run() method with
the PR kube-burner/kube-burner#704

kube-burner-ocp workloads now explicitly define PostRun and call
os.exit().

This change helps workloads to do any cleanup as part of PostRun
once kube-burner finishes execution.

Signed-off-by: venkataanil <[email protected]>
  • Loading branch information
venkataanil committed Oct 9, 2024
1 parent ee6426d commit ee0143a
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 12 deletions.
1 change: 1 addition & 0 deletions cluster-density.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func NewClusterDensity(wh *workloads.WorkloadHelper, variant string) *cobra.Comm
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
Expand Down
7 changes: 6 additions & 1 deletion crd-scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
func NewCrdScale(wh *workloads.WorkloadHelper) *cobra.Command {
var iterations int
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: "crd-scale",
Short: "Runs crd-scale workload",
Expand All @@ -35,7 +36,11 @@ func NewCrdScale(wh *workloads.WorkloadHelper) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().IntVar(&iterations, "iterations", 0, "Number of CRDs to create")
Expand Down
7 changes: 6 additions & 1 deletion custom-workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func CustomWorkload(wh *workloads.WorkloadHelper) *cobra.Command {
var churnDelay, churnDuration, podReadyThreshold time.Duration
var configFile, churnDeletionStrategy string
var iterations, churnPercent, churnCycles, iterationsPerNamespace, podsPerNode int
var rc int
cmd := &cobra.Command{
Use: "init",
Short: "Runs custom workload",
Expand Down Expand Up @@ -67,7 +68,11 @@ func CustomWorkload(wh *workloads.WorkloadHelper) *cobra.Command {
log.Fatalf("Error reading custom configuration file: %v", err.Error())
}
configFileName := strings.Split(configFile, ".")[0]
wh.Run(configFileName)
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().StringVarP(&configFile, "config", "c", "", "Config file path or url")
Expand Down
7 changes: 6 additions & 1 deletion egressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func NewEgressIP(wh *workloads.WorkloadHelper, variant string) *cobra.Command {
var externalServerIP string
var podReadyThreshold time.Duration
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: variant,
Short: fmt.Sprintf("Runs %v workload", variant),
Expand All @@ -162,7 +163,11 @@ func NewEgressIP(wh *workloads.WorkloadHelper, variant string) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().DurationVar(&podReadyThreshold, "pod-ready-threshold", 2*time.Minute, "Pod ready timeout threshold")
Expand Down
2 changes: 1 addition & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewIndex(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata) *cobr
Long: "If no other indexer is specified, local indexer is used by default",
SilenceUsage: true,
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("👋 Exiting kube-burner ", uuid)
log.Info("Exiting kube-burner-ocp ", uuid)
os.Exit(rc)
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down
7 changes: 6 additions & 1 deletion networkpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewNetworkPolicy(wh *workloads.WorkloadHelper, variant string) *cobra.Comma
var churnDelay, churnDuration time.Duration
var churnDeletionStrategy string
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: variant,
Short: fmt.Sprintf("Runs %v workload", variant),
Expand All @@ -44,7 +45,11 @@ func NewNetworkPolicy(wh *workloads.WorkloadHelper, variant string) *cobra.Comma
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().IntVar(&iterations, "iterations", 0, fmt.Sprintf("%v iterations", variant))
Expand Down
7 changes: 6 additions & 1 deletion node-density-cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewNodeDensityCNI(wh *workloads.WorkloadHelper) *cobra.Command {
var podReadyThreshold time.Duration
var iterationsPerNamespace int
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: "node-density-cni",
Short: "Runs node-density-cni workload",
Expand All @@ -51,7 +52,11 @@ func NewNodeDensityCNI(wh *workloads.WorkloadHelper) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().DurationVar(&podReadyThreshold, "pod-ready-threshold", 1*time.Minute, "Pod ready timeout threshold")
Expand Down
7 changes: 6 additions & 1 deletion node-density-heavy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func NewNodeDensityHeavy(wh *workloads.WorkloadHelper) *cobra.Command {
var namespacedIterations bool
var iterationsPerNamespace int
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: "node-density-heavy",
Short: "Runs node-density-heavy workload",
Expand All @@ -51,7 +52,11 @@ func NewNodeDensityHeavy(wh *workloads.WorkloadHelper) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().DurationVar(&podReadyThreshold, "pod-ready-threshold", 2*time.Minute, "Pod ready timeout threshold")
Expand Down
7 changes: 6 additions & 1 deletion node-density.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewNodeDensity(wh *workloads.WorkloadHelper) *cobra.Command {
var podReadyThreshold time.Duration
var containerImage string
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: "node-density",
Short: "Runs node-density workload",
Expand All @@ -47,7 +48,11 @@ func NewNodeDensity(wh *workloads.WorkloadHelper) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().IntVar(&podsPerNode, "pods-per-node", 245, "Pods per node")
Expand Down
7 changes: 6 additions & 1 deletion pvc-density.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewPVCDensity(wh *workloads.WorkloadHelper) *cobra.Command {
var storageProvisioners, metricsProfiles []string
var claimSize string
var containerImage string
var rc int
provisioner := "aws"

cmd := &cobra.Command{
Expand All @@ -65,7 +66,11 @@ func NewPVCDensity(wh *workloads.WorkloadHelper) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}

Expand Down
7 changes: 6 additions & 1 deletion udn-density-l3-pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewUDNDensityL3Pods(wh *workloads.WorkloadHelper) *cobra.Command {
var churnDelay, churnDuration, podReadyThreshold time.Duration
var churnDeletionStrategy string
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: "udn-density-l3-pods",
Short: "Runs node-density-udn workload",
Expand All @@ -47,7 +48,11 @@ func NewUDNDensityL3Pods(wh *workloads.WorkloadHelper) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().BoolVar(&churn, "churn", true, "Enable churning")
Expand Down
7 changes: 6 additions & 1 deletion web-burner.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewWebBurner(wh *workloads.WorkloadHelper, variant string) *cobra.Command {
var bridge string
var podReadyThreshold time.Duration
var metricsProfiles []string
var rc int
cmd := &cobra.Command{
Use: variant,
Short: fmt.Sprintf("Runs %v workload", variant),
Expand All @@ -46,7 +47,11 @@ func NewWebBurner(wh *workloads.WorkloadHelper, variant string) *cobra.Command {
},
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
wh.Run(cmd.Name())
rc = wh.Run(cmd.Name())
},
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("Exiting kube-burner-ocp ", wh.Config.UUID)
os.Exit(rc)
},
}
cmd.Flags().DurationVar(&podReadyThreshold, "pod-ready-threshold", 2*time.Minute, "Pod ready timeout threshold")
Expand Down
2 changes: 1 addition & 1 deletion workers-scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewWorkersScale(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata
Long: "If no other indexer is specified, local indexer is used by default",
SilenceUsage: true,
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("👋 Exiting kube-burner ", uuid)
log.Info("Exiting kube-burner-ocp ", uuid)
os.Exit(rc)
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down

0 comments on commit ee0143a

Please sign in to comment.