Skip to content

Commit f6dce57

Browse files
committed
fix: some struct changes & better logging
1 parent 2c2e403 commit f6dce57

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

job.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func (job benchJob) run(ctx context.Context, WarmVMs <-chan runningFirecracker)
1414

1515
err := q.setjobReceived(ctx, job)
1616
if err != nil {
17+
log.WithError(err).Error("Could not set job received")
1718
q.setjobFailed(ctx, job)
1819
return
1920
}
@@ -31,9 +32,10 @@ func (job benchJob) run(ctx context.Context, WarmVMs <-chan runningFirecracker)
3132
var reqJSON []byte
3233

3334
reqJSON, err = json.Marshal(agentRunReq{
34-
ID: job.ID,
35-
Variant: job.Variant,
36-
Code: job.Code,
35+
ID: job.ID,
36+
Language: job.Language,
37+
Code: job.Code,
38+
Variant: "TODO",
3739
})
3840
if err != nil {
3941
log.WithError(err).Error("Failed to marshal JSON request")
@@ -43,6 +45,7 @@ func (job benchJob) run(ctx context.Context, WarmVMs <-chan runningFirecracker)
4345

4446
err = q.setjobRunning(ctx, job)
4547
if err != nil {
48+
log.WithError(err).Error("Could not set job running")
4649
q.setjobFailed(ctx, job)
4750
return
4851
}
@@ -51,7 +54,7 @@ func (job benchJob) run(ctx context.Context, WarmVMs <-chan runningFirecracker)
5154
var agentRes agentExecRes
5255

5356
// FIXME
54-
httpRes, err = http.Post("http://"+vm.ip.String()+":8080/run/python", "application/json", bytes.NewBuffer(reqJSON))
57+
httpRes, err = http.Post("http://"+vm.ip.String()+":8080/run", "application/json", bytes.NewBuffer(reqJSON))
5558
if err != nil {
5659
log.WithError(err).Error("Failed to request execution to agent")
5760
q.setjobFailed(ctx, job)
@@ -60,7 +63,11 @@ func (job benchJob) run(ctx context.Context, WarmVMs <-chan runningFirecracker)
6063
json.NewDecoder(httpRes.Body).Decode(&agentRes)
6164
log.WithField("result", agentRes).Info("Job execution finished")
6265
if httpRes.StatusCode != 200 {
63-
log.WithField("res", agentRes).Error("Failed to compile and run code")
66+
log.WithFields(log.Fields{
67+
"httpRes": httpRes,
68+
"agentRes": agentRes,
69+
"reqJSON": string(reqJSON),
70+
}).Error("Failed to compile and run code")
6471
q.setjobFailed(ctx, job)
6572
return
6673
}

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818
)
1919

2020
type benchJob struct {
21-
ID string `json:"id"`
22-
Variant string `json:"variant"`
23-
Code string `json:"code"`
21+
ID string `json:"id"`
22+
Language string `json:"language"`
23+
Code string `json:"code"`
2424
}
2525

2626
type agentExecReq struct {
@@ -29,9 +29,10 @@ type agentExecReq struct {
2929
}
3030

3131
type agentRunReq struct {
32-
ID string `json:"id"`
33-
Variant string `json:"variant"`
34-
Code string `json:"code"`
32+
ID string `json:"id"`
33+
Language string `json:"language"`
34+
Code string `json:"code"`
35+
Variant string `json:"variant"`
3536
}
3637

3738
type agentExecRes struct {

0 commit comments

Comments
 (0)