package jobobject

import "github.com/Microsoft/hcsshim/internal/jobobject"

Index

Constants

const (
	CPULimitMin  = 1
	CPULimitMax  = 10000
	CPUWeightMin = 1
	CPUWeightMax = 9
)

Processor resource controls

Variables

var (
	ErrAlreadyClosed = errors.New("the handle has already been closed")
	ErrNotRegistered = errors.New("job is not registered to receive notifications")
)

Types

type CPURateControlType

type CPURateControlType uint32
const (
	WeightBased CPURateControlType = iota
	RateBased
)

type JobLimits

type JobLimits struct {
	CPULimit           uint32
	CPUWeight          uint32
	MemoryLimitInBytes uint64
	MaxIOPS            int64
	MaxBandwidth       int64
}

JobLimits represents the resource constraints that can be applied to a job object.

type JobObject

type JobObject struct {
	// contains filtered or unexported fields
}

JobObject is a high level wrapper around a Windows job object. Holds a handle to the job, a queue to receive iocp notifications about the lifecycle of the job and a mutex for synchronized handle access.

func Create

func Create(ctx context.Context, name string, notifications bool) (_ *JobObject, err error)

Create creates a job object.

`name` specifies the name of the job object if a named job object is desired. If name is an empty string, the job will not be assigned a name.

`notifications` specifies if the job will be registered to receive notifications. If this is false, `PollNotifications` will return immediately with error `errNotRegistered`.

Returns a JobObject structure and an error if there is one.

func (*JobObject) Assign

func (job *JobObject) Assign(pid uint32) error

Assign assigns a process to the job object.

func (*JobObject) Close

func (job *JobObject) Close() error

Close closes the job object handle.

func (*JobObject) Pids

func (job *JobObject) Pids() ([]uint32, error)

Pids returns all of the process IDs in the job object.

func (*JobObject) PollNotification

func (job *JobObject) PollNotification() (interface{}, error)

PollNotification will poll for a job object notification. This call should only be called once per job (ideally in a goroutine loop) and will block if there is not a notification ready. This call will return immediately with error `ErrNotRegistered` if the job was not registered to receive notifications during `Create`. Internally, messages will be queued and there is no worry of messages being dropped.

func (*JobObject) QueryMemoryStats

func (job *JobObject) QueryMemoryStats() (*winapi.JOBOBJECT_MEMORY_USAGE_INFORMATION, error)

QueryMemoryStats gets the memory stats for the job object.

func (*JobObject) QueryProcessorStats

func (job *JobObject) QueryProcessorStats() (*winapi.JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, error)

QueryProcessorStats gets the processor stats for the job object.

func (*JobObject) QueryStorageStats

QueryStorageStats gets the storage (I/O) stats for the job object.

func (*JobObject) SetCPULimit

func (job *JobObject) SetCPULimit(rateControlType CPURateControlType, rateControlValue uint32) error

SetCPULimit sets the CPU limit specified on the job object.

func (*JobObject) SetIOLimit

func (job *JobObject) SetIOLimit(maxBandwidth, maxIOPS int64) error

SetIOLimit sets the IO limits specified on the job object.

func (*JobObject) SetMemoryLimit

func (job *JobObject) SetMemoryLimit(memoryLimitInBytes uint64) error

SetMemoryLimit sets the memory limit specified on the job object.

func (*JobObject) SetResourceLimits

func (job *JobObject) SetResourceLimits(limits *JobLimits) error

SetResourceLimits sets resource limits on the job object (cpu, memory, storage).

func (*JobObject) Terminate

func (job *JobObject) Terminate(exitCode uint32) error

Terminate terminates the job, essentially calls TerminateProcess on every process in the job.

type MsgAllProcessesExited

type MsgAllProcessesExited struct{}

MsgAllProcessesExited is a type representing a message that every process in a job has exited.

type MsgUnimplemented

type MsgUnimplemented struct{}

MsgUnimplemented represents a message that we are aware of, but that isn't implemented currently. This should not be treated as an error.

Source Files

iocp.go jobobject.go

Version
v0.8.12
Published
Dec 15, 2020
Platform
linux/amd64
Imports
10 packages
Last checked
57 minutes ago

Tools for package owners.