package hcsoci
import "github.com/Microsoft/hcsshim/internal/hcsoci"
Index ¶
- Constants
- func GetNamespaceEndpoints(ctx context.Context, netNS string) ([]*hns.HNSEndpoint, error)
- func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot string, uvm *uvmpkg.UtilityVM) (_ string, err error)
- func ReleaseResources(ctx context.Context, r *Resources, vm *uvm.UtilityVM, all bool) error
- func UnmountContainerLayers(ctx context.Context, layerFolders []string, containerRootPath string, uvm *uvmpkg.UtilityVM, op UnmountOperation) error
- type Cmd
- func Command(host cow.ProcessHost, name string, arg ...string) *Cmd
- func CommandContext(ctx context.Context, host cow.ProcessHost, name string, arg ...string) *Cmd
- func (c *Cmd) Output() ([]byte, error)
- func (c *Cmd) Run() error
- func (c *Cmd) Start() error
- func (c *Cmd) Wait() error
- type CreateOptions
- type ExitError
- type ExitState
- type Resources
- func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Container, _ *Resources, err error)
- func (r *Resources) NetNS() string
- type UnmountOperation
Constants ¶
const ( UnmountOperationSCSI UnmountOperation = 0x01 UnmountOperationVSMB = 0x02 UnmountOperationVPMEM = 0x04 UnmountOperationAll = UnmountOperationSCSI | UnmountOperationVSMB | UnmountOperationVPMEM )
Functions ¶
func GetNamespaceEndpoints ¶
GetNamespaceEndpoints gets all endpoints in `netNS`
func MountContainerLayers ¶
func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot string, uvm *uvmpkg.UtilityVM) (_ string, err error)
MountContainerLayers is a helper for clients to hide all the complexity of layer mounting Layer folder are in order: base, [rolayer1..rolayern,] scratch
v1/v2: Argon WCOW: Returns the mount path on the host as a volume GUID. v1: Xenon WCOW: Done internally in HCS, so no point calling doing anything here. v2: Xenon WCOW: Returns a CombinedLayersV2 structure where ContainerRootPath is a folder
inside the utility VM which is a GUID mapping of the scratch folder. Each of the layers are the VSMB locations where the read-only layers are mounted.
func ReleaseResources ¶
TODO: Method on the resources?
func UnmountContainerLayers ¶
func UnmountContainerLayers(ctx context.Context, layerFolders []string, containerRootPath string, uvm *uvmpkg.UtilityVM, op UnmountOperation) error
UnmountContainerLayers is a helper for clients to hide all the complexity of layer unmounting
Types ¶
type Cmd ¶
type Cmd struct { // Host is the process host in which to launch the process. Host cow.ProcessHost // The OCI spec for the process. Spec *specs.Process // Standard IO streams to relay to/from the process. Stdin io.Reader Stdout io.Writer Stderr io.Writer // Log provides a logrus entry to use in logging IO copying status. Log *logrus.Entry // Context provides a context that terminates the process when it is done. Context context.Context // CopyAfterExitTimeout is the amount of time after process exit we allow the // stdout, stderr relays to continue before forcibly closing them if not // already completed. This is primarily a safety step against the HCS when // it fails to send a close on the stdout, stderr pipes when the process // exits and blocks the relay wait groups forever. CopyAfterExitTimeout time.Duration // Process is filled out after Start() returns. Process cow.Process // ExitState is filled out after Wait() (or Run() or Output()) completes. ExitState *ExitState // contains filtered or unexported fields }
Cmd represents a command being prepared or run in a process host.
func Command ¶
func Command(host cow.ProcessHost, name string, arg ...string) *Cmd
Command makes a Cmd for a given command and arguments.
func CommandContext ¶
CommandContext makes a Cmd for a given command and arguments. After it is launched, the process is killed when the context becomes done.
func (*Cmd) Output ¶
Output runs a command via Run and collects its stdout into a buffer, which it returns.
func (*Cmd) Run ¶
Run is equivalent to Start followed by Wait.
func (*Cmd) Start ¶
Start starts a command. The caller must ensure that if Start succeeds, Wait is eventually called to clean up resources.
func (*Cmd) Wait ¶
Wait waits for a command and its IO to complete and closes the underlying process. It can only be called once. It returns an ExitError if the command runs and returns a non-zero exit code.
type CreateOptions ¶
type CreateOptions struct { // Common parameters ID string // Identifier for the container Owner string // Specifies the owner. Defaults to executable name. Spec *specs.Spec // Definition of the container or utility VM being created SchemaVersion *hcsschema.Version // Requested Schema Version. Defaults to v2 for RS5, v1 for RS1..RS4 HostingSystem *uvm.UtilityVM // Utility or service VM in which the container is to be created. NetworkNamespace string // Host network namespace to use (overrides anything in the spec) // This is an advanced debugging parameter. It allows for diagnosibility by leaving a containers // resources allocated in case of a failure. Thus you would be able to use tools such as hcsdiag // to look at the state of a utility VM to see what resources were allocated. Obviously the caller // must a) not tear down the utility VM on failure (or pause in some way) and b) is responsible for // performing the ReleaseResources() call themselves. DoNotReleaseResourcesOnFailure bool }
CreateOptions are the set of fields used to call CreateContainer(). Note: In the spec, the LayerFolders must be arranged in the same way in which moby configures them: layern, layern-1,...,layer2,layer1,scratch where layer1 is the base read-only layer, layern is the top-most read-only layer, and scratch is the RW layer. This is for historical reasons only.
type ExitError ¶
type ExitError struct { *ExitState }
ExitError is used when a process exits with a non-zero exit code.
func (*ExitError) Error ¶
type ExitState ¶
type ExitState struct {
// contains filtered or unexported fields
}
ExitState contains whether a process has exited and with which exit code.
func (*ExitState) ExitCode ¶
ExitCode returns the exit code of the process, or -1 if the exit code is not known.
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
Resources is the structure returned as part of creating a container. It holds nothing useful to clients, hence everything is lowercased. A client would use it in a call to ReleaseResource to ensure everything is cleaned up when a container exits.
func CreateContainer ¶
func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Container, _ *Resources, err error)
CreateContainer creates a container. It can cope with a wide variety of scenarios, including v1 HCS schema calls, as well as more complex v2 HCS schema calls. Note we always return the resources that have been allocated, even in the case of an error. This provides support for the debugging option not to release the resources on failure, so that the client can make the necessary call to release resources that have been allocated as part of calling this function.
func (*Resources) NetNS ¶
NetNS returns the network namespace for the container
type UnmountOperation ¶
type UnmountOperation uint
UnmountOperation is used when calling Unmount() to determine what type of unmount is required. In V1 schema, this must be unmountOperationAll. In V2, client can be more optimal and only unmount what they need which can be a minor performance improvement (eg if you know only one container is running in a utility VM, and the UVM is about to be torn down, there's no need to unmount the VSMB shares, just SCSI to have a consistent file system).
Source Files ¶
cmd.go create.go hcsdoc_lcow.go hcsdoc_wcow.go layers.go network.go resources.go resources_lcow.go resources_wcow.go
- Version
- v0.8.7
- Published
- Nov 15, 2019
- Platform
- windows/amd64
- Imports
- 35 packages
- Last checked
- 1 hour ago –
Tools for package owners.