From a9fab5b70aa2949e18428ba0624fab89dfa7ef78 Mon Sep 17 00:00:00 2001 From: Alexander Jung Date: Sun, 20 Dec 2020 18:50:52 +0100 Subject: [PATCH] cmd/run,job/job: Pass runtime configuration Signed-off-by: Alexander Jung --- cmd/run.go | 16 ++++++++-------- job/job.go | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 47900c2..ae955b9 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -79,14 +79,6 @@ func init() { // doRunCmd func doRunCmd(cmd *cobra.Command, args []string) { - j, err := job.NewJob(args[0]) - if err != nil { - log.Fatalf("Could not read configuration: %s", err) - os.Exit(1) - } - - setupInterruptHandler() - // Determine CPU sets cpus, err := parseCpuSets(runConfig.CpuSets) if err != nil { @@ -94,6 +86,14 @@ func doRunCmd(cmd *cobra.Command, args []string) { os.Exit(1) } + j, err := job.NewJob(args[0], &job.RuntimeConfig{ + Cpus: cpus, + }) + if err != nil { + log.Fatalf("Could not read configuration: %s", err) + os.Exit(1) + } + // Prepare environment err = run.PrepareEnvironment(cpus, runConfig.DryRun) if err != nil { diff --git a/job/job.go b/job/job.go index cdc3f8c..c85de8a 100644 --- a/job/job.go +++ b/job/job.go @@ -79,8 +79,13 @@ type Job struct { waitList *List } +// RuntimeConfig contains details about the runtime of ukbench +type RuntimeConfig struct { + Cpus []int +} + // NewJob prepares a job yaml file -func NewJob(filePath string) (*Job, error) { +func NewJob(filePath string, cfg *RuntimeConfig) (*Job, error) { // Check if the path is set if len(filePath) == 0 { return nil, fmt.Errorf("File path cannot be empty")