From 81eba79e549250ec4149d88f84239ca2b552e7e6 Mon Sep 17 00:00:00 2001 From: Kirtana Ashok Date: Tue, 17 Sep 2024 19:48:55 -0700 Subject: [PATCH] Refactor hcs internal pkg k/k repo using ContainerProperties and NetworkStats struct from hcs internal pkg. Due to this the whole hcsshim pkg is having to be imported in k/k. This commit helps to restructure the pkg and maintain submodule to ensure that only this pkg is imported in k/k Signed-off-by: Kirtana Ashok --- computestorage/storage.go | 3 +- container.go | 35 +++-- go.mod | 3 + hcs/go.mod | 7 + hcs/go.sum | 4 + hcs/helpers.go | 7 + hcs/helpers_windows.go | 48 +++++++ hcs/internal/schema1/schema1.go | 133 ++++++++++++++++++ .../hcs => hcs/internal}/schema2/version.go | 0 internal/cow/cow.go | 3 +- internal/gcs/container.go | 5 +- internal/gcs/guestcaps.go | 4 +- internal/gcs/protocol.go | 9 +- internal/hcs/schema1/schema1.go | 125 ---------------- internal/hcs/schema2/compute_system.go | 6 +- internal/hcs/schema2/guest_connection_info.go | 8 +- internal/hcs/schema2/hosted_system.go | 6 +- internal/hcs/schema2/virtual_machine.go | 6 +- internal/hcs/system.go | 9 +- internal/hcsoci/create.go | 19 +-- internal/hcsoci/hcsdoc_lcow.go | 4 +- internal/jobcontainers/jobcontainer.go | 9 +- internal/schemaversion/schemaversion.go | 26 ++-- test/go.mod | 10 +- test/internal/schemaversion_test.go | 6 +- .../Microsoft/hcsshim/hcs/helpers.go | 7 + .../Microsoft/hcsshim/hcs/helpers_windows.go | 48 +++++++ .../hcsshim/hcs/internal/schema1/schema1.go | 133 ++++++++++++++++++ .../hcsshim/hcs/internal/schema2/version.go | 16 +++ vendor/modules.txt | 6 + 30 files changed, 514 insertions(+), 191 deletions(-) create mode 100644 hcs/go.mod create mode 100644 hcs/go.sum create mode 100644 hcs/helpers.go create mode 100644 hcs/helpers_windows.go create mode 100644 hcs/internal/schema1/schema1.go rename {internal/hcs => hcs/internal}/schema2/version.go (100%) create mode 100644 vendor/github.com/Microsoft/hcsshim/hcs/helpers.go create mode 100644 vendor/github.com/Microsoft/hcsshim/hcs/helpers_windows.go create mode 100644 vendor/github.com/Microsoft/hcsshim/hcs/internal/schema1/schema1.go create mode 100644 vendor/github.com/Microsoft/hcsshim/hcs/internal/schema2/version.go diff --git a/computestorage/storage.go b/computestorage/storage.go index 5af931f2f4..6210f37872 100644 --- a/computestorage/storage.go +++ b/computestorage/storage.go @@ -4,6 +4,7 @@ package computestorage import ( + hcstypes "github.com/Microsoft/hcsshim/hcs" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) @@ -22,7 +23,7 @@ import ( //sys hcsAttachOverlayFilter(volumePath string, layerData string) (hr error) = computestorage.HcsAttachOverlayFilter? //sys hcsDetachOverlayFilter(volumePath string, layerData string) (hr error) = computestorage.HcsDetachOverlayFilter? -type Version = hcsschema.Version +type Version = hcstypes.Version type Layer = hcsschema.Layer // LayerData is the data used to describe parent layer information. diff --git a/container.go b/container.go index 0ad7f495af..c15c270d8c 100644 --- a/container.go +++ b/container.go @@ -9,51 +9,58 @@ import ( "sync" "time" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/hcs" "github.com/Microsoft/hcsshim/internal/hcs/schema1" "github.com/Microsoft/hcsshim/internal/mergemaps" ) +// The following declarations have been moved to hcs/helpers.go . +// They have been retained here only to avoid breaking any +// downstream users. +// TODO (kiashok): Once hcsshim moves to a new major version, we can +// remove these declarations from here. + // ContainerProperties holds the properties for a container and the processes running in that container -type ContainerProperties = schema1.ContainerProperties +type ContainerProperties = hcstypes.ContainerProperties // MemoryStats holds the memory statistics for a container -type MemoryStats = schema1.MemoryStats +type MemoryStats = hcstypes.MemoryStats // ProcessorStats holds the processor statistics for a container -type ProcessorStats = schema1.ProcessorStats +type ProcessorStats = hcstypes.ProcessorStats // StorageStats holds the storage statistics for a container -type StorageStats = schema1.StorageStats +type StorageStats = hcstypes.StorageStats // NetworkStats holds the network statistics for a container -type NetworkStats = schema1.NetworkStats +type NetworkStats = hcstypes.NetworkStats // Statistics is the structure returned by a statistics call on a container -type Statistics = schema1.Statistics +type Statistics = hcstypes.Statistics // ProcessList is the structure of an item returned by a ProcessList call on a container -type ProcessListItem = schema1.ProcessListItem +type ProcessListItem = hcstypes.ProcessListItem // MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container -type MappedVirtualDiskController = schema1.MappedVirtualDiskController +type MappedVirtualDiskController = hcstypes.MappedVirtualDiskController // Type of Request Support in ModifySystem -type RequestType = schema1.RequestType +type RequestType = hcstypes.RequestType // Type of Resource Support in ModifySystem -type ResourceType = schema1.ResourceType +type ResourceType = hcstypes.ResourceType // RequestType const const ( - Add = schema1.Add - Remove = schema1.Remove - Network = schema1.Network + Add = hcstypes.Add + Remove = hcstypes.Remove + Network = hcstypes.Network ) // ResourceModificationRequestResponse is the structure used to send request to the container to modify the system // Supported resource types are Network and Request Types are Add/Remove -type ResourceModificationRequestResponse = schema1.ResourceModificationRequestResponse +type ResourceModificationRequestResponse = hcstypes.ResourceModificationRequestResponse type container struct { system *hcs.System diff --git a/go.mod b/go.mod index 896a343e17..82b3754d39 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/Microsoft/cosesign1go v1.2.0 github.com/Microsoft/didx509go v0.0.3 github.com/Microsoft/go-winio v0.6.2 + github.com/Microsoft/hcsshim/hcs v0.0.0 github.com/blang/semver/v4 v4.0.0 github.com/cenkalti/backoff/v4 v4.3.0 github.com/containerd/cgroups/v3 v3.0.3 @@ -120,3 +121,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) + +replace github.com/Microsoft/hcsshim/hcs => ./hcs diff --git a/hcs/go.mod b/hcs/go.mod new file mode 100644 index 0000000000..42e0ed4506 --- /dev/null +++ b/hcs/go.mod @@ -0,0 +1,7 @@ +module github.com/Microsoft/hcsshim/hcs + +go 1.21 + +require github.com/Microsoft/go-winio v0.6.2 + +require golang.org/x/sys v0.10.0 // indirect diff --git a/hcs/go.sum b/hcs/go.sum new file mode 100644 index 0000000000..a001052ff3 --- /dev/null +++ b/hcs/go.sum @@ -0,0 +1,4 @@ +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/hcs/helpers.go b/hcs/helpers.go new file mode 100644 index 0000000000..68b90b6318 --- /dev/null +++ b/hcs/helpers.go @@ -0,0 +1,7 @@ +package hcs + +import ( + hcsschema "github.com/Microsoft/hcsshim/hcs/internal/schema2" +) + +type Version = hcsschema.Version diff --git a/hcs/helpers_windows.go b/hcs/helpers_windows.go new file mode 100644 index 0000000000..c6922bfcb4 --- /dev/null +++ b/hcs/helpers_windows.go @@ -0,0 +1,48 @@ +//go:build windows + +package hcs + +import ( + "github.com/Microsoft/hcsshim/hcs/internal/schema1" +) + +// ContainerProperties holds the properties for a container and the processes running in that container +type ContainerProperties = schema1.ContainerProperties + +// MemoryStats holds the memory statistics for a container +type MemoryStats = schema1.MemoryStats + +// ProcessorStats holds the processor statistics for a container +type ProcessorStats = schema1.ProcessorStats + +// StorageStats holds the storage statistics for a container +type StorageStats = schema1.StorageStats + +// NetworkStats holds the network statistics for a container +type NetworkStats = schema1.NetworkStats + +// Statistics is the structure returned by a statistics call on a container +type Statistics = schema1.Statistics + +// ProcessList is the structure of an item returned by a ProcessList call on a container +type ProcessListItem = schema1.ProcessListItem + +// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container +type MappedVirtualDiskController = schema1.MappedVirtualDiskController + +// Type of Request Support in ModifySystem +type RequestType = schema1.RequestType + +// Type of Resource Support in ModifySystem +type ResourceType = schema1.ResourceType + +type GuestDefinedCapabilities = schema1.GuestDefinedCapabilities + +type ResourceModificationRequestResponse = schema1.ResourceModificationRequestResponse + +// RequestType const +const ( + Add RequestType = "Add" + Remove RequestType = "Remove" + Network ResourceType = "Network" +) diff --git a/hcs/internal/schema1/schema1.go b/hcs/internal/schema1/schema1.go new file mode 100644 index 0000000000..3bd40d9da3 --- /dev/null +++ b/hcs/internal/schema1/schema1.go @@ -0,0 +1,133 @@ +//go:build windows + +package schema1 + +import ( + "time" + + "github.com/Microsoft/go-winio/pkg/guid" + hcsschema "github.com/Microsoft/hcsshim/hcs/internal/schema2" +) + +// ContainerProperties holds the properties for a container and the processes running in that container +type ContainerProperties struct { + ID string `json:"Id"` + State string + Name string + SystemType string + RuntimeOSType string `json:"RuntimeOsType,omitempty"` + Owner string + SiloGUID string `json:"SiloGuid,omitempty"` + RuntimeID guid.GUID `json:"RuntimeId,omitempty"` + IsRuntimeTemplate bool `json:",omitempty"` + RuntimeImagePath string `json:",omitempty"` + Stopped bool `json:",omitempty"` + ExitType string `json:",omitempty"` + AreUpdatesPending bool `json:",omitempty"` + ObRoot string `json:",omitempty"` + Statistics Statistics `json:",omitempty"` + ProcessList []ProcessListItem `json:",omitempty"` + MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"` + GuestConnectionInfo GuestConnectionInfo `json:",omitempty"` +} + +// MemoryStats holds the memory statistics for a container +type MemoryStats struct { + UsageCommitBytes uint64 `json:"MemoryUsageCommitBytes,omitempty"` + UsageCommitPeakBytes uint64 `json:"MemoryUsageCommitPeakBytes,omitempty"` + UsagePrivateWorkingSetBytes uint64 `json:"MemoryUsagePrivateWorkingSetBytes,omitempty"` +} + +// ProcessorStats holds the processor statistics for a container +type ProcessorStats struct { + TotalRuntime100ns uint64 `json:",omitempty"` + RuntimeUser100ns uint64 `json:",omitempty"` + RuntimeKernel100ns uint64 `json:",omitempty"` +} + +// StorageStats holds the storage statistics for a container +type StorageStats struct { + ReadCountNormalized uint64 `json:",omitempty"` + ReadSizeBytes uint64 `json:",omitempty"` + WriteCountNormalized uint64 `json:",omitempty"` + WriteSizeBytes uint64 `json:",omitempty"` +} + +// NetworkStats holds the network statistics for a container +type NetworkStats struct { + BytesReceived uint64 `json:",omitempty"` + BytesSent uint64 `json:",omitempty"` + PacketsReceived uint64 `json:",omitempty"` + PacketsSent uint64 `json:",omitempty"` + DroppedPacketsIncoming uint64 `json:",omitempty"` + DroppedPacketsOutgoing uint64 `json:",omitempty"` + EndpointId string `json:",omitempty"` + InstanceId string `json:",omitempty"` +} + +// Statistics is the structure returned by a statistics call on a container +type Statistics struct { + Timestamp time.Time `json:",omitempty"` + ContainerStartTime time.Time `json:",omitempty"` + Uptime100ns uint64 `json:",omitempty"` + Memory MemoryStats `json:",omitempty"` + Processor ProcessorStats `json:",omitempty"` + Storage StorageStats `json:",omitempty"` + Network []NetworkStats `json:",omitempty"` +} + +// ProcessList is the structure of an item returned by a ProcessList call on a container +type ProcessListItem struct { + CreateTimestamp time.Time `json:",omitempty"` + ImageName string `json:",omitempty"` + KernelTime100ns uint64 `json:",omitempty"` + MemoryCommitBytes uint64 `json:",omitempty"` + MemoryWorkingSetPrivateBytes uint64 `json:",omitempty"` + MemoryWorkingSetSharedBytes uint64 `json:",omitempty"` + ProcessId uint32 `json:",omitempty"` + UserTime100ns uint64 `json:",omitempty"` +} + +// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container +type MappedVirtualDiskController struct { + MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"` +} + +type MappedVirtualDisk struct { + HostPath string `json:",omitempty"` // Path to VHD on the host + ContainerPath string // Platform-specific mount point path in the container + CreateInUtilityVM bool `json:",omitempty"` + ReadOnly bool `json:",omitempty"` + Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing" + AttachOnly bool `json:",omitempty"` +} + +// GuestDefinedCapabilities is part of the GuestConnectionInfo returned by a GuestConnection call on a utility VM +type GuestDefinedCapabilities struct { + NamespaceAddRequestSupported bool `json:",omitempty"` + SignalProcessSupported bool `json:",omitempty"` + DumpStacksSupported bool `json:",omitempty"` + DeleteContainerStateSupported bool `json:",omitempty"` + UpdateContainerSupported bool `json:",omitempty"` +} + +// GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM +type GuestConnectionInfo struct { + SupportedSchemaVersions []hcsschema.Version `json:",omitempty"` + ProtocolVersion uint32 `json:",omitempty"` + GuestDefinedCapabilities GuestDefinedCapabilities `json:",omitempty"` +} + +// Type of Request Support in ModifySystem +type RequestType string + +// Type of Resource Support in ModifySystem +type ResourceType string + +// ResourceModificationRequestResponse is the structure used to send request to the container to modify the system +// Supported resource types are Network and Request Types are Add/Remove +type ResourceModificationRequestResponse struct { + Resource ResourceType `json:"ResourceType"` + Data interface{} `json:"Settings"` + Request RequestType `json:"RequestType,omitempty"` +} diff --git a/internal/hcs/schema2/version.go b/hcs/internal/schema2/version.go similarity index 100% rename from internal/hcs/schema2/version.go rename to hcs/internal/schema2/version.go diff --git a/internal/cow/cow.go b/internal/cow/cow.go index b60cd383b6..691fa2a5e7 100644 --- a/internal/cow/cow.go +++ b/internal/cow/cow.go @@ -6,6 +6,7 @@ import ( "context" "io" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/hcs/schema1" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) @@ -73,7 +74,7 @@ type Container interface { // ID returns the container ID. ID() string // Properties returns the requested container properties targeting a V1 schema container. - Properties(ctx context.Context, types ...schema1.PropertyType) (*schema1.ContainerProperties, error) + Properties(ctx context.Context, types ...schema1.PropertyType) (*hcstypes.ContainerProperties, error) // PropertiesV2 returns the requested container properties targeting a V2 schema container. PropertiesV2(ctx context.Context, types ...hcsschema.PropertyType) (*hcsschema.Properties, error) // Start starts a container. diff --git a/internal/gcs/container.go b/internal/gcs/container.go index a64408b834..d6e9591e88 100644 --- a/internal/gcs/container.go +++ b/internal/gcs/container.go @@ -8,6 +8,7 @@ import ( "sync" "time" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs/schema1" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" @@ -138,7 +139,7 @@ func (c *Container) Modify(ctx context.Context, config interface{}) (err error) } // Properties returns the requested container properties targeting a V1 schema container. -func (c *Container) Properties(ctx context.Context, types ...schema1.PropertyType) (_ *schema1.ContainerProperties, err error) { +func (c *Container) Properties(ctx context.Context, types ...schema1.PropertyType) (_ *hcstypes.ContainerProperties, err error) { ctx, span := oc.StartSpan(ctx, "gcs::Container::Properties", oc.WithClientSpanKind) defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -153,7 +154,7 @@ func (c *Container) Properties(ctx context.Context, types ...schema1.PropertyTyp if err != nil { return nil, err } - return (*schema1.ContainerProperties)(&resp.Properties), nil + return (*hcstypes.ContainerProperties)(&resp.Properties), nil } // PropertiesV2 returns the requested container properties targeting a V2 schema container. diff --git a/internal/gcs/guestcaps.go b/internal/gcs/guestcaps.go index 22ca548d3b..3155a4a82a 100644 --- a/internal/gcs/guestcaps.go +++ b/internal/gcs/guestcaps.go @@ -6,8 +6,8 @@ import ( "encoding/json" "fmt" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/guest/prot" - "github.com/Microsoft/hcsshim/internal/hcs/schema1" ) // GuestDefinedCapabilities is an interface for different guest defined capabilities. @@ -82,7 +82,7 @@ func (l *LCOWGuestDefinedCapabilities) IsDeleteContainerStateSupported() bool { var _ GuestDefinedCapabilities = &WCOWGuestDefinedCapabilities{} type WCOWGuestDefinedCapabilities struct { - schema1.GuestDefinedCapabilities + hcstypes.GuestDefinedCapabilities } func (w *WCOWGuestDefinedCapabilities) IsNamespaceAddRequestSupported() bool { diff --git a/internal/gcs/protocol.go b/internal/gcs/protocol.go index 7aeeb4991f..7bebb2c3bf 100644 --- a/internal/gcs/protocol.go +++ b/internal/gcs/protocol.go @@ -8,6 +8,7 @@ import ( "strconv" "github.com/Microsoft/go-winio/pkg/guid" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/hcs/schema1" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) @@ -321,7 +322,7 @@ type gcsCapabilities struct { SendHostStartMessage bool HvSocketConfigOnStartup bool SendLifecycleNotifications bool - SupportedSchemaVersions []hcsschema.Version + SupportedSchemaVersions []hcstypes.Version RuntimeOsType string GuestDefinedCapabilities json.RawMessage } @@ -340,14 +341,14 @@ type containerWaitForProcessResponse struct { ExitCode uint32 } -type containerProperties schema1.ContainerProperties +type containerProperties hcstypes.ContainerProperties func (p *containerProperties) MarshalText() ([]byte, error) { - return json.Marshal((*schema1.ContainerProperties)(p)) + return json.Marshal((*hcstypes.ContainerProperties)(p)) } func (p *containerProperties) UnmarshalText(b []byte) error { - return json.Unmarshal(b, (*schema1.ContainerProperties)(p)) + return json.Unmarshal(b, (*hcstypes.ContainerProperties)(p)) } type containerPropertiesV2 hcsschema.Properties diff --git a/internal/hcs/schema1/schema1.go b/internal/hcs/schema1/schema1.go index d1f219cfad..3e3a3733ef 100644 --- a/internal/hcs/schema1/schema1.go +++ b/internal/hcs/schema1/schema1.go @@ -4,10 +4,6 @@ package schema1 import ( "encoding/json" - "time" - - "github.com/Microsoft/go-winio/pkg/guid" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" ) // ProcessConfig is used as both the input of Container.CreateProcess @@ -129,124 +125,3 @@ const ( type PropertyQuery struct { PropertyTypes []PropertyType `json:",omitempty"` } - -// ContainerProperties holds the properties for a container and the processes running in that container -type ContainerProperties struct { - ID string `json:"Id"` - State string - Name string - SystemType string - RuntimeOSType string `json:"RuntimeOsType,omitempty"` - Owner string - SiloGUID string `json:"SiloGuid,omitempty"` - RuntimeID guid.GUID `json:"RuntimeId,omitempty"` - IsRuntimeTemplate bool `json:",omitempty"` - RuntimeImagePath string `json:",omitempty"` - Stopped bool `json:",omitempty"` - ExitType string `json:",omitempty"` - AreUpdatesPending bool `json:",omitempty"` - ObRoot string `json:",omitempty"` - Statistics Statistics `json:",omitempty"` - ProcessList []ProcessListItem `json:",omitempty"` - MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"` - GuestConnectionInfo GuestConnectionInfo `json:",omitempty"` -} - -// MemoryStats holds the memory statistics for a container -type MemoryStats struct { - UsageCommitBytes uint64 `json:"MemoryUsageCommitBytes,omitempty"` - UsageCommitPeakBytes uint64 `json:"MemoryUsageCommitPeakBytes,omitempty"` - UsagePrivateWorkingSetBytes uint64 `json:"MemoryUsagePrivateWorkingSetBytes,omitempty"` -} - -// ProcessorStats holds the processor statistics for a container -type ProcessorStats struct { - TotalRuntime100ns uint64 `json:",omitempty"` - RuntimeUser100ns uint64 `json:",omitempty"` - RuntimeKernel100ns uint64 `json:",omitempty"` -} - -// StorageStats holds the storage statistics for a container -type StorageStats struct { - ReadCountNormalized uint64 `json:",omitempty"` - ReadSizeBytes uint64 `json:",omitempty"` - WriteCountNormalized uint64 `json:",omitempty"` - WriteSizeBytes uint64 `json:",omitempty"` -} - -// NetworkStats holds the network statistics for a container -type NetworkStats struct { - BytesReceived uint64 `json:",omitempty"` - BytesSent uint64 `json:",omitempty"` - PacketsReceived uint64 `json:",omitempty"` - PacketsSent uint64 `json:",omitempty"` - DroppedPacketsIncoming uint64 `json:",omitempty"` - DroppedPacketsOutgoing uint64 `json:",omitempty"` - EndpointId string `json:",omitempty"` - InstanceId string `json:",omitempty"` -} - -// Statistics is the structure returned by a statistics call on a container -type Statistics struct { - Timestamp time.Time `json:",omitempty"` - ContainerStartTime time.Time `json:",omitempty"` - Uptime100ns uint64 `json:",omitempty"` - Memory MemoryStats `json:",omitempty"` - Processor ProcessorStats `json:",omitempty"` - Storage StorageStats `json:",omitempty"` - Network []NetworkStats `json:",omitempty"` -} - -// ProcessList is the structure of an item returned by a ProcessList call on a container -type ProcessListItem struct { - CreateTimestamp time.Time `json:",omitempty"` - ImageName string `json:",omitempty"` - KernelTime100ns uint64 `json:",omitempty"` - MemoryCommitBytes uint64 `json:",omitempty"` - MemoryWorkingSetPrivateBytes uint64 `json:",omitempty"` - MemoryWorkingSetSharedBytes uint64 `json:",omitempty"` - ProcessId uint32 `json:",omitempty"` - UserTime100ns uint64 `json:",omitempty"` -} - -// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container -type MappedVirtualDiskController struct { - MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"` -} - -// GuestDefinedCapabilities is part of the GuestConnectionInfo returned by a GuestConnection call on a utility VM -type GuestDefinedCapabilities struct { - NamespaceAddRequestSupported bool `json:",omitempty"` - SignalProcessSupported bool `json:",omitempty"` - DumpStacksSupported bool `json:",omitempty"` - DeleteContainerStateSupported bool `json:",omitempty"` - UpdateContainerSupported bool `json:",omitempty"` -} - -// GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM -type GuestConnectionInfo struct { - SupportedSchemaVersions []hcsschema.Version `json:",omitempty"` - ProtocolVersion uint32 `json:",omitempty"` - GuestDefinedCapabilities GuestDefinedCapabilities `json:",omitempty"` -} - -// Type of Request Support in ModifySystem -type RequestType string - -// Type of Resource Support in ModifySystem -type ResourceType string - -// RequestType const -const ( - Add RequestType = "Add" - Remove RequestType = "Remove" - Network ResourceType = "Network" -) - -// ResourceModificationRequestResponse is the structure used to send request to the container to modify the system -// Supported resource types are Network and Request Types are Add/Remove -type ResourceModificationRequestResponse struct { - Resource ResourceType `json:"ResourceType"` - Data interface{} `json:"Settings"` - Request RequestType `json:"RequestType,omitempty"` -} diff --git a/internal/hcs/schema2/compute_system.go b/internal/hcs/schema2/compute_system.go index 10cea67e04..cad33dd481 100644 --- a/internal/hcs/schema2/compute_system.go +++ b/internal/hcs/schema2/compute_system.go @@ -9,10 +9,14 @@ package hcsschema +import ( + hcstypes "github.com/Microsoft/hcsshim/hcs" +) + type ComputeSystem struct { Owner string `json:"Owner,omitempty"` - SchemaVersion *Version `json:"SchemaVersion,omitempty"` + SchemaVersion *hcstypes.Version `json:"SchemaVersion,omitempty"` HostingSystemId string `json:"HostingSystemId,omitempty"` diff --git a/internal/hcs/schema2/guest_connection_info.go b/internal/hcs/schema2/guest_connection_info.go index 8a369bab71..61eeb4ee55 100644 --- a/internal/hcs/schema2/guest_connection_info.go +++ b/internal/hcs/schema2/guest_connection_info.go @@ -9,11 +9,15 @@ package hcsschema -// Information about the guest. +import ( + hcstypes "github.com/Microsoft/hcsshim/hcs" +) + +// Information about the guest. type GuestConnectionInfo struct { // Each schema version x.y stands for the range of versions a.b where a==x and b<=y. This list comes from the SupportedSchemaVersions field in GcsCapabilities. - SupportedSchemaVersions []Version `json:"SupportedSchemaVersions,omitempty"` + SupportedSchemaVersions []hcstypes.Version `json:"SupportedSchemaVersions,omitempty"` ProtocolVersion int32 `json:"ProtocolVersion,omitempty"` diff --git a/internal/hcs/schema2/hosted_system.go b/internal/hcs/schema2/hosted_system.go index ea3084bca7..a1c969ac02 100644 --- a/internal/hcs/schema2/hosted_system.go +++ b/internal/hcs/schema2/hosted_system.go @@ -9,8 +9,12 @@ package hcsschema +import ( + hcstypes "github.com/Microsoft/hcsshim/hcs" +) + type HostedSystem struct { - SchemaVersion *Version `json:"SchemaVersion,omitempty"` + SchemaVersion *hcstypes.Version `json:"SchemaVersion,omitempty"` Container *Container `json:"Container,omitempty"` } diff --git a/internal/hcs/schema2/virtual_machine.go b/internal/hcs/schema2/virtual_machine.go index 3f750466f8..e32aaee9d4 100644 --- a/internal/hcs/schema2/virtual_machine.go +++ b/internal/hcs/schema2/virtual_machine.go @@ -11,9 +11,13 @@ package hcsschema +import( + hcstypes "github.com/Microsoft/hcsshim/hcs" +) + // Configuration of a virtual machine, used during its creation to set up and/or use resources. type VirtualMachine struct { - Version *Version `json:"Version,omitempty"` + Version *hcstypes.Version `json:"Version,omitempty"` // When set to true, the virtual machine will treat a reset as a stop, releasing resources and cleaning up state. StopOnReset bool `json:"StopOnReset,omitempty"` Chipset *Chipset `json:"Chipset,omitempty"` diff --git a/internal/hcs/system.go b/internal/hcs/system.go index 81d60ed434..2fc587f4e6 100644 --- a/internal/hcs/system.go +++ b/internal/hcs/system.go @@ -12,6 +12,7 @@ import ( "syscall" "time" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/hcs/schema1" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" @@ -165,7 +166,7 @@ func (computeSystem *System) IsOCI() bool { } // GetComputeSystems gets a list of the compute systems on the system that match the query -func GetComputeSystems(ctx context.Context, q schema1.ComputeSystemQuery) ([]schema1.ContainerProperties, error) { +func GetComputeSystems(ctx context.Context, q schema1.ComputeSystemQuery) ([]hcstypes.ContainerProperties, error) { operation := "hcs::GetComputeSystems" queryb, err := json.Marshal(q) @@ -182,7 +183,7 @@ func GetComputeSystems(ctx context.Context, q schema1.ComputeSystemQuery) ([]sch if computeSystemsJSON == "" { return nil, ErrUnexpectedValue } - computeSystems := []schema1.ContainerProperties{} + computeSystems := []hcstypes.ContainerProperties{} if err = json.Unmarshal([]byte(computeSystemsJSON), &computeSystems); err != nil { return nil, err } @@ -344,7 +345,7 @@ func (computeSystem *System) ExitError() error { } // Properties returns the requested container properties targeting a V1 schema container. -func (computeSystem *System) Properties(ctx context.Context, types ...schema1.PropertyType) (*schema1.ContainerProperties, error) { +func (computeSystem *System) Properties(ctx context.Context, types ...schema1.PropertyType) (*hcstypes.ContainerProperties, error) { computeSystem.handleLock.RLock() defer computeSystem.handleLock.RUnlock() @@ -368,7 +369,7 @@ func (computeSystem *System) Properties(ctx context.Context, types ...schema1.Pr if propertiesJSON == "" { return nil, ErrUnexpectedValue } - properties := &schema1.ContainerProperties{} + properties := &hcstypes.ContainerProperties{} if err := json.Unmarshal([]byte(propertiesJSON), properties); err != nil { return nil, makeSystemError(computeSystem, operation, err, nil) } diff --git a/internal/hcsoci/create.go b/internal/hcsoci/create.go index 774449b7ee..6348a82401 100644 --- a/internal/hcsoci/create.go +++ b/internal/hcsoci/create.go @@ -12,6 +12,7 @@ import ( "strconv" "github.com/Microsoft/go-winio/pkg/guid" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/guestpath" "github.com/Microsoft/hcsshim/internal/hcs" @@ -38,12 +39,12 @@ var ( // layer, and scratch is the RW layer. This is for historical reasons only. 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) + 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 *hcstypes.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) LCOWLayers *layers.LCOWLayers WCOWLayers layers.WCOWLayers @@ -64,9 +65,9 @@ type CreateOptions struct { type createOptionsInternal struct { *CreateOptions - actualSchemaVersion *hcsschema.Version // Calculated based on Windows build and optional caller-supplied override - actualID string // Identifier for the container - actualOwner string // Owner for the container + actualSchemaVersion *hcstypes.Version // Calculated based on Windows build and optional caller-supplied override + actualID string // Identifier for the container + actualOwner string // Owner for the container actualNetworkNamespace string ccgState *hcsschema.ContainerCredentialGuardState // Container Credential Guard information to be attached to HCS container document diff --git a/internal/hcsoci/hcsdoc_lcow.go b/internal/hcsoci/hcsdoc_lcow.go index db94d73df0..69220aa1a7 100644 --- a/internal/hcsoci/hcsdoc_lcow.go +++ b/internal/hcsoci/hcsdoc_lcow.go @@ -7,7 +7,7 @@ import ( "context" "encoding/json" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/oci" "github.com/Microsoft/hcsshim/internal/schemaversion" @@ -77,7 +77,7 @@ func setWindowsDevices(coi *createOptionsInternal, spec *specs.Spec) { } type linuxHostedSystem struct { - SchemaVersion *hcsschema.Version + SchemaVersion *hcstypes.Version OciBundlePath string OciSpecification *specs.Spec diff --git a/internal/jobcontainers/jobcontainer.go b/internal/jobcontainers/jobcontainer.go index 63cd709564..64cb7e294a 100644 --- a/internal/jobcontainers/jobcontainer.go +++ b/internal/jobcontainers/jobcontainer.go @@ -14,6 +14,7 @@ import ( "unsafe" "github.com/Microsoft/go-winio/pkg/guid" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/conpty" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/exec" @@ -570,7 +571,7 @@ func (c *JobContainer) PropertiesV2(ctx context.Context, types ...hcsschema.Prop // Properties returns properties relating to the job container. This is an HCS construct but // to adhere to the interface for containers on Windows it is partially implemented. The only // supported property is schema1.PropertyTypeProcessList. -func (c *JobContainer) Properties(ctx context.Context, types ...schema1.PropertyType) (*schema1.ContainerProperties, error) { +func (c *JobContainer) Properties(ctx context.Context, types ...schema1.PropertyType) (*hcstypes.ContainerProperties, error) { if len(types) == 0 { return nil, errors.New("no property types supplied for Properties call") } @@ -578,9 +579,9 @@ func (c *JobContainer) Properties(ctx context.Context, types ...schema1.Property return nil, errors.New("ProcessList is the only supported property type for job containers") } - var processList []schema1.ProcessListItem + var processList []hcstypes.ProcessListItem err := forEachProcessInfo(c.job, func(procInfo *winapi.SYSTEM_PROCESS_INFORMATION) { - proc := schema1.ProcessListItem{ + proc := hcstypes.ProcessListItem{ CreateTimestamp: time.Unix(0, procInfo.CreateTime), ProcessId: uint32(procInfo.UniqueProcessID), ImageName: procInfo.ImageName.String(), @@ -596,7 +597,7 @@ func (c *JobContainer) Properties(ctx context.Context, types ...schema1.Property return nil, errors.Wrap(err, "failed to get process ") } - return &schema1.ContainerProperties{ProcessList: processList}, nil + return &hcstypes.ContainerProperties{ProcessList: processList}, nil } // Terminate terminates the job object (kills every process in the job). diff --git a/internal/schemaversion/schemaversion.go b/internal/schemaversion/schemaversion.go index 1f847c8f56..01467d093e 100644 --- a/internal/schemaversion/schemaversion.go +++ b/internal/schemaversion/schemaversion.go @@ -7,28 +7,28 @@ import ( "encoding/json" "fmt" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/osversion" "github.com/sirupsen/logrus" ) // SchemaV10 makes it easy for callers to get a v1.0 schema version object -func SchemaV10() *hcsschema.Version { - return &hcsschema.Version{Major: 1, Minor: 0} +func SchemaV10() *hcstypes.Version { + return &hcstypes.Version{Major: 1, Minor: 0} } // SchemaV21 makes it easy for callers to get a v2.1 schema version object -func SchemaV21() *hcsschema.Version { - return &hcsschema.Version{Major: 2, Minor: 1} +func SchemaV21() *hcstypes.Version { + return &hcstypes.Version{Major: 2, Minor: 1} } // SchemaV25 makes it easy for callers to get a v2.5 schema version object. -func SchemaV25() *hcsschema.Version { - return &hcsschema.Version{Major: 2, Minor: 5} +func SchemaV25() *hcstypes.Version { + return &hcstypes.Version{Major: 2, Minor: 5} } // isSupported determines if a given schema version is supported -func IsSupported(sv *hcsschema.Version) error { +func IsSupported(sv *hcstypes.Version) error { if IsV10(sv) { return nil } @@ -50,7 +50,7 @@ func IsSupported(sv *hcsschema.Version) error { // IsV10 determines if a given schema version object is 1.0. This was the only thing // supported in RS1..3. It lives on in RS5, but will be deprecated in a future release. -func IsV10(sv *hcsschema.Version) bool { +func IsV10(sv *hcstypes.Version) bool { if sv.Major == 1 && sv.Minor == 0 { return true } @@ -60,7 +60,7 @@ func IsV10(sv *hcsschema.Version) bool { // IsV21 determines if a given schema version object is 2.0. This was introduced in // RS4, but not fully implemented. Recommended for applications using HCS in RS5 // onwards. -func IsV21(sv *hcsschema.Version) bool { +func IsV21(sv *hcstypes.Version) bool { if sv.Major == 2 && sv.Minor == 1 { return true } @@ -68,7 +68,7 @@ func IsV21(sv *hcsschema.Version) bool { } // V25 schema introduced much later. Required to support SNP. -func IsV25(sv *hcsschema.Version) bool { +func IsV25(sv *hcstypes.Version) bool { if sv.Major == 2 && sv.Minor == 5 { return true } @@ -76,7 +76,7 @@ func IsV25(sv *hcsschema.Version) bool { } // String returns a JSON encoding of a schema version object -func String(sv *hcsschema.Version) string { +func String(sv *hcstypes.Version) string { b, err := json.Marshal(sv) if err != nil { return "" @@ -86,7 +86,7 @@ func String(sv *hcsschema.Version) string { // DetermineSchemaVersion works out what schema version to use based on build and // requested option. -func DetermineSchemaVersion(requestedSV *hcsschema.Version) *hcsschema.Version { +func DetermineSchemaVersion(requestedSV *hcstypes.Version) *hcstypes.Version { sv := SchemaV10() if osversion.Build() >= osversion.RS5 { sv = SchemaV21() diff --git a/test/go.mod b/test/go.mod index b514212f11..359c773fda 100644 --- a/test/go.mod +++ b/test/go.mod @@ -1,10 +1,13 @@ module github.com/Microsoft/hcsshim/test -go 1.21 +go 1.21.0 + +toolchain go1.21.5 require ( github.com/Microsoft/go-winio v0.6.2 github.com/Microsoft/hcsshim v0.12.2 + github.com/Microsoft/hcsshim/hcs v0.0.0 github.com/containerd/cgroups/v3 v3.0.3 github.com/containerd/containerd v1.7.21 github.com/containerd/containerd/api v1.7.19 @@ -126,4 +129,7 @@ require ( tags.cncf.io/container-device-interface/specs-go v0.7.0 // indirect ) -replace github.com/Microsoft/hcsshim => ../ +replace ( + github.com/Microsoft/hcsshim => ../ + github.com/Microsoft/hcsshim/hcs => ../hcs +) diff --git a/test/internal/schemaversion_test.go b/test/internal/schemaversion_test.go index 873a4148a3..ded488bb04 100644 --- a/test/internal/schemaversion_test.go +++ b/test/internal/schemaversion_test.go @@ -6,7 +6,7 @@ import ( "io" "testing" - hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" + hcstypes "github.com/Microsoft/hcsshim/hcs" "github.com/Microsoft/hcsshim/internal/schemaversion" "github.com/Microsoft/hcsshim/osversion" "github.com/sirupsen/logrus" @@ -32,7 +32,7 @@ func TestDetermineSchemaVersion(t *testing.T) { if sv := schemaversion.DetermineSchemaVersion(schemaversion.SchemaV10()); !schemaversion.IsV10(sv) { t.Fatalf("expected requested v1") } - if sv := schemaversion.DetermineSchemaVersion(&hcsschema.Version{}); !schemaversion.IsV21(sv) { + if sv := schemaversion.DetermineSchemaVersion(&hcstypes.Version{}); !schemaversion.IsV21(sv) { t.Fatalf("expected requested v2") } @@ -53,7 +53,7 @@ func TestDetermineSchemaVersion(t *testing.T) { if sv := schemaversion.DetermineSchemaVersion(schemaversion.SchemaV10()); !schemaversion.IsV10(sv) { t.Fatalf("expected requested v1") } - if sv := schemaversion.DetermineSchemaVersion(&hcsschema.Version{}); !schemaversion.IsV10(sv) { + if sv := schemaversion.DetermineSchemaVersion(&hcstypes.Version{}); !schemaversion.IsV10(sv) { t.Fatalf("expected requested v1") } diff --git a/vendor/github.com/Microsoft/hcsshim/hcs/helpers.go b/vendor/github.com/Microsoft/hcsshim/hcs/helpers.go new file mode 100644 index 0000000000..49b27a855e --- /dev/null +++ b/vendor/github.com/Microsoft/hcsshim/hcs/helpers.go @@ -0,0 +1,7 @@ +package hcs + +import ( + hcsschema "github.com/Microsoft/hcsshim/hcs/internal/schema2" +) + +type Version = hcsschema.Version diff --git a/vendor/github.com/Microsoft/hcsshim/hcs/helpers_windows.go b/vendor/github.com/Microsoft/hcsshim/hcs/helpers_windows.go new file mode 100644 index 0000000000..23bfc7ada5 --- /dev/null +++ b/vendor/github.com/Microsoft/hcsshim/hcs/helpers_windows.go @@ -0,0 +1,48 @@ +//go:build windows + +package hcs + +import ( + "github.com/Microsoft/hcsshim/hcs/internal/schema1" +) + +// ContainerProperties holds the properties for a container and the processes running in that container +type ContainerProperties = schema1.ContainerProperties + +// MemoryStats holds the memory statistics for a container +type MemoryStats = schema1.MemoryStats + +// ProcessorStats holds the processor statistics for a container +type ProcessorStats = schema1.ProcessorStats + +// StorageStats holds the storage statistics for a container +type StorageStats = schema1.StorageStats + +// NetworkStats holds the network statistics for a container +type NetworkStats = schema1.NetworkStats + +// Statistics is the structure returned by a statistics call on a container +type Statistics = schema1.Statistics + +// ProcessList is the structure of an item returned by a ProcessList call on a container +type ProcessListItem = schema1.ProcessListItem + +// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container +type MappedVirtualDiskController = schema1.MappedVirtualDiskController + +// Type of Request Support in ModifySystem +type RequestType = schema1.RequestType + +// Type of Resource Support in ModifySystem +type ResourceType = schema1.ResourceType + +type GuestDefinedCapabilities = schema1.GuestDefinedCapabilities + +type ResourceModificationRequestResponse = schema1.ResourceModificationRequestResponse + +// RequestType const +const ( + Add RequestType = "Add" + Remove RequestType = "Remove" + Network ResourceType = "Network" +) diff --git a/vendor/github.com/Microsoft/hcsshim/hcs/internal/schema1/schema1.go b/vendor/github.com/Microsoft/hcsshim/hcs/internal/schema1/schema1.go new file mode 100644 index 0000000000..3f7037cdd1 --- /dev/null +++ b/vendor/github.com/Microsoft/hcsshim/hcs/internal/schema1/schema1.go @@ -0,0 +1,133 @@ +//go:build windows + +package schema1 + +import ( + "time" + + "github.com/Microsoft/go-winio/pkg/guid" + hcsschema "github.com/Microsoft/hcsshim/hcs/internal/schema2" +) + +// ContainerProperties holds the properties for a container and the processes running in that container +type ContainerProperties struct { + ID string `json:"Id"` + State string + Name string + SystemType string + RuntimeOSType string `json:"RuntimeOsType,omitempty"` + Owner string + SiloGUID string `json:"SiloGuid,omitempty"` + RuntimeID guid.GUID `json:"RuntimeId,omitempty"` + IsRuntimeTemplate bool `json:",omitempty"` + RuntimeImagePath string `json:",omitempty"` + Stopped bool `json:",omitempty"` + ExitType string `json:",omitempty"` + AreUpdatesPending bool `json:",omitempty"` + ObRoot string `json:",omitempty"` + Statistics Statistics `json:",omitempty"` + ProcessList []ProcessListItem `json:",omitempty"` + MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"` + GuestConnectionInfo GuestConnectionInfo `json:",omitempty"` +} + +// MemoryStats holds the memory statistics for a container +type MemoryStats struct { + UsageCommitBytes uint64 `json:"MemoryUsageCommitBytes,omitempty"` + UsageCommitPeakBytes uint64 `json:"MemoryUsageCommitPeakBytes,omitempty"` + UsagePrivateWorkingSetBytes uint64 `json:"MemoryUsagePrivateWorkingSetBytes,omitempty"` +} + +// ProcessorStats holds the processor statistics for a container +type ProcessorStats struct { + TotalRuntime100ns uint64 `json:",omitempty"` + RuntimeUser100ns uint64 `json:",omitempty"` + RuntimeKernel100ns uint64 `json:",omitempty"` +} + +// StorageStats holds the storage statistics for a container +type StorageStats struct { + ReadCountNormalized uint64 `json:",omitempty"` + ReadSizeBytes uint64 `json:",omitempty"` + WriteCountNormalized uint64 `json:",omitempty"` + WriteSizeBytes uint64 `json:",omitempty"` +} + +// NetworkStats holds the network statistics for a container +type NetworkStats struct { + BytesReceived uint64 `json:",omitempty"` + BytesSent uint64 `json:",omitempty"` + PacketsReceived uint64 `json:",omitempty"` + PacketsSent uint64 `json:",omitempty"` + DroppedPacketsIncoming uint64 `json:",omitempty"` + DroppedPacketsOutgoing uint64 `json:",omitempty"` + EndpointId string `json:",omitempty"` + InstanceId string `json:",omitempty"` +} + +// Statistics is the structure returned by a statistics call on a container +type Statistics struct { + Timestamp time.Time `json:",omitempty"` + ContainerStartTime time.Time `json:",omitempty"` + Uptime100ns uint64 `json:",omitempty"` + Memory MemoryStats `json:",omitempty"` + Processor ProcessorStats `json:",omitempty"` + Storage StorageStats `json:",omitempty"` + Network []NetworkStats `json:",omitempty"` +} + +// ProcessList is the structure of an item returned by a ProcessList call on a container +type ProcessListItem struct { + CreateTimestamp time.Time `json:",omitempty"` + ImageName string `json:",omitempty"` + KernelTime100ns uint64 `json:",omitempty"` + MemoryCommitBytes uint64 `json:",omitempty"` + MemoryWorkingSetPrivateBytes uint64 `json:",omitempty"` + MemoryWorkingSetSharedBytes uint64 `json:",omitempty"` + ProcessId uint32 `json:",omitempty"` + UserTime100ns uint64 `json:",omitempty"` +} + +// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container +type MappedVirtualDiskController struct { + MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"` +} + +type MappedVirtualDisk struct { + HostPath string `json:",omitempty"` // Path to VHD on the host + ContainerPath string // Platform-specific mount point path in the container + CreateInUtilityVM bool `json:",omitempty"` + ReadOnly bool `json:",omitempty"` + Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing" + AttachOnly bool `json:",omitempty"` +} + +// GuestDefinedCapabilities is part of the GuestConnectionInfo returned by a GuestConnection call on a utility VM +type GuestDefinedCapabilities struct { + NamespaceAddRequestSupported bool `json:",omitempty"` + SignalProcessSupported bool `json:",omitempty"` + DumpStacksSupported bool `json:",omitempty"` + DeleteContainerStateSupported bool `json:",omitempty"` + UpdateContainerSupported bool `json:",omitempty"` +} + +// GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM +type GuestConnectionInfo struct { + SupportedSchemaVersions []hcsschema.Version `json:",omitempty"` + ProtocolVersion uint32 `json:",omitempty"` + GuestDefinedCapabilities GuestDefinedCapabilities `json:",omitempty"` +} + +// Type of Request Support in ModifySystem +type RequestType string + +// Type of Resource Support in ModifySystem +type ResourceType string + +// ResourceModificationRequestResponse is the structure used to send request to the container to modify the system +// Supported resource types are Network and Request Types are Add/Remove +type ResourceModificationRequestResponse struct { + Resource ResourceType `json:"ResourceType"` + Data interface{} `json:"Settings"` + Request RequestType `json:"RequestType,omitempty"` +} diff --git a/vendor/github.com/Microsoft/hcsshim/hcs/internal/schema2/version.go b/vendor/github.com/Microsoft/hcsshim/hcs/internal/schema2/version.go new file mode 100644 index 0000000000..2abfccca31 --- /dev/null +++ b/vendor/github.com/Microsoft/hcsshim/hcs/internal/schema2/version.go @@ -0,0 +1,16 @@ +/* + * HCS API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 2.1 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package hcsschema + +type Version struct { + Major int32 `json:"Major,omitempty"` + + Minor int32 `json:"Minor,omitempty"` +} diff --git a/vendor/modules.txt b/vendor/modules.txt index feb9a0510e..67078b4b9d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -21,6 +21,11 @@ github.com/Microsoft/go-winio/pkg/guid github.com/Microsoft/go-winio/pkg/process github.com/Microsoft/go-winio/tools/mkwinsyscall github.com/Microsoft/go-winio/vhd +# github.com/Microsoft/hcsshim/hcs v0.0.0 => ./hcs +## explicit; go 1.21 +github.com/Microsoft/hcsshim/hcs +github.com/Microsoft/hcsshim/hcs/internal/schema1 +github.com/Microsoft/hcsshim/hcs/internal/schema2 # github.com/OneOfOne/xxhash v1.2.8 ## explicit; go 1.11 github.com/OneOfOne/xxhash @@ -726,3 +731,4 @@ gopkg.in/yaml.v2 ## explicit; go 1.12 sigs.k8s.io/yaml sigs.k8s.io/yaml/goyaml.v2 +# github.com/Microsoft/hcsshim/hcs => ./hcs