mirror of https://github.com/chaos-mesh/chaosd.git
Merge 345a4788ac into bc039aa483
This commit is contained in:
commit
aadf79c896
|
|
@ -79,6 +79,7 @@ func NewStressMemCommand(dep fx.Option, options *core.StressCommand) *cobra.Comm
|
||||||
|
|
||||||
cmd.Flags().StringVarP(&options.Size, "size", "s", "", "Size specifies N bytes consumed per vm worker, default is the total available memory. One can specify the size as % of total available memory or in units of B, KB/KiB, MB/MiB, GB/GiB, TB/TiB..")
|
cmd.Flags().StringVarP(&options.Size, "size", "s", "", "Size specifies N bytes consumed per vm worker, default is the total available memory. One can specify the size as % of total available memory or in units of B, KB/KiB, MB/MiB, GB/GiB, TB/TiB..")
|
||||||
cmd.Flags().StringSliceVarP(&options.Options, "options", "o", []string{}, "extend stress-ng options.")
|
cmd.Flags().StringSliceVarP(&options.Options, "options", "o", []string{}, "extend stress-ng options.")
|
||||||
|
cmd.Flags().IntVar(&options.OOMScoreAdj, "oom-score-adj", 0, "OOMScoreAdj specifies the oom_score_adj value for the memory stress process. The default is 0.")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ type StressCommand struct {
|
||||||
Size string `json:"size,omitempty"`
|
Size string `json:"size,omitempty"`
|
||||||
Options []string `json:"options,omitempty"`
|
Options []string `json:"options,omitempty"`
|
||||||
StressngPid int32 `json:"stress-ng-pid,omitempty"`
|
StressngPid int32 `json:"stress-ng-pid,omitempty"`
|
||||||
|
OOMScoreAdj int `json:"oom-score-adj,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ AttackConfig = &StressCommand{}
|
var _ AttackConfig = &StressCommand{}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ func (stressAttack) Attack(options core.AttackConfig, _ Environment) (err error)
|
||||||
},
|
},
|
||||||
Size: attack.Size,
|
Size: attack.Size,
|
||||||
Options: attack.Options,
|
Options: attack.Options,
|
||||||
|
OOMScoreAdj: attack.OOMScoreAdj,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,6 +89,7 @@ func (stressAttack) Attack(options core.AttackConfig, _ Environment) (err error)
|
||||||
log.Info("stressors normalize", zap.String("arguments", stressorsStr))
|
log.Info("stressors normalize", zap.String("arguments", stressorsStr))
|
||||||
|
|
||||||
cmd := bpm.DefaultProcessBuilder(stressorTool, strings.Fields(stressorsStr)...).
|
cmd := bpm.DefaultProcessBuilder(stressorTool, strings.Fields(stressorsStr)...).
|
||||||
|
SetOOMScoreAdj(attack.OOMScoreAdj).
|
||||||
Build(context.Background())
|
Build(context.Background())
|
||||||
|
|
||||||
// Build will set SysProcAttr.Pdeathsig = syscall.SIGTERM, and so stress-ng will exit while chaosd exit
|
// Build will set SysProcAttr.Pdeathsig = syscall.SIGTERM, and so stress-ng will exit while chaosd exit
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue