package specerror

import "github.com/opencontainers/runtime-tools/specerror"

Package specerror implements runtime-spec-specific tooling for tracking RFC 2119 violations.

Index

Constants

const (
	ConfigInRootBundleDir = "This REQUIRED file MUST reside in the root of the bundle directory."

	ConfigConstName = "This REQUIRED file MUST be named `config.json`."

	ArtifactsInSingleDir = "" /* 154 byte string literal not displayed */
)

define error codes

const (
	DefaultFilesystems = "The following filesystems SHOULD be made available in each container's filesystem:"

	NSPathAbs = "This value MUST be an absolute path in the runtime mount namespace."

	NSProcInPath = "The runtime MUST place the container process in the namespace associated with that `path`."

	NSPathMatchTypeError = "The runtime MUST generate an error if `path` is not associated with a namespace of type `type`."

	NSNewNSWithoutPath = "If `path` is not specified, the runtime MUST create a new container namespace of type `type`."

	NSInheritWithoutType = "If a namespace type is not specified in the `namespaces` array, the container MUST inherit the runtime namespace of that type."

	NSErrorOnDup = "If a `namespaces` field contains duplicated namespaces with same `type`, the runtime MUST generate an error."

	UserNSMapOwnershipRO = "The runtime SHOULD NOT modify the ownership of referenced filesystems to realize the mapping."

	DevicesAvailable = "devices (array of objects, OPTIONAL) lists devices that MUST be available in the container."

	DevicesFileNotMatch = "If a file already exists at `path` that does not match the requested device, the runtime MUST generate an error."

	DevicesMajMinRequired = "`major, minor` (int64, REQUIRED unless `type` is `p`) - major, minor numbers for the device."

	DevicesErrorOnDup = "The same `type`, `major` and `minor` SHOULD NOT be used for multiple devices."

	DefaultDevices = "In addition to any devices configured with this setting, the runtime MUST also supply default devices."

	CgroupsPathAbsOrRel = "The value of `cgroupsPath` MUST be either an absolute path or a relative path."

	CgroupsAbsPathRelToMount = "In the case of an absolute path (starting with `/`), the runtime MUST take the path to be relative to the cgroups mount point."

	CgroupsPathAttach = "" /* 147 byte string literal not displayed */

	CgroupsPathError = "Runtimes MAY consider certain `cgroupsPath` values to be invalid, and MUST generate an error if this is the case."

	DevicesApplyInOrder = "The runtime MUST apply entries in the listed order."

	BlkIOWeightOrLeafWeightExist = "You MUST specify at least one of `weight` or `leafWeight` in a given entry, and MAY specify both."

	IntelRdtPIDWrite = "" /* 242 byte string literal not displayed */

	IntelRdtNoMountedResctrlError = "If no mounted `resctrl` pseudo-filesystem is available in the runtime mount namespace, the runtime MUST generate an error."

	NotManipResctrlWithoutIntelRdt = "If `intelRdt` is not set, the runtime MUST NOT manipulate any `resctrl` pseudo-filesystems."

	IntelRdtL3CacheSchemaWrite = "" /* 140 byte string literal not displayed */

	IntelRdtL3CacheSchemaNotWrite = "If `l3CacheSchema` is not set, runtimes MUST NOT write to `schemata` files in any `resctrl` pseudo-filesystems."

	SeccSyscallsNamesRequired = "`names` MUST contain at least one entry."

	MaskedPathsAbs = "" /* 188 byte string literal not displayed */

	ReadonlyPathsAbs = "" /* 168 byte string literal not displayed */
)

define error codes

const (
	// WindowsLayerFoldersRequired represents "`layerFolders` MUST contain at least one entry."
	WindowsLayerFoldersRequired = "`layerFolders` MUST contain at least one entry."
	// WindowsHyperVPresent represents "If present, the container MUST be run with Hyper-V isolation."
	WindowsHyperVPresent = "If present, the container MUST be run with Hyper-V isolation."
	// WindowsHyperVOmit represents "If omitted, the container MUST be run as a Windows Server container."
	WindowsHyperVOmit = "If omitted, the container MUST be run as a Windows Server container."
)

define error codes

const (
	SpecVersionInSemVer = "" /* 178 byte string literal not displayed */

	RootOnWindowsRequired = "On Windows, for Windows Server Containers, this field is REQUIRED."

	RootOnHyperVNotSet = "For Hyper-V Containers, this field MUST NOT be set."

	RootOnNonHyperVRequired = "On all other platforms, this field is REQUIRED."

	RootPathOnWindowsGUID = "On Windows, `path` MUST be a volume GUID path."

	RootPathOnPosixConvention = "The value SHOULD be the conventional `rootfs`."

	RootPathExist = "A directory MUST exist at the path declared by the field."

	RootReadonlyImplement = "`readonly` (bool, OPTIONAL) If true then the root filesystem MUST be read-only inside the container, defaults to false."

	RootReadonlyOnWindowsFalse = "On Windows, this field MUST be omitted or false."

	MountsInOrder = "The runtime MUST mount entries in the listed order."

	MountsDestAbs = "Destination of mount point: path inside container. This value MUST be an absolute path."

	MountsDestOnWindowsNotNested = "Windows: one mount destination MUST NOT be nested within another mount (e.g., c:\\foo and c:\\foo\\bar)."

	MountsOptionsOnWindowsROSupport = "Windows: runtimes MUST support `ro`, mounting the filesystem read-only when `ro` is given."

	ProcRequiredAtStart = "This property is REQUIRED when `start` is called."

	ProcConsoleSizeIgnore = "Runtimes MUST ignore `consoleSize` if `terminal` is `false` or unset."

	ProcCwdAbs = "cwd (string, REQUIRED) is the working directory that will be set for the executable. This value MUST be an absolute path."

	ProcArgsOneEntryRequired = "" /* 155 byte string literal not displayed */

	PosixProcRlimitsTypeGenError = "The runtime MUST generate an error for any values which cannot be mapped to a relevant kernel interface."

	PosixProcRlimitsTypeGet = "For each entry in `rlimits`, a `getrlimit(3)` on `type` MUST succeed."

	PosixProcRlimitsTypeValueError = "valid values are defined in the ... man page"

	PosixProcRlimitsSoftMatchCur = "`rlim.rlim_cur` MUST match the configured value."

	PosixProcRlimitsHardMatchMax = "`rlim.rlim_max` MUST match the configured value."

	PosixProcRlimitsErrorOnDup = "If `rlimits` contains duplicated entries with same `type`, the runtime MUST generate an error."

	LinuxProcCapError = "Any value which cannot be mapped to a relevant kernel interface MUST cause an error."

	LinuxProcOomScoreAdjSet = "If `oomScoreAdj` is set, the runtime MUST set `oom_score_adj` to the given value."

	LinuxProcOomScoreAdjNotSet = "If `oomScoreAdj` is not set, the runtime MUST NOT change the value of `oom_score_adj`."

	PlatformSpecConfOnWindowsSet = "This MUST be set if the target platform of this spec is `windows`."

	PosixHooksPathAbs = "This specification extends the IEEE standard in that `path` MUST be absolute."

	PosixHooksTimeoutPositive = "If set, `timeout` MUST be greater than zero."

	PosixHooksCalledInOrder = "Hooks MUST be called in the listed order."

	PosixHooksStateToStdin = "" /* 139 byte string literal not displayed */

	PrestartTiming = "" /* 133 byte string literal not displayed */

	PoststartTiming = "The post-start hooks MUST be called after the user-specified process is executed but before the `start` operation returns."

	PoststopTiming = "The post-stop hooks MUST be called after the container is deleted but before the `delete` operation returns."

	AnnotationsKeyValueMap = "Annotations MUST be a key-value map."

	AnnotationsKeyString = "Keys MUST be strings."

	AnnotationsKeyRequired = "Keys MUST NOT be an empty string."

	AnnotationsKeyReversedDomain = "Keys SHOULD be named using a reverse domain notation - e.g. `com.example.myKey`."

	AnnotationsKeyReservedNS = "Keys using the `org.opencontainers` namespace are reserved and MUST NOT be used by subsequent specifications."

	AnnotationsKeyIgnoreUnknown = "" /* 141 byte string literal not displayed */

	AnnotationsValueString = "Values MUST be strings."

	ExtensibilityIgnoreUnknownProp = "" /* 177 byte string literal not displayed */

	ValidValues = "" /* 140 byte string literal not displayed */
)

define error codes

const (
	// NonError represents that an input is not an error
	NonError = "the input is not an error"
	// NonRFCError represents that an error is not a rfc2119 error
	NonRFCError = "the error is not a rfc2119 error"
)
const (
	EntityOperSameContainer = "" /* 144 byte string literal not displayed */

	StateIDUniq = "`id` (string, REQUIRED) is the container's ID. This MUST be unique across all containers on this host."

	StateNewStatus = "Additional values MAY be defined by the runtime, however, they MUST be used to represent new runtime states not defined above."

	DefaultStateJSONPattern = "When serialized in JSON, the format MUST adhere to the default pattern."

	EnvCreateImplement = "The container's runtime environment MUST be created according to the configuration in `config.json`."

	EnvCreateError = "If the runtime is unable to create the environment specified in the `config.json`. it MUST generate an error."

	ProcNotRunAtResRequest = "" /* 143 byte string literal not displayed */

	ConfigUpdatesWithoutAffect = "Any updates to `config.json` after this step MUST NOT affect the container."

	PrestartHooksInvoke = "The prestart hooks MUST be invoked by the runtime."

	PrestartHookFailGenError = "If any prestart hook fails, the runtime MUST generate an error, stop the container, and continue the lifecycle at step 9."

	ProcImplement = "The runtime MUST run the user-specified program, as specified by `process`."

	PoststartHooksInvoke = "The poststart hooks MUST be invoked by the runtime."

	PoststartHookFailGenWarn = "" /* 139 byte string literal not displayed */

	UndoCreateSteps = "The container MUST be destroyed by undoing the steps performed during create phase (step 2)."

	PoststopHooksInvoke = "The poststop hooks MUST be invoked by the runtime."

	PoststopHookFailGenWarn = "" /* 138 byte string literal not displayed */

	ErrorsLeaveStateUnchange = "" /* 192 byte string literal not displayed */

	WarnsLeaveFlowUnchange = "" /* 143 byte string literal not displayed */

	DefaultOperations = "Unless otherwise stated, runtimes MUST support the default operations."

	QueryWithoutIDGenError = "This operation MUST generate an error if it is not provided the ID of a container."

	QueryNonExistGenError = "Attempting to query a container that does not exist MUST generate an error."

	QueryStateImplement = "This operation MUST return the state of a container as specified in the State section."

	CreateWithBundlePathAndID = "" /* 136 byte string literal not displayed */

	CreateWithUniqueID = "" /* 206 byte string literal not displayed */

	CreateNewContainer = "This operation MUST create a new container."

	PropsApplyExceptProcOnCreate = "All of the properties configured in `config.json` except for `process` MUST be applied."

	ProcArgsApplyUntilStart = "`process.args` MUST NOT be applied until triggered by the `start` operation."

	PropApplyFailGenError = "If the runtime cannot apply a property as specified in the configuration, it MUST generate an error."

	PropApplyFailNotCreate = "If the runtime cannot apply a property as specified in the configuration, a new container MUST NOT be created."

	StartWithoutIDGenError = "`start` operation MUST generate an error if it is not provided the container ID."

	StartNonCreateHaveNoEffect = "Attempting to `start` a container that is not `created` MUST have no effect on the container."

	StartNonCreateGenError = "Attempting to `start` a container that is not `created` MUST generate an error."

	StartProcImplement = "`start` operation MUST run the user-specified program as specified by `process`."

	StartWithProcUnsetGenError = "`start` operation MUST generate an error if `process` was not set."

	KillWithoutIDGenError = "`kill` operation MUST generate an error if it is not provided the container ID."

	KillNonCreateRunHaveNoEffect = "Attempting to send a signal to a container that is neither `created` nor `running` MUST have no effect on the container."

	KillNonCreateRunGenError = "Attempting to send a signal to a container that is neither `created` nor `running` MUST generate an error."

	KillSignalImplement = "`kill` operation MUST send the specified signal to the container process."

	DeleteWithoutIDGenError = "`delete` operation MUST generate an error if it is not provided the container ID."

	DeleteNonStopHaveNoEffect = "Attempting to `delete` a container that is not `stopped` MUST have no effect on the container."

	DeleteNonStopGenError = "Attempting to `delete` a container that is not `stopped` MUST generate an error."

	DeleteResImplement = "Deleting a container MUST delete the resources that were created during the `create` step."

	DeleteOnlyCreatedRes = "Note that resources associated with the container, but not created by this container, MUST NOT be deleted."
)

define error codes

const (
	DefaultRuntimeLinuxSymlinks = "" /* 152 byte string literal not displayed */
)

define error codes

Functions

func NewError

func NewError(code Code, err error, version string) error

NewError creates an Error referencing a spec violation. The error can be cast to an *Error for extracting structured information about the level of the violation and a reference to the violated spec condition.

A version string (for the version of the spec that was violated) must be set to get a working URL.

Types

type Code

type Code string

Code represents the spec violation, enumerating both configuration violations and runtime violations.

func FindError

func FindError(err error, code Code) Code

FindError finds an error from a source error (multiple error) and returns the error code if found. If the source error is nil or empty, return NonError. If the source error is not a multiple error, return NonRFCError.

type Error

type Error struct {
	// Err holds the RFC 2119 violation.
	Err rfc2119.Error

	// Code is a matchable holds a Code
	Code Code
}

Error represents a runtime-spec violation.

func (*Error) Error

func (err *Error) Error() string

Error returns the error message with specification reference.

type LevelErrors

type LevelErrors struct {
	// Warnings holds Errors that were below a compliance-level threshold.
	Warnings []*Error

	// Error holds errors that were at or above a compliance-level
	// threshold, as well as errors that are not Errors.
	Error *multierror.Error
}

LevelErrors represents Errors filtered into fatal and warnings.

func SplitLevel

func SplitLevel(errIn error, level rfc2119.Level) (levelErrors LevelErrors, errOut error)

SplitLevel removes RFC 2119 errors with a level less than 'level' from the source error. If the source error is not a multierror, it is returned unchanged.

Source Files

bundle.go config-linux.go config-windows.go config.go error.go runtime-linux.go runtime.go

Version
v0.3.0
Published
Nov 1, 2017
Platform
js/wasm
Imports
3 packages
Last checked
17 hours ago

Tools for package owners.