Windows: OCI aggressive namespacing

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-09-16 10:48:40 -07:00
parent b72c7f74a6
commit c89db6c044
2 changed files with 28 additions and 28 deletions

View File

@ -115,7 +115,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
hv = c.HostConfig.Isolation.IsHyperV() hv = c.HostConfig.Isolation.IsHyperV()
} }
if hv { if hv {
hvr := &windowsoci.HvRuntime{} hvr := &windowsoci.WindowsHvRuntime{}
if img.RootFS != nil && img.RootFS.Type == image.TypeLayers { if img.RootFS != nil && img.RootFS.Type == image.TypeLayers {
// For TP5, the utility VM is part of the base layer. // For TP5, the utility VM is part of the base layer.
// TODO-jstarks: Add support for separate utility VM images // TODO-jstarks: Add support for separate utility VM images
@ -159,26 +159,26 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
} }
} }
} }
s.Windows.Networking = &windowsoci.Networking{ s.Windows.Networking = &windowsoci.WindowsNetworking{
EndpointList: epList, EndpointList: epList,
} }
// In s.Windows.Resources // In s.Windows.Resources
// @darrenstahlmsft implement these resources // @darrenstahlmsft implement these resources
cpuShares := uint64(c.HostConfig.CPUShares) cpuShares := uint64(c.HostConfig.CPUShares)
s.Windows.Resources = &windowsoci.Resources{ s.Windows.Resources = &windowsoci.WindowsResources{
CPU: &windowsoci.CPU{ CPU: &windowsoci.WindowsCPU{
Percent: &c.HostConfig.CPUPercent, Percent: &c.HostConfig.CPUPercent,
Shares: &cpuShares, Shares: &cpuShares,
}, },
Memory: &windowsoci.Memory{ Memory: &windowsoci.WindowsMemory{
Limit: &c.HostConfig.Memory, Limit: &c.HostConfig.Memory,
//TODO Reservation: ..., //TODO Reservation: ...,
}, },
Network: &windowsoci.Network{ Network: &windowsoci.WindowsNetwork{
//TODO Bandwidth: ..., //TODO Bandwidth: ...,
}, },
Storage: &windowsoci.Storage{ Storage: &windowsoci.WindowsStorage{
Bps: &c.HostConfig.IOMaximumBandwidth, Bps: &c.HostConfig.IOMaximumBandwidth,
Iops: &c.HostConfig.IOMaximumIOps, Iops: &c.HostConfig.IOMaximumIOps,
}, },

View File

@ -36,15 +36,15 @@ type Spec struct {
// Windows contains platform specific configuration for Windows based containers. // Windows contains platform specific configuration for Windows based containers.
type Windows struct { type Windows struct {
// Resources contains information for handling resource constraints for the container // Resources contains information for handling resource constraints for the container
Resources *Resources `json:"resources,omitempty"` Resources *WindowsResources `json:"resources,omitempty"`
// Networking contains the platform specific network settings for the container. // Networking contains the platform specific network settings for the container.
Networking *Networking `json:"networking,omitempty"` Networking *WindowsNetworking `json:"networking,omitempty"`
// LayerFolder is the path to the current layer folder // LayerFolder is the path to the current layer folder
LayerFolder string `json:"layer_folder,omitempty"` LayerFolder string `json:"layer_folder,omitempty"`
// Layer paths of the parent layers // Layer paths of the parent layers
LayerPaths []string `json:"layer_paths,omitempty"` LayerPaths []string `json:"layer_paths,omitempty"`
// HvRuntime contains settings specific to Hyper-V containers, omitted if not using Hyper-V isolation // HvRuntime contains settings specific to Hyper-V containers, omitted if not using Hyper-V isolation
HvRuntime *HvRuntime `json:"hv_runtime,omitempty"` HvRuntime *WindowsHvRuntime `json:"hv_runtime,omitempty"`
} }
// Process contains information to start a specific application inside the container. // Process contains information to start a specific application inside the container.
@ -108,20 +108,20 @@ type Mount struct {
Options []string `json:"options,omitempty"` Options []string `json:"options,omitempty"`
} }
// HvRuntime contains settings specific to Hyper-V containers // WindowsHvRuntime contains settings specific to Hyper-V containers
type HvRuntime struct { type WindowsHvRuntime struct {
// ImagePath is the path to the Utility VM image for this container // ImagePath is the path to the Utility VM image for this container
ImagePath string `json:"image_path,omitempty"` ImagePath string `json:"image_path,omitempty"`
} }
// Networking contains the platform specific network settings for the container // WindowsNetworking contains the platform specific network settings for the container
type Networking struct { type WindowsNetworking struct {
// List of endpoints to be attached to the container // List of endpoints to be attached to the container
EndpointList []string `json:"endpoints,omitempty"` EndpointList []string `json:"endpoints,omitempty"`
} }
// Storage contains storage resource management settings // WindowsStorage contains storage resource management settings
type Storage struct { type WindowsStorage struct {
// Specifies maximum Iops for the system drive // Specifies maximum Iops for the system drive
Iops *uint64 `json:"iops,omitempty"` Iops *uint64 `json:"iops,omitempty"`
// Specifies maximum bytes per second for the system drive // Specifies maximum bytes per second for the system drive
@ -130,16 +130,16 @@ type Storage struct {
SandboxSize *uint64 `json:"sandbox_size,omitempty"` SandboxSize *uint64 `json:"sandbox_size,omitempty"`
} }
// Memory contains memory settings for the container // WindowsMemory contains memory settings for the container
type Memory struct { type WindowsMemory struct {
// Memory limit (in bytes). // Memory limit (in bytes).
Limit *int64 `json:"limit,omitempty"` Limit *int64 `json:"limit,omitempty"`
// Memory reservation (in bytes). // Memory reservation (in bytes).
Reservation *uint64 `json:"reservation,omitempty"` Reservation *uint64 `json:"reservation,omitempty"`
} }
// CPU contains information for cpu resource management // WindowsCPU contains information for cpu resource management
type CPU struct { type WindowsCPU struct {
// Number of CPUs available to the container. This is an appoximation for Windows Server Containers. // Number of CPUs available to the container. This is an appoximation for Windows Server Containers.
Count *uint64 `json:"count,omitempty"` Count *uint64 `json:"count,omitempty"`
// CPU shares (relative weight (ratio) vs. other containers with cpu shares). Range is from 1 to 10000. // CPU shares (relative weight (ratio) vs. other containers with cpu shares). Range is from 1 to 10000.
@ -148,24 +148,24 @@ type CPU struct {
Percent *int64 `json:"percent,omitempty"` Percent *int64 `json:"percent,omitempty"`
} }
// Network contains network resource management information // WindowsNetwork contains network resource management information
type Network struct { type WindowsNetwork struct {
// Bandwidth is the maximum egress bandwidth in bytes per second // Bandwidth is the maximum egress bandwidth in bytes per second
Bandwidth *uint64 `json:"bandwidth,omitempty"` Bandwidth *uint64 `json:"bandwidth,omitempty"`
} }
// Resources has container runtime resource constraints // WindowsResources has container runtime resource constraints
// TODO Windows containerd. This structure needs ratifying with the old resources // TODO Windows containerd. This structure needs ratifying with the old resources
// structure used on Windows and the latest OCI spec. // structure used on Windows and the latest OCI spec.
type Resources struct { type WindowsResources struct {
// Memory restriction configuration // Memory restriction configuration
Memory *Memory `json:"memory,omitempty"` Memory *WindowsMemory `json:"memory,omitempty"`
// CPU resource restriction configuration // CPU resource restriction configuration
CPU *CPU `json:"cpu,omitempty"` CPU *WindowsCPU `json:"cpu,omitempty"`
// Storage restriction configuration // Storage restriction configuration
Storage *Storage `json:"storage,omitempty"` Storage *WindowsStorage `json:"storage,omitempty"`
// Network restriction configuration // Network restriction configuration
Network *Network `json:"network,omitempty"` Network *WindowsNetwork `json:"network,omitempty"`
} }
const ( const (