Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit 4a0688b

Browse files
author
Yevgeny Pats
committed
Add expermintal partial cpus and memory
1 parent 2301804 commit 4a0688b

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

client/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const FuzzitEndpoint = "https://app.fuzzit.dev"
14-
const Version = "v2.4.62"
14+
const Version = "v2.4.63"
1515

1616
type Target struct {
1717
Name string `firestore:"target_name"`
@@ -26,7 +26,8 @@ type Job struct {
2626
Host string `firestore:"host"`
2727
Revision string `firestore:"revision"`
2828
Branch string `firestore:"branch"`
29-
Parallelism uint16 `firestore:"parallelism"`
29+
CPUs string `firestore:"cpus"`
30+
Memory string `firestore:"memory"`
3031
EnvironmentVariables []string `firestore:"environment_variables"`
3132
Completed uint16 `firestore:"completed"`
3233
Status string `firestore:"status"`

cmd/job.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package cmd
1717

1818
import (
1919
"log"
20+
"strconv"
2021
"strings"
2122

2223
"github.com/fuzzitdev/fuzzit/v2/client"
@@ -28,6 +29,20 @@ import (
2829

2930
var newJob = client.Job{}
3031

32+
var allowedCPUs = map[string]bool{
33+
"0.1": true,
34+
"0.2": true,
35+
"0.3": true,
36+
"0.4": true,
37+
"0.5": true,
38+
"0.6": true,
39+
"0.7": true,
40+
"0.8": true,
41+
"0.9": true,
42+
"1": true,
43+
"1.0": true,
44+
}
45+
3146
var jobCmd = &cobra.Command{
3247
Use: "job [target_id] [files...]",
3348
Short: "create new fuzzing job",
@@ -41,6 +56,22 @@ var jobCmd = &cobra.Command{
4156
log.Fatalf("--engine should be either libfuzzer or jqf. Received: %s", newJob.Type)
4257
}
4358

59+
if !allowedCPUs[newJob.CPUs] {
60+
log.Fatalf("got %s cpus. CPUs can only be one of 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.0\n", newJob.CPUs)
61+
}
62+
63+
if !strings.HasSuffix(newJob.Memory, "Mi") {
64+
log.Fatalf("got %s memory. Memory should be suffixed by Mi\n", newJob.Memory)
65+
}
66+
megabytes := newJob.Memory[:len(newJob.Memory)-2]
67+
i, err := strconv.Atoi(megabytes)
68+
if err != nil {
69+
log.Fatalln(err)
70+
}
71+
if i > 2048 {
72+
log.Fatalf("got %d Mi memory. > 2048Mi memory is only supported for enterprise customers\n", i)
73+
}
74+
4475
image := client.HostToDocker[newJob.Host]
4576
if image == "" {
4677
if newJob.Host == "" {
@@ -108,7 +139,10 @@ func init() {
108139

109140
jobCmd.Flags().StringVar(&newJob.Type, "type", "fuzzing", "fuzzing/regression/local-regression")
110141
jobCmd.Flags().StringVar(&newJob.Engine, "engine", "libfuzzer", "libfuzzer/jqf")
111-
jobCmd.Flags().Uint16Var(&newJob.Parallelism, "cpus", 1, "number of cpus to use (only relevant for fuzzing job)")
142+
jobCmd.Flags().StringVar(&newJob.CPUs, "cpus", "1", "number of cpus to use (only relevant for fuzzing job)")
143+
jobCmd.Flags().StringVar(&newJob.Memory, "memory", "2048Mi", "number of cpus to use (only relevant for fuzzing job)")
144+
jobCmd.Flags().MarkHidden("memory")
145+
jobCmd.Flags().MarkHidden("cpus")
112146
jobCmd.Flags().StringVar(&newJob.Revision, "revision", revision, "Revision tag of fuzzer (populates automatically from git,travis,circleci)")
113147
jobCmd.Flags().StringVar(&newJob.Branch, "branch", branch, "Branch of the fuzzer (populates automatically from git,travis,circleci)")
114148
jobCmd.Flags().StringVar(&newJob.Host, "host", "", "docker image to use when running the fuzzer. Options: stretch-llvm8/stretch-llvm9/bionic-swift51")

0 commit comments

Comments
 (0)