Virtcontainers store#1066
Conversation
596b3fe to
6cb93e6
Compare
6cb93e6 to
a6f776b
Compare
|
Happy new year @sameo I'm looking forward to seeing more dialogue on this PR w.r.t. the store itself. Does it make sense to create a seperate PR for the commits which make use of the 'internal types' pkg? That should be ready to go as is? Would like to at least get that in for 1.5 (scheduled week of 1/23). WDYT? |
|
@egernst Bonne Année a toi aussi! I will extract the |
23f026c to
e7cf9cd
Compare
e7cf9cd to
ce86229
Compare
|
@egernst @sboeuf @jodh-intel @bergwolf @WeiZhang555 |
73b15c6 to
c8e3852
Compare
|
Unit tests pass locally... |
fabbd8a to
0d8c289
Compare
sboeuf
left a comment
There was a problem hiding this comment.
@sameo
I have several comments regarding this PR in the code, but here is the summary:
-
It globally looks good, and I really appreciate the way commits are split, it's neat and easy to understand.
-
I'm wondering if we're not missing the port of the specific implementations retrieving special devices.
-
I have some doubt this is really simplifying the existing code. The whole manager is neat but maybe a bit too much since virtcontainers will be the only consumer of this. Having a
VCStoreimplementation calling intoStorewho calls into the backend interface eventually seems a lot of layers to me when I don't think anything else will reuse this package.
| ) | ||
|
|
||
| // Item represents a virtcontainers items that will be managed through the store. | ||
| type Item uint8 |
There was a problem hiding this comment.
Is it really important to put this on 8bits?
There was a problem hiding this comment.
I want it to be a specific type. Are you suggesting this should be a string instead?
There was a problem hiding this comment.
No, no, I was just thinking this could be a simple uint, but doesn't matter.
| delete() | ||
| load(item Item, data interface{}) error | ||
| store(item Item, data interface{}) error | ||
| raw(id string) (string, error) |
There was a problem hiding this comment.
Could you please highlight in the commit message and through some comments in the code, some concrete use cases for this new API.
There was a problem hiding this comment.
I did. Please let me know if this looks better.
There was a problem hiding this comment.
Yes it helps a lot to understand :)
IMO, you should even mention
// For example the Firecracker code uses this API to create temp
// files under the sandbox state root path, and uses them as block
// driver backend placeholder.
from the commit message.
| load(item Item, data interface{}) error | ||
| store(item Item, data interface{}) error | ||
| raw(id string) (string, error) | ||
| lock(item Item, exclusive bool) (string, error) |
There was a problem hiding this comment.
I don't get why we need those new locking API. If I followed until then, we have any Load() performing a read only lock, and Store() performing a read/write lock, which looks like it should be enough. Also, from the Kata API perspective, we have the locking of the pod, meaning we cannot access two containers of the same pod concurrently.
Ohh maybe I understand now, are you trying to do the pod locking through this API? And you're doing this because the lock file has to be created somewhere... It's a tricky one because it's not natural to have the locking being handled through the storage, but I guess that's how it was kind of working already.
Unless we share the global path for pods (in types maybe), and we could create a separate lock/ package.
| l.Info("Device type found") | ||
|
|
||
| switch d.Type { | ||
| case string(config.DeviceVFIO): |
There was a problem hiding this comment.
Where have you moved specific fetch implementation related to devices? I could not find it in virtcontainers/store/filesystem.go
There was a problem hiding this comment.
I need to add a lot more unit tests to vc_test.go
0d8c289 to
3608420
Compare
|
/test |
3608420 to
04dec93
Compare
|
/test |
04dec93 to
375a1a5
Compare
It's going to be used to completely clean a Store away. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This is basically a Store dispatcher, for storing items into their right Store (either configuration or state). There's very little logic here, except for finding out which store an item belongs to in the virtcontainers context. vc.go also provides virtcontainers specific utilities. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
The Raw API creates a raw item, i.e. an item that must be handled directly by the caller. A raw item is one that's not defined by the store.Item enum, i.e. it is a custom, caller defined one. The caller gets a URL back and is responsible for handling the item directly from this URL. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
The ItemLock API allows for taking shared and exclusive locks on all items. For virtcontainers, this is specialized into taking locks on the Lock item, and will be used for sandbox locking. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
e283ff1 to
a2a73d4
Compare
|
Basic CI passes, let's retest. |
|
/retest |
We convert the whole virtcontainers code to use the store package
instead of the resource_storage one. The resource_storage removal will
happen in a separate change for a more logical split.
This change is fairly big but mostly does not change the code logic.
What really changes is when we create a store for a container or a
sandbox. We now need to explictly do so instead of just assigning a
filesystem{} instance. Other than that, the logic is kept intact.
Fixes: kata-containers#1099
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Now that we converted the virtcontainers code to the store package, we can remove all the resource storage old code. Fixes: kata-containers#1099 Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
With the Stores conversion, the newContainer() cyclomatic complexity went over 15. We fix that by extracting the block devices creation routine out of newContainer. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
We are creating Store directories but never removing them. Calling into a VM factory created vm Stop() will now clean the VM Store artifacts up. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
a2a73d4 to
bb99e41
Compare
|
I just fixed a network NS leak caused by a typo in the Store conversion patch. |
|
/retest |
|
@sboeuf @WeiZhang555 @bergwolf @jodh-intel The CI passes now. |
|
LGTM Let's retest it again before it can be merged. /retest |
|
@WeiZhang555 The fc and ARM CI are broken, as expected :-/ |
The store refactor (kata-containers#1066) inadvertently broke runtime tracing as it created new contexts containing trace spans. Reworking the store changes to re-use the existing context resolves the problem since runtime tracing assumes a single context. Fixes kata-containers#1277. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Description and goals
This is a rewrite of the
resource_storageand itsfilesystem_resource_storagebackend, with the following goals:filesystembackend implementation and make it the default one for virtcontainers.storepackage for the core virtcontainers code to consume. Since several components are depending on a store API, this will break these dependencies and allow us to move virtcontainers code base is monolithic #1059 further away.Shortcomings
There are a lot of places in the virtcontainers code where we assume that our store backend will be a local filesystem one. This is practically just right but ideally we should not make any of those assumptions. This PR does not completely remove those assumptions, but the
storepackage top level API is neutral enough so that we could eventually remove them from the core virtcontainers code.