persist: baseline persist data format#883
Conversation
|
/test |
c2c472c to
06728ae
Compare
|
/test |
06728ae to
5f57ee5
Compare
|
@WeiZhang555 any updates? |
209428c to
80827f9
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
df17755 to
e58557b
Compare
This comment has been minimized.
This comment has been minimized.
e58557b to
f47580b
Compare
This comment has been minimized.
This comment has been minimized.
jodh-intel
left a comment
There was a problem hiding this comment.
Hi @WeiZhang555 - This is interesting! A few initial comments (more tomorrow probably).
A couple of other thoughts:
-
We'll need super-careful tests for this.
If we do use
CurPersistVersion, we need set of valid and invalid state files for every value ofCurPersistVersionso that we can assert the expected behaviour in unit tests. -
Features like this are hard to test
Hence, it would be very useful to be able to request the runtime dump the state at any time (to the journal or an arbitrary file) either by:
- adding a new sub-command (
kata-runtime kata-state showor something). - adding a
SIGUSR2signal handler (killall -USR2 kata-runtime).
- adding a new sub-command (
| ) | ||
|
|
||
| // PersistVersion set persist data version to current version in runtime | ||
| func (s *Sandbox) PersistVersion() { |
There was a problem hiding this comment.
The names of these functions suggest that as soon as you call them, the data will be persisted to disk. But that doesn't appear to be what is happening - persistence only occurs when Dump() is called. This is potentially misleading.
How about:
- Renaming
Dump()toSave()(clearer asDumpalmost suggests some sort of debug operation to me). - Renaming
Persist*()toAddToTransaction()or something like that (AddToTrn()?) as that makes it clear this isn't actually saving any data (yet).
There was a problem hiding this comment.
Nice suggestion! I'll rename the functions, thanks!
There was a problem hiding this comment.
I just reworked the whole PR, and renamed PersistVersion to versionSaveCallback, and Dump to ToDisk. Not sure if this is clear enough for users.
Anyway, comments addressed
|
|
||
| fs.containerState[cid] = cstate | ||
| } | ||
| return nil |
There was a problem hiding this comment.
I appreciate this is a demo only, but:
- There is no validation performed on the decoded values.
- There is no check on whether
CurPersistVersionlooks reasonable (what if it was set to99in the on-disk file)?
There was a problem hiding this comment.
CurPersistVersion is hardcoded, so it will always be valid. Restoring from disk can get a 99 version number, I can add some validation during restoring.
There was a problem hiding this comment.
Not sure currently. Let's keep it as it is for now :-)
jodh-intel
left a comment
There was a problem hiding this comment.
Just a few comments.
Ping @kata-containers/runtime - this is a big PR which needs more eyes on it!
You can start by looking just at virtcontainers/persist/api/ (or just heading over to the corresponding #874).
|
@jodh-intel Thanks for reviewing! Recently I was busy on other stuffs, the PR can work but test cases would need some fixes. I will try to rebase and rework to make it work soon. |
|
@WeiZhang555 ping, any updates? Thx |
a373ba2 to
122fe74
Compare
78aad02 to
3a4a50f
Compare
Save and restore state from persist.json instead of state.json Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
Address some comments: * fix persist driver func names for better understanding * modify some logic, add some returned error etc Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
Set new persist storage driver "virtcontainers/persist/" as "experimental" feature. One day when this can fully work and we're ready to move to 2.0, we'll move it from "experimental" feature to formal feature. At that time, the "virtcontainers/filesystem_resource_storage.go" can be removed completely. Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
For experimental features, state.json won't be updated, so modify some unit test to skip. Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
add more unit tests. Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
Address review comments Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
5ae8dd5 to
5c384f3
Compare
* Fix potential panic by nil pointer. * Address comments. Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
5c384f3 to
40bc2ca
Compare
|
/test |
|
All tests are green now 🍾 🎆 The last commit is for testing the experimental new store driver, which must be deprecated before merging. I'll remove the last commit for testing compatibility with original store Last commit: |
40bc2ca to
3262da0
Compare
|
/test |
sboeuf
left a comment
There was a problem hiding this comment.
@WeiZhang555 The PR looks pretty good (two comments in the code), but I have two concerns:
- You use the same
storewording that is already part of virtcontainers to store sandbox and containers data already with the store API located atvirtcontainers/store. - This PR duplicates the way to store data, which should rely on the
virtcontainers/storecode instead. Is it something that you're planning fix as follow up PR?
| errContainerPersistNotExist = errors.New("container doesn't exist in persist data") | ||
| ) | ||
|
|
||
| func (s *Sandbox) dumpState(ss *persistapi.SandboxState, cs map[string]persistapi.ContainerState) error { |
There was a problem hiding this comment.
Global comment for this file:
Having new Sandbox methods out of the sandbox.go file sounds pretty confusing to me.
There was a problem hiding this comment.
I can move them to sandbox.go, I am worried that sandbox.go is already so large, the single file has over 1800 lines, that's why I put the store part to one single file.
I can merge this file into sandbox.go in a following PR if you insist .
|
/test |
No, the PR is meant to replace |
Ah that makes sense, thanks for the clarification. Make sure this is highly documented as this might create some confusion from a code base perspective. |
|
LGTM |
Modify lisense header from 2018 to 2019. Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
5ce73fa to
989b373
Compare
|
/test |
|
ping @kata-containers/ci We need a separate CI job for testing experimental features since experimental feature can run in different code path as this PR does. I think we can reuse the exisiting job, such as The modification for this experimental feature is adding one single line to Thanks! |
|
@WeiZhang555 I have added an envar |
|
Thanks @chavafg ! Cross refs to kata-containers/tests#1501 and copying comments here:
|

Fixes #803
This demonstrate how to use new
virtcontainers/persist/api/package brought by #874This PR is only for demo, please don't merge it.This is ready for review and merge now :-)
state.jsonis removed, contents moved topersist.jsonnetwork.jsonagent.jsondevices.jsonhypervisor.jsonmounts.jsonprocess.json