Documentation ¶
Index ¶
- Constants
- Variables
- func ContainerConfigurationRoot(sandboxID, containerID string) string
- func ContainerConfigurationRootPath(sandboxID, containerID string) string
- func ContainerRuntimeRoot(sandboxID, containerID string) string
- func ContainerRuntimeRootPath(sandboxID, containerID string) string
- func DeleteAll()
- func SandboxConfigurationItemPath(id string, item Item) (string, error)
- func SandboxConfigurationRoot(id string) string
- func SandboxConfigurationRootPath(id string) string
- func SandboxRuntimeItemPath(id string, item Item) (string, error)
- func SandboxRuntimeRoot(id string) string
- func SandboxRuntimeRootPath(id string) string
- func SetLogger(logger *logrus.Entry)
- func VCSandboxStoreExists(ctx context.Context, sandboxID string) bool
- func VCStoreUUIDPath() string
- type Item
- type Store
- func (s *Store) Delete() error
- func (s *Store) ItemLock(item Item, exclusive bool) (string, error)
- func (s *Store) ItemUnlock(item Item, token string) error
- func (s *Store) Load(item Item, data interface{}) error
- func (s *Store) Logger() *logrus.Entry
- func (s *Store) Raw(id string) (string, error)
- func (s *Store) Store(item Item, data interface{}) error
- type TypedDevice
- type VCStore
- func (s *VCStore) Delete() error
- func (s *VCStore) Load(item Item, data interface{}) error
- func (s *VCStore) LoadContainerState() (types.ContainerState, error)
- func (s *VCStore) LoadDevices() ([]api.Device, error)
- func (s *VCStore) LoadState() (types.SandboxState, error)
- func (s *VCStore) Lock() (string, error)
- func (s *VCStore) RLock() (string, error)
- func (s *VCStore) Raw(id string) (string, error)
- func (s *VCStore) Store(item Item, data interface{}) error
- func (s *VCStore) StoreDevices(devices []api.Device) error
- func (s *VCStore) Unlock(token string) error
Constants ¶
const ( // ConfigurationFile is the file name used for every JSON sandbox configuration. ConfigurationFile string = "config.json" // StateFile is the file name storing a sandbox state. StateFile = "state.json" // NetworkFile is the file name storing a sandbox network. NetworkFile = "network.json" // HypervisorFile is the file name storing a hypervisor's state. HypervisorFile = "hypervisor.json" // AgentFile is the file name storing an agent's state. AgentFile = "agent.json" // ProcessFile is the file name storing a container process. ProcessFile = "process.json" // LockFile is the file name locking the usage of a resource. LockFile = "lock" // MountsFile is the file name storing a container's mount points. MountsFile = "mounts.json" // DevicesFile is the file name storing a container's devices. DevicesFile = "devices.json" )
const DirMode = os.FileMode(0750) | os.ModeDir
DirMode is the permission bits used for creating a directory
const SandboxPathSuffix = "sbs"
SandboxPathSuffix is the suffix used for sandbox storage
const StoragePathSuffix = "vc"
StoragePathSuffix is the suffix used for all storage paths
Note: this very brief path represents "virtcontainers". It is as terse as possible to minimise path length.
const UUIDPathSuffix = "uuid"
UUIDPathSuffix is the suffix used for uuid storage
const VMPathSuffix = "vm"
VMPathSuffix is the suffix used for guest VMs.
Variables ¶
var ConfigStoragePath = func() string { path := filepath.Join("/var/lib", StoragePathSuffix, SandboxPathSuffix) if rootless.IsRootless() { return filepath.Join(rootless.GetRootlessDir(), path) } return path }
ConfigStoragePath is the sandbox configuration directory. It will contain one config.json file for each created sandbox. The function is declared this way for mocking in unit tests
var RunStoragePath = func() string { path := filepath.Join("/run", StoragePathSuffix, SandboxPathSuffix) if rootless.IsRootless() { return filepath.Join(rootless.GetRootlessDir(), path) } return path }
RunStoragePath is the sandbox runtime directory. It will contain one state.json and one lock file for each created sandbox. The function is declared this way for mocking in unit tests
var RunVMStoragePath = func() string { path := filepath.Join("/run", StoragePathSuffix, VMPathSuffix) if rootless.IsRootless() { return filepath.Join(rootless.GetRootlessDir(), path) } return path }
RunVMStoragePath is the vm directory. It will contain all guest vm sockets and shared mountpoints. The function is declared this way for mocking in unit tests
var VCStorePrefix = ""
VCStorePrefix is only used for tests to config a temp store dir
var VMUUIDStoragePath = func() string { path := filepath.Join("/var/lib", StoragePathSuffix, UUIDPathSuffix) if rootless.IsRootless() { return filepath.Join(rootless.GetRootlessDir(), path) } return path }
VMUUIDStoragePath is the uuid directory. It will contain all uuid info used by guest vm.
Functions ¶
func ContainerConfigurationRoot ¶
ContainerConfigurationRoot returns a virtcontainers container configuration root URL. This will hold across host reboot persistent data about a container configuration. It should look like file:///var/lib/vc/sbs/<sandboxID>/<containerID> Or if rootless file://<rootlessDir>/var/lib/vc/sbs/<sandboxID>/<containerID>
func ContainerConfigurationRootPath ¶
ContainerConfigurationRootPath returns a virtcontainers container configuration root path.
func ContainerRuntimeRoot ¶
ContainerRuntimeRoot returns a virtcontainers container runtime root URL. This will hold data related to a container run-time state that will not be persistent across host reboots. It should look like file:///run/vc/sbs/<sandboxID>/<containerID>/ Or for rootless file://<rootlessDir>/run/vc/sbs/<sandboxID>/<containerID>/
func ContainerRuntimeRootPath ¶
ContainerRuntimeRootPath returns a virtcontainers container runtime root path.
func SandboxConfigurationItemPath ¶
SandboxConfigurationItemPath returns a virtcontainers sandbox configuration item path.
func SandboxConfigurationRoot ¶
SandboxConfigurationRoot returns a virtcontainers sandbox configuration root URL. This will hold across host reboot persistent data about a sandbox configuration. It should look like file:///var/lib/vc/sbs/<sandboxID>/ Or for rootless: file://<rootlessDir>/var/lib/vc/sbs/<sandboxID>/
func SandboxConfigurationRootPath ¶
SandboxConfigurationRootPath returns a virtcontainers sandbox configuration root path.
func SandboxRuntimeItemPath ¶
SandboxRuntimeItemPath returns a virtcontainers sandbox runtime item path.
func SandboxRuntimeRoot ¶
SandboxRuntimeRoot returns a virtcontainers sandbox runtime root URL. This will hold data related to a sandbox run-time state that will not be persistent across host reboots. It should look like file:///run/vc/sbs/<sandboxID>/ or if rootless: file://<rootlessDir>/run/vc/sbs/<sandboxID>/
func SandboxRuntimeRootPath ¶
SandboxRuntimeRootPath returns a virtcontainers sandbox runtime root path.
func SetLogger ¶
SetLogger sets the custom logger to be used by this package. If not called, the package will create its own logger.
func VCSandboxStoreExists ¶
VCSandboxStoreExists returns true if a sandbox store already exists.
func VCStoreUUIDPath ¶
func VCStoreUUIDPath() string
VCStoreUUIDPath returns a virtcontainers runtime uuid URL.
Types ¶
type Item ¶
type Item uint8
Item represents a virtcontainers items that will be managed through the store.
const ( // Configuration represents a configuration item to be stored Configuration Item = iota // State represents a state item to be stored. State // Network represents a networking item to be stored. Network // Hypervisor represents an hypervisor item to be stored. Hypervisor // Agent represents a agent item to be stored. Agent // Process represents a container process item to be stored. Process // Lock represents a lock item to be stored. Lock // Mounts represents a set of mounts related item to be stored. Mounts // Devices represents a set of devices related item to be stored. Devices // DeviceIDs represents a set of reference IDs item to be stored. DeviceIDs // UUID represents a set of uuids item to be stored. UUID )
type Store ¶
Store is an opaque structure representing a virtcontainers Store.
func New ¶
New will return a new virtcontainers Store. If there is already a Store for the URL, we will re-use it. Otherwise a new Store is created.
func (*Store) Delete ¶
Delete deletes all artifacts created by a Store. The Store is also removed from the manager.
func (*Store) ItemUnlock ¶
ItemUnlock unlocks an item.
type TypedDevice ¶
type TypedDevice struct { Type string // Data is assigned the Device object. // This being declared as RawMessage prevents it from being marshalled/unmarshalled. // We do that explicitly depending on Type. Data json.RawMessage }
TypedDevice is used as an intermediate representation for marshalling and unmarshalling Device implementations.
type VCStore ¶
type VCStore struct {
// contains filtered or unexported fields
}
VCStore is a virtcontainers specific Store. Virtcontainers typically needs a configuration Store for storing permanent items across reboots. It also needs a state Store for storing states and other run-time related items. Those should not survive a reboot.
VCStore simply dispatches items into the right Store.
func NewVCContainerStore ¶
NewVCContainerStore creates a virtcontainers container Store, with filesystem backend.
func NewVCSandboxStore ¶
NewVCSandboxStore creates a virtcontainers sandbox Store, with filesystem backend.
func NewVCStore ¶
NewVCStore creates a virtcontainers specific Store.
func (*VCStore) Delete ¶
Delete deletes all artifacts created by a VCStore. Both config and state Stores are also removed from the manager.
func (*VCStore) LoadContainerState ¶
func (s *VCStore) LoadContainerState() (types.ContainerState, error)
LoadContainerState loads an returns a virtcontainer state
func (*VCStore) LoadDevices ¶
LoadDevices loads an returns a virtcontainer devices slice. We need a custom unmarshalling routine for translating TypedDevices into api.Devices based on their type.
func (*VCStore) LoadState ¶
func (s *VCStore) LoadState() (types.SandboxState, error)
LoadState loads an returns a virtcontainer state
func (*VCStore) Raw ¶
Raw creates a raw item in the virtcontainer state Store. A raw item is a custom one, not defined through the Item enum, and that the caller needs to handle directly. Typically this is used to create a custom virtcontainers file. 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.
func (*VCStore) StoreDevices ¶
StoreDevices stores a virtcontainers devices slice. The Device slice is first marshalled into a TypedDevice one to include the type of the Device objects.