mirror of https://github.com/k3s-io/k3s
Merge pull request #13789 from socaa/resource-consumer-memory
Auto commit by PR queue botpull/6/head
commit
08fbe2bc10
|
@ -104,8 +104,7 @@ func (handler ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, q
|
||||||
http.Error(w, incorrectFunctionArgument, http.StatusBadRequest)
|
http.Error(w, incorrectFunctionArgument, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ConsumeMem(megabytes, durationSec)
|
go ConsumeMem(megabytes, durationSec)
|
||||||
fmt.Fprintln(w, "Warning: not implemented!")
|
|
||||||
fmt.Fprintln(w, consumeMemAddress[1:])
|
fmt.Fprintln(w, consumeMemAddress[1:])
|
||||||
fmt.Fprintln(w, megabytes, megabytesQuery)
|
fmt.Fprintln(w, megabytes, megabytesQuery)
|
||||||
fmt.Fprintln(w, durationSec, durationSecQuery)
|
fmt.Fprintln(w, durationSec, durationSecQuery)
|
||||||
|
|
|
@ -20,9 +20,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const consumeCPUBinary = "./consume-cpu/consume-cpu"
|
const (
|
||||||
|
consumeCPUBinary = "./consume-cpu/consume-cpu"
|
||||||
|
consumeMemBinary = "stress"
|
||||||
|
)
|
||||||
|
|
||||||
func ConsumeCPU(millicores int, durationSec int) {
|
func ConsumeCPU(millicores int, durationSec int) {
|
||||||
log.Printf("ConsumeCPU millicores: %v, durationSec: %v", millicores, durationSec)
|
log.Printf("ConsumeCPU millicores: %v, durationSec: %v", millicores, durationSec)
|
||||||
|
@ -35,7 +39,11 @@ func ConsumeCPU(millicores int, durationSec int) {
|
||||||
|
|
||||||
func ConsumeMem(megabytes int, durationSec int) {
|
func ConsumeMem(megabytes int, durationSec int) {
|
||||||
log.Printf("ConsumeMem megabytes: %v, durationSec: %v", megabytes, durationSec)
|
log.Printf("ConsumeMem megabytes: %v, durationSec: %v", megabytes, durationSec)
|
||||||
// not implemented
|
megabytesString := strconv.Itoa(megabytes) + "M"
|
||||||
|
durationSecString := strconv.Itoa(durationSec)
|
||||||
|
// creating new consume memory process
|
||||||
|
consumeMem := exec.Command(consumeMemBinary, "-m", "1", "--vm-bytes", megabytesString, "--vm-hang", "0", "-t", durationSecString)
|
||||||
|
consumeMem.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCurrentStatus() {
|
func GetCurrentStatus() {
|
||||||
|
|
Loading…
Reference in New Issue