-
Notifications
You must be signed in to change notification settings - Fork 773
feature: define the interface and http api of preheat #1242
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1242 +/- ##
==========================================
- Coverage 51.41% 51.14% -0.27%
==========================================
Files 125 126 +1
Lines 8241 8321 +80
==========================================
+ Hits 4237 4256 +19
- Misses 3661 3720 +59
- Partials 343 345 +2
Continue to review full report at Codecov.
|
e5b326b
to
ced0538
Compare
|
||
"github.com/dragonflyoss/Dragonfly/apis/types" | ||
"github.com/dragonflyoss/Dragonfly/pkg/errortypes" | ||
"github.com/go-openapi/strfmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a blank line here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
id := mux.Vars(req)["id"] | ||
task, err := s.PreheatMgr.Get(ctx, id) | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You defined a code of StatusNotFound, while I am wondering if the code here could return the code of 404?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PreheatMgr
returns the error with a proper code and methodhandlePreheatErrorResponse
convert the error to error response and send to user.
supernode/daemon/mgr/preheat_mgr.go
Outdated
Get(ctx context.Context, id string) (task *PreheatTask, err error) | ||
|
||
// Delete deletes a preheat task by id. | ||
Delete(ctx context.Context, id string) (err error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add the Delete
endpoint if the swagger.yml? Since I have not found that.
I am afraid that we should define the API in swagger.yml first, and then implement that in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
supernode/server/preheat_bridge.go
Outdated
// Handle error if request handling fails. | ||
handlePreheatErrorResponse(w, err) | ||
} | ||
logrus.Debugf("%v err:%v", req.URL, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not print this line if err
is equal to nil. But the code here would print that no matter what value the err
is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a debug level log that indicates a request has been processed and what result is. It represents the process is success if the err
is nil
.
4a37394
to
20a39ed
Compare
da7adf1
to
7a31b77
Compare
@allencloud PTAL |
supernode/daemon/mgr/preheat_mgr.go
Outdated
return (string)(ps) | ||
} | ||
|
||
// PreheatTask store the detailed preheat task information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/store/stores
supernode/daemon/mgr/preheat_mgr.go
Outdated
) | ||
|
||
// PreheatStatus | ||
type PreheatStatus string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about defining it with go-swager?
157bb4b
to
a4a4e07
Compare
@starnop @allencloud PTAL |
80304d1
to
4fbbaa1
Compare
Sorry for the late reply. I will finish the review today. |
supernode/daemon/mgr/preheat_mgr.go
Outdated
Delete(ctx context.Context, id string) (err error) | ||
|
||
// GetAll gets all preheat tasks that unexpired. | ||
GetAll(ctx context.Context) (task []*PreheatTask, err error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update "task" to "preheatTask" in order to avoid ambiguity.
supernode/server/preheat_bridge.go
Outdated
} | ||
resp := types.PreheatInfo{ | ||
ID: task.ID, | ||
FinishTime: strfmt.DateTime{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use strfmt .NewDateTime() instead?
supernode/daemon/mgr/preheat_mgr.go
Outdated
Identifier string | ||
Headers map[string]string | ||
|
||
ParentID string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the fields "ParentID" and "Children" for? And how about add comments here?
64e65f2
to
99918a7
Compare
@allencloud @starnop PTAL |
c6989e8
to
9d34dfd
Compare
Signed-off-by: lowzj <[email protected]>
LGTM |
Signed-off-by: sunwp <[email protected]> Co-authored-by: Jim Ma <[email protected]>
Signed-off-by: lowzj [email protected]
Ⅰ. Describe what this PR did
This pull request defines the interface and http api of preheat.
Ⅱ. Does this pull request fix one issue?
#1115
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews