[WIP] revive config.json for docker checkpoints#38028
[WIP] revive config.json for docker checkpoints#38028lifubang wants to merge 1 commit intomoby:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38028 +/- ##
=========================================
Coverage ? 36.11%
=========================================
Files ? 610
Lines ? 45225
Branches ? 0
=========================================
Hits ? 16334
Misses ? 26650
Partials ? 2241 |
daemon/checkpoint.go
Outdated
There was a problem hiding this comment.
Please define new struct, because api/types is for REST API
There was a problem hiding this comment.
For now, "docker checkpoint ls" just return "Checkpoint name", I think we need more useful information.
So, my original idea is that after this patch, "docker checkpoint ls " should print more information. such as:
CheckpintName, Create Time, Exit
So I reuse "types.Checkpoint".
Do you still think that we need to define a new struct?
If yes, I'll redefine it.
There was a problem hiding this comment.
Ok, thank you for your review.
For one PR do one thing, I defined a new struct.
c54b23e to
8b01e7f
Compare
daemon/checkpoint.go
Outdated
There was a problem hiding this comment.
If this type is (at least currently) only used locally, perhaps it should be un-exported.
There was a problem hiding this comment.
Thank you.
I should be careful every time. Don't just copy & paste.
8b01e7f to
ae58625
Compare
daemon/checkpoint.go
Outdated
There was a problem hiding this comment.
It just occurred to me, but does this play nice with custom checkpoint dirs? (i.e.; should it remove the directory in that case?)
There was a problem hiding this comment.
Yeah, I thought about it when I was writing this code. I don't know we should delete or just return the error. I just choose to delete it at that time. But now, with your opinion, I think we should remain that dir. I'll remove this line.
There was a problem hiding this comment.
The alternative would be to check if we created the directory, but that would be dangerous (there could be a race-condition where we checked if it existed before, but meanwhile another session is creating a checkpoint (and the checkpoint dir))
There was a problem hiding this comment.
how about add an option --save-whenfail?
Whether save any incomplete files or not when fail in checkpoint create process.
The default value is true, if set to false, remove the dir when fail.
There was a problem hiding this comment.
Hm, no, I don't think we should add an option for this; also in light of future work for checkpoints is being worked on on containerd.
There was a problem hiding this comment.
For https://github.com/containerd/containerd/blob/06b9cb35161009dcb7123345749fef02f7cea8e0/runtime/container.go#L367
If write config.json fail, it just return the error.
I think there is very very small opportunity to meet this error, so we just return the error without remove the dir?
If yes, I'll remove this line, and modify the checkpoint list func to ignore this type folder because there is no config.json in it(very very small opportunity).
There was a problem hiding this comment.
Or move create config.json to the position before call daemon.containerd.CreateCheckpoint?
There was a problem hiding this comment.
@thaJeztah I have moved the code position, and the checkpoint dir is always created by dockerd, not created by the user(
Line 44 in 502b6e6
ae58625 to
502b6e6
Compare
Signed-off-by: Lifubang <[email protected]>
| return fmt.Errorf("cannot checkpoint container %s: %s", name, err) | ||
| } | ||
|
|
||
| checkpointInfo := checkPoint{ |
There was a problem hiding this comment.
Could you add a space before the curly bracket, please?
There was a problem hiding this comment.
If I add a space, gofmt will remove it.
There was a problem hiding this comment.
And I prefer to add a space, it looks more pretty. But we need to upgrade gofmt.
|
@lifubang Thank you for the PR! I can confirm that this commit solves the problem with |
| ) | ||
|
|
||
| // checkPoint represents the details of a checkpoint | ||
| type checkPoint struct { |
There was a problem hiding this comment.
There was a problem hiding this comment.
Because we need to add some fields for types.Checkpoint. And AkihiroSuda tell me I should define a new struct, I accept his suggestion. Please see the first review msg at the top of this page. Thanks.
There was a problem hiding this comment.
In this case, you have to fix CheckpointList too
|
Since #38452 is merged, this is no longer needed to fix |
|
To finish this, I guess Closing for now, feel free to reopen if you want to finish it. |
Signed-off-by: Lifubang [email protected]
- What I did
- How I did it
After this commit (Update libcontainerd to use containerd 1.0): ddae20c#diff-d2fd8e9feab75f193a7d19493831c1f1
There is no "config.json" now.
So, when checkpoint ls, there will be an error.
Just create it, because all value in "config.json" is from daemon.
- How to verify it
After fix:
- Description for the changelog
Create config.json after checkpoint succ.