batch

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 27 Imported by: 0

README

Batch

Parity grade: A · SDK aws-sdk-go-v2/service/batch@v1.61.1 · last audited 2026-07-12 (01dbe288c7a19e4adc701e870bcee3d4907f6a05)

Coverage

Metric Value
Operations audited 25 (24 ok, 1 partial)
Feature families 4 (4 deferred)
Known gaps 4
Deferred items 4
Resource leaks clean
Known gaps
  • DescribeJobs (JobDetail) does not model container/attempts/isCancelled/isTerminated/platformCapabilities/nodeDetails/ecsProperties/eksProperties -- these require simulating job execution details, out of scope for this pass (bd: file follow-up)
  • ConsumableResourceProperty.Quantity is float64 in Go; real API's ConsumableResourceRequirement.Quantity is int64 (Long). Harmless for whole-number quantities (JSON encodes identically) but wrong for fractional input, which real AWS would reject anyway (bd: file follow-up, low priority)
  • JobDefinition has no RetryStrategy field; RegisterJobDefinition doesn't accept/store a default retry strategy even though real AWS Batch supports one at the job-definition level (job-level RetryStrategy via SubmitJob already works) (bd: file follow-up)
  • RegisterJobDefinition's EksProperties parameter is hardcoded nil in the handler (pre-existing, not touched this pass -- see handler.go handleRegisterJobDefinition comment)
Deferred
  • SchedulingPolicy family (full wire-shape re-verification)
  • ServiceEnvironment family (full wire-shape re-verification)
  • ServiceJob family (full wire-shape re-verification)
  • GetJobQueueSnapshot

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist.
	ErrNotFound = awserr.New("ClientException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a resource already exists.
	ErrAlreadyExists = awserr.New("ClientException", awserr.ErrAlreadyExists)
	// ErrValidation is returned when a request contains invalid parameters.
	ErrValidation = awserr.New("ClientException", awserr.ErrInvalidParameter)
)

Functions

This section is empty.

Types

type ArrayProperties

type ArrayProperties struct {
	StatusSummary map[string]int32 `json:"statusSummary,omitempty"`
	Size          int32            `json:"size,omitempty"`
	Index         int32            `json:"index,omitempty"`
}

ArrayProperties specifies array job fan-out configuration.

type ComputeEnvironment

type ComputeEnvironment struct {
	Tags             map[string]string `json:"tags"`
	ComputeResources *ComputeResources `json:"computeResources,omitempty"`
	EksConfiguration *EksConfiguration `json:"eksConfiguration,omitempty"`
	UpdatePolicy     *UpdatePolicy     `json:"updatePolicy,omitempty"`

	ServiceRole            string `json:"serviceRole,omitempty"`
	ComputeEnvironmentArn  string `json:"computeEnvironmentArn"`
	Type                   string `json:"type"`
	State                  string `json:"state"`
	Status                 string `json:"status"`
	StatusReason           string `json:"statusReason,omitempty"`
	ComputeEnvironmentName string `json:"computeEnvironmentName"`
	// contains filtered or unexported fields
}

ComputeEnvironment represents a Batch compute environment.

type ComputeEnvironmentOrder

type ComputeEnvironmentOrder struct {
	ComputeEnvironment string `json:"computeEnvironment"`
	Order              int32  `json:"order"`
}

ComputeEnvironmentOrder pairs a compute environment with its ordering in a job queue.

type ComputeResources

type ComputeResources struct {
	Type               string             `json:"type,omitempty"`
	AllocationStrategy string             `json:"allocationStrategy,omitempty"`
	InstanceRole       string             `json:"instanceRole,omitempty"`
	Ec2KeyPair         string             `json:"ec2KeyPair,omitempty"`
	ImageID            string             `json:"imageId,omitempty"`
	PlacementGroup     string             `json:"placementGroup,omitempty"`
	SpotIamFleetRole   string             `json:"spotIamFleetRole,omitempty"`
	InstanceTypes      []string           `json:"instanceTypes,omitempty"`
	Subnets            []string           `json:"subnets,omitempty"`
	SecurityGroupIDs   []string           `json:"securityGroupIds,omitempty"`
	Tags               map[string]string  `json:"tags,omitempty"`
	LaunchTemplate     *LaunchTemplate    `json:"launchTemplate,omitempty"`
	Ec2Configuration   []Ec2Configuration `json:"ec2Configuration,omitempty"`
	MinvCpus           int32              `json:"minvCpus,omitempty"`
	MaxvCpus           int32              `json:"maxvCpus,omitempty"`
	DesiredvCpus       int32              `json:"desiredvCpus,omitempty"`
	BidPercentage      int32              `json:"bidPercentage,omitempty"`
}

ComputeResources holds compute resource configuration for a managed CE.

type ConfigProvider

type ConfigProvider interface {
	GetBatchSettings() Settings
}

ConfigProvider is a private interface to extract Batch configuration from the abstract AppContext Config.

type ConsumableResource

type ConsumableResource struct {
	Tags map[string]string `json:"tags"`

	ConsumableResourceName string `json:"consumableResourceName"`
	ConsumableResourceArn  string `json:"consumableResourceArn"`
	ResourceType           string `json:"resourceType,omitempty"`
	CreatedAt              int64  `json:"createdAt"`
	TotalQuantity          int64  `json:"totalQuantity"`
	AvailableQuantity      int64  `json:"availableQuantity"`
	InUseQuantity          int64  `json:"inUseQuantity"`
	// contains filtered or unexported fields
}

ConsumableResource represents a Batch consumable resource.

type ConsumableResourceProperties

type ConsumableResourceProperties struct {
	ConsumableResourceList []ConsumableResourceProperty `json:"consumableResourceList,omitempty"`
}

ConsumableResourceProperties holds the consumable resources required by a job or job definition. The real Batch API nests the requirement list under "consumableResourceList" rather than serialising it as a bare array; wrap it here so the wire shape matches (see aws-sdk-go-v2/service/batch/types. ConsumableResourceProperties).

type ConsumableResourceProperty

type ConsumableResourceProperty struct {
	ConsumableResource string  `json:"consumableResource"`
	Quantity           float64 `json:"quantity"`
}

ConsumableResourceProperty specifies a single consumable resource requirement.

type ContainerOverrides

type ContainerOverrides struct {
	InstanceType         string                `json:"instanceType,omitempty"`
	Command              []string              `json:"command,omitempty"`
	Environment          []KeyValuePair        `json:"environment,omitempty"`
	ResourceRequirements []ResourceRequirement `json:"resourceRequirements,omitempty"`
}

ContainerOverrides overrides container properties at job submission time.

type ContainerProperties

type ContainerProperties struct {
	LinuxParameters              *LinuxParameters              `json:"linuxParameters,omitempty"`
	RepositoryCredentials        *RepositoryCredentials        `json:"repositoryCredentials,omitempty"`
	RuntimePlatform              *RuntimePlatform              `json:"runtimePlatform,omitempty"`
	EphemeralStorage             *EphemeralStorage             `json:"ephemeralStorage,omitempty"`
	FargatePlatformConfiguration *FargatePlatformConfiguration `json:"fargatePlatformConfiguration,omitempty"`
	NetworkConfiguration         *NetworkConfiguration         `json:"networkConfiguration,omitempty"`
	LogConfiguration             *LogConfiguration             `json:"logConfiguration,omitempty"`
	JobRoleArn                   string                        `json:"jobRoleArn,omitempty"`
	ExecutionRoleArn             string                        `json:"executionRoleArn,omitempty"`
	User                         string                        `json:"user,omitempty"`
	InstanceType                 string                        `json:"instanceType,omitempty"`
	Image                        string                        `json:"image,omitempty"`
	Command                      []string                      `json:"command,omitempty"`
	Secrets                      []Secret                      `json:"secrets,omitempty"`
	ResourceRequirements         []ResourceRequirement         `json:"resourceRequirements,omitempty"`
	Ulimits                      []Ulimit                      `json:"ulimits,omitempty"`
	MountPoints                  []MountPoint                  `json:"mountPoints,omitempty"`
	Volumes                      []Volume                      `json:"volumes,omitempty"`
	Environment                  []KeyValuePair                `json:"environment,omitempty"`
	Vcpus                        int32                         `json:"vcpus,omitempty"`
	Memory                       int32                         `json:"memory,omitempty"`
	ReadonlyRootFilesystem       bool                          `json:"readonlyRootFilesystem,omitempty"`
	Privileged                   bool                          `json:"privileged,omitempty"`
}

ContainerProperties stores container configuration for a job definition.

type Device

type Device struct {
	HostPath      string   `json:"hostPath"`
	ContainerPath string   `json:"containerPath,omitempty"`
	Permissions   []string `json:"permissions,omitempty"`
}

Device specifies a device to expose to a container.

type Ec2Configuration

type Ec2Configuration struct {
	ImageType              string `json:"imageType"`
	ImageIDOverride        string `json:"imageIdOverride,omitempty"`
	ImageKubernetesVersion string `json:"imageKubernetesVersion,omitempty"`
}

Ec2Configuration specifies AMI matching configuration for EC2 compute environments.

type EksConfiguration

type EksConfiguration struct {
	EksClusterArn       string `json:"eksClusterArn"`
	KubernetesNamespace string `json:"kubernetesNamespace"`
}

EksConfiguration specifies EKS cluster configuration for a CE.

type EksContainer

type EksContainer struct {
	Resources       *EksContainerResources `json:"resources,omitempty"`
	SecurityContext *EksSecurityContext    `json:"securityContext,omitempty"`
	Name            string                 `json:"name"`
	Image           string                 `json:"image"`
	Command         []string               `json:"command,omitempty"`
	Args            []string               `json:"args,omitempty"`
	Env             []EksContainerEnv      `json:"env,omitempty"`
	VolumeMounts    []EksVolumeMount       `json:"volumeMounts,omitempty"`
}

EksContainer specifies an EKS pod container.

type EksContainerEnv

type EksContainerEnv struct {
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
}

EksContainerEnv is a name/value env var for EKS containers.

type EksContainerResources

type EksContainerResources struct {
	Limits   map[string]string `json:"limits,omitempty"`
	Requests map[string]string `json:"requests,omitempty"`
}

EksContainerResources specifies resource limits and requests for EKS containers.

type EksEmptyDir

type EksEmptyDir struct {
	Medium    string `json:"medium,omitempty"`
	SizeLimit string `json:"sizeLimit,omitempty"`
}

EksEmptyDir specifies an emptyDir volume for EKS.

type EksHostPath

type EksHostPath struct {
	Path string `json:"path,omitempty"`
}

EksHostPath specifies a host path volume for EKS.

type EksMetadata

type EksMetadata struct {
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

EksMetadata holds labels and annotations for an EKS pod.

type EksPodProperties

type EksPodProperties struct {
	Metadata           *EksMetadata   `json:"metadata,omitempty"`
	ServiceAccountName string         `json:"serviceAccountName,omitempty"`
	DNSPolicy          string         `json:"dnsPolicy,omitempty"`
	Containers         []EksContainer `json:"containers,omitempty"`
	InitContainers     []EksContainer `json:"initContainers,omitempty"`
	Volumes            []EksVolume    `json:"volumes,omitempty"`
	HostNetwork        bool           `json:"hostNetwork,omitempty"`
}

EksPodProperties specifies the Kubernetes pod spec for an EKS job.

type EksProperties

type EksProperties struct {
	PodProperties *EksPodProperties `json:"podProperties,omitempty"`
}

EksProperties specifies EKS-specific job definition properties.

type EksSecret

type EksSecret struct {
	SecretName string `json:"secretName"`
	Optional   bool   `json:"optional,omitempty"`
}

EksSecret specifies a Kubernetes secret volume for EKS.

type EksSecurityContext

type EksSecurityContext struct {
	RunAsUser                *int64 `json:"runAsUser,omitempty"`
	RunAsGroup               *int64 `json:"runAsGroup,omitempty"`
	Privileged               bool   `json:"privileged,omitempty"`
	ReadOnlyRootFilesystem   bool   `json:"readOnlyRootFilesystem,omitempty"`
	RunAsNonRoot             bool   `json:"runAsNonRoot,omitempty"`
	AllowPrivilegeEscalation bool   `json:"allowPrivilegeEscalation,omitempty"`
}

EksSecurityContext specifies security settings for an EKS container.

type EksVolume

type EksVolume struct {
	HostPath *EksHostPath `json:"hostPath,omitempty"`
	EmptyDir *EksEmptyDir `json:"emptyDir,omitempty"`
	Secret   *EksSecret   `json:"secret,omitempty"`
	Name     string       `json:"name"`
}

EksVolume specifies a volume available to EKS pod containers.

type EksVolumeMount

type EksVolumeMount struct {
	Name      string `json:"name"`
	MountPath string `json:"mountPath"`
	ReadOnly  bool   `json:"readOnly,omitempty"`
}

EksVolumeMount mounts a volume into an EKS container.

type EphemeralStorage

type EphemeralStorage struct {
	SizeInGiB int32 `json:"sizeInGiB"`
}

EphemeralStorage specifies ephemeral storage capacity for Fargate tasks.

type EvaluateOnExit

type EvaluateOnExit struct {
	Action         string `json:"action"`
	OnStatusReason string `json:"onStatusReason,omitempty"`
	OnReason       string `json:"onReason,omitempty"`
	OnExitCode     string `json:"onExitCode,omitempty"`
}

EvaluateOnExit specifies a conditional retry rule evaluated against exit information.

type FairsharePolicy

type FairsharePolicy struct {
	ShareDistribution  []ShareDistribution `json:"shareDistribution,omitempty"`
	ShareDecaySeconds  int32               `json:"shareDecaySeconds,omitempty"`
	ComputeReservation int32               `json:"computeReservation,omitempty"`
}

FairsharePolicy configures fair-share scheduling for a scheduling policy.

type FargatePlatformConfiguration

type FargatePlatformConfiguration struct {
	PlatformVersion string `json:"platformVersion,omitempty"`
}

FargatePlatformConfiguration specifies the Fargate platform version.

type FrontOfQueue

type FrontOfQueue struct {
	Jobs      []FrontOfQueueJob `json:"jobs,omitempty"`
	Timestamp float64           `json:"timestamp"`
}

FrontOfQueue holds jobs at the front of a job queue.

type FrontOfQueueJob

type FrontOfQueueJob struct {
	JobArn                 string  `json:"jobArn"`
	EarliestTimeAtPosition float64 `json:"earliestTimeAtPosition"`
}

FrontOfQueueJob represents a single job at the front of a queue.

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for AWS Batch operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new Batch handler backed by backend. backend must not be nil.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name from the request path and method.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource extracts a resource identifier from the request path.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for Batch requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches Batch requests. It matches /v1/ paths but explicitly excludes /v1/apis (AppSync), CodeArtifact paths, Kafka paths, and Kafka tag resource paths to prevent routing conflicts when multiple services use PriorityPathVersioned.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor if configured. It always returns nil; the error return satisfies the service.BackgroundWorker interface.

func (*Handler) WithJanitor

func (h *Handler) WithJanitor(
	interval, inactiveJobDefTTL, completedJobTTL time.Duration,
	taskTimeout ...time.Duration,
) *Handler

WithJanitor attaches a background janitor to the handler. Zero values for interval, inactiveJobDefTTL, or completedJobTTL use defaults. The optional taskTimeout bounds each sweep; 0 means no per-task timeout.

type HostVolume

type HostVolume struct {
	SourcePath string `json:"sourcePath,omitempty"`
}

HostVolume specifies a host-path volume binding.

type InMemoryBackend

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

InMemoryBackend stores AWS Batch state in memory.

The eight resource collections below (computeEnvironments, jobQueues, jobDefinitions, jobs, consumableResources, schedulingPolicies, serviceEnvironments, serviceJobs) were previously nested by region (outer key = region, e.g. map[string]map[string]*Job); each is now a single flat *store.Table[T] keyed by the composite "region|id" string (see regionKey), with a companion *store.Index grouping entries by region for per-region scans/pagination -- the region-qualified-table pattern services/emr and services/mwaa use (Phase 3.3 of the datalayer refactor). jobs additionally carries a "byARN" index (replacing the old jobsByARN region-nested map) and a "byQueue" index (replacing jobsByQueue), both maintained automatically by store.Table on every Put/Delete/Restore.

jobDefRevisions (a per-region name -> revision-counter map, not a *T map) is left as a plain region-nested map since store.Table requires pointer identity values; it is persisted directly, unchanged from before.

cesByARN, jqsByARN, crsByARN and ceToQueues are also left as plain maps: the first three hold bare strings (no *T identity) and were already write-only/dead for reads before this refactor; ceToQueues is a non-*T set-of-sets used only for the CE-in-use-by-queue check. None of the four are region-nested (a pre-existing quirk, e.g. a same-named CE in two regions shares one cesByARN slot) and none are persisted -- both facts predate this refactor and are preserved byte-for-byte, not fixed here.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend.

func (*InMemoryBackend) CancelJob

func (b *InMemoryBackend) CancelJob(ctx context.Context, idOrARN, reason string) error

CancelJob cancels a job in SUBMITTED, PENDING, or RUNNABLE state. Accepts job ID or ARN.

func (*InMemoryBackend) CreateComputeEnvironment

func (b *InMemoryBackend) CreateComputeEnvironment(
	ctx context.Context,
	name, ceType, state string,
	tags map[string]string,
	serviceRole string,
	computeResources *ComputeResources,
	eksConfig *EksConfiguration,
	updatePolicy *UpdatePolicy,
) (*ComputeEnvironment, error)

CreateComputeEnvironment creates a new compute environment.

func (*InMemoryBackend) CreateConsumableResource

func (b *InMemoryBackend) CreateConsumableResource(
	ctx context.Context,
	name, resourceType string,
	totalQuantity int64,
	tags map[string]string,
) (*ConsumableResource, error)

CreateConsumableResource creates a new consumable resource.

func (*InMemoryBackend) CreateJobQueue

func (b *InMemoryBackend) CreateJobQueue(
	ctx context.Context,
	name string,
	priority int32,
	state string,
	ceOrder []ComputeEnvironmentOrder,
	tags map[string]string,
	schedulingPolicyArn string,
	jobStateTimeLimitActions []JobStateTimeLimitAction,
) (*JobQueue, error)

CreateJobQueue creates a new job queue.

func (*InMemoryBackend) CreateSchedulingPolicy

func (b *InMemoryBackend) CreateSchedulingPolicy(
	ctx context.Context,
	name string,
	tags map[string]string,
	fairsharePolicy *FairsharePolicy,
) (*SchedulingPolicy, error)

CreateSchedulingPolicy creates a new scheduling policy.

func (*InMemoryBackend) CreateServiceEnvironment

func (b *InMemoryBackend) CreateServiceEnvironment(
	ctx context.Context,
	name, envType, state string,
	tags map[string]string,
) (*ServiceEnvironment, error)

CreateServiceEnvironment creates a new service environment.

func (*InMemoryBackend) DeleteComputeEnvironment

func (b *InMemoryBackend) DeleteComputeEnvironment(ctx context.Context, nameOrARN string) error

DeleteComputeEnvironment removes a compute environment.

func (*InMemoryBackend) DeleteConsumableResource

func (b *InMemoryBackend) DeleteConsumableResource(ctx context.Context, nameOrARN string) error

DeleteConsumableResource removes a consumable resource by name or ARN.

func (*InMemoryBackend) DeleteJobQueue

func (b *InMemoryBackend) DeleteJobQueue(ctx context.Context, nameOrARN string) error

DeleteJobQueue removes a job queue and all associated jobs. The queue must be in DISABLED state before deletion.

func (*InMemoryBackend) DeleteSchedulingPolicy

func (b *InMemoryBackend) DeleteSchedulingPolicy(ctx context.Context, policyARN string) error

DeleteSchedulingPolicy removes a scheduling policy by ARN.

func (*InMemoryBackend) DeleteServiceEnvironment

func (b *InMemoryBackend) DeleteServiceEnvironment(ctx context.Context, nameOrARN string) error

DeleteServiceEnvironment removes a service environment by name or ARN.

func (*InMemoryBackend) DeregisterJobDefinition

func (b *InMemoryBackend) DeregisterJobDefinition(ctx context.Context, arnOrNameRev string) error

DeregisterJobDefinition marks a job definition as INACTIVE by ARN or name:revision. INACTIVE definitions remain visible in DescribeJobDefinitions (matching AWS behavior) and are swept by the janitor after the configured TTL.

func (*InMemoryBackend) DescribeComputeEnvironments

func (b *InMemoryBackend) DescribeComputeEnvironments(
	ctx context.Context,
	names []string,
	maxResults int32,
	nextToken string,
) ([]*ComputeEnvironment, string)

DescribeComputeEnvironments returns compute environments, optionally filtered by names/ARNs. When names is empty, results are paginated via maxResults/nextToken.

func (*InMemoryBackend) DescribeConsumableResource

func (b *InMemoryBackend) DescribeConsumableResource(
	ctx context.Context,
	nameOrARN string,
) (*ConsumableResource, error)

DescribeConsumableResource returns details for a consumable resource identified by name or ARN.

func (*InMemoryBackend) DescribeJobDefinitions

func (b *InMemoryBackend) DescribeJobDefinitions(
	ctx context.Context,
	names []string,
	status, jobDefinitionName string,
	maxResults int32,
	nextToken string,
) ([]*JobDefinition, string)

DescribeJobDefinitions returns job definitions, optionally filtered by names/ARNs. When names is empty, results are paginated via maxResults/nextToken.

func (*InMemoryBackend) DescribeJobQueues

func (b *InMemoryBackend) DescribeJobQueues(
	ctx context.Context,
	names []string,
	maxResults int32,
	nextToken string,
) ([]*JobQueue, string)

DescribeJobQueues returns job queues, optionally filtered by names/ARNs. When names are provided, all matching queues are returned without pagination. When names is empty, results are paginated using maxResults and nextToken.

func (*InMemoryBackend) DescribeJobs

func (b *InMemoryBackend) DescribeJobs(ctx context.Context, jobIDs []string) []*Job

DescribeJobs returns full job details for the given job IDs or ARNs.

func (*InMemoryBackend) DescribeSchedulingPolicies

func (b *InMemoryBackend) DescribeSchedulingPolicies(ctx context.Context, arns []string) []*SchedulingPolicy

DescribeSchedulingPolicies returns scheduling policies, optionally filtered by ARNs.

func (*InMemoryBackend) DescribeServiceEnvironments

func (b *InMemoryBackend) DescribeServiceEnvironments(ctx context.Context, names []string) []*ServiceEnvironment

DescribeServiceEnvironments returns service environments, optionally filtered by names/ARNs.

func (*InMemoryBackend) DescribeServiceJob

func (b *InMemoryBackend) DescribeServiceJob(ctx context.Context, serviceJobID string) (*ServiceJob, error)

DescribeServiceJob returns a single service job by ID.

func (*InMemoryBackend) GetJobQueueSnapshot

func (b *InMemoryBackend) GetJobQueueSnapshot(ctx context.Context, jobQueue string) (*JobQueueSnapshot, error)

GetJobQueueSnapshot returns a snapshot of the front of a job queue.

func (*InMemoryBackend) ListConsumableResources

func (b *InMemoryBackend) ListConsumableResources(ctx context.Context) []*ConsumableResource

ListConsumableResources returns all consumable resources sorted by name.

func (*InMemoryBackend) ListJobs

func (b *InMemoryBackend) ListJobs(
	ctx context.Context,
	queue, status, nextToken string,
	maxResults int32,
) ([]*Job, string, error)

ListJobs returns job summaries for a queue, optionally filtered by status. Pagination is controlled via maxResults and nextToken (token encodes an integer offset).

func (*InMemoryBackend) ListJobsByConsumableResource

func (b *InMemoryBackend) ListJobsByConsumableResource(
	ctx context.Context,
	consumableResource string,
) ([]*Job, error)

ListJobsByConsumableResource returns jobs that reference the named consumable resource via their ConsumableResourceProperties.

func (*InMemoryBackend) ListSchedulingPolicies

func (b *InMemoryBackend) ListSchedulingPolicies(ctx context.Context) []*SchedulingPolicy

ListSchedulingPolicies returns all scheduling policies sorted by ARN.

func (*InMemoryBackend) ListServiceJobs

func (b *InMemoryBackend) ListServiceJobs(ctx context.Context, serviceEnv string) ([]*ServiceJob, error)

ListServiceJobs returns service jobs, optionally filtered by service environment.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)

ListTagsForResource returns the tags for a resource identified by ARN.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

func (*InMemoryBackend) RegisterJobDefinition

func (b *InMemoryBackend) RegisterJobDefinition(
	ctx context.Context,
	name, defType string,
	tags map[string]string,
	platformCapabilities []string,
	timeoutSeconds int32,
	schedulingPriority int32,
	containerProps *ContainerProperties,
	nodeProps *NodeProperties,
	eksProps *EksProperties,
	runtimePlatform *RuntimePlatform,
	consumableResourceProperties []ConsumableResourceProperty,
	parameters map[string]string,
	propagateTags bool,
) (*JobDefinition, error)

RegisterJobDefinition registers a new job definition (or a new revision).

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state from the backend.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) SubmitJob

func (b *InMemoryBackend) SubmitJob(
	ctx context.Context,
	name, queue, jobDefinition string,
	tags map[string]string,
	parameters map[string]string,
	dependsOn []JobDependency,
	retryStrategy *RetryStrategy,
	timeout *JobTimeout,
	arrayProperties *ArrayProperties,
	containerOverrides *ContainerOverrides,
	consumableResourceProperties []ConsumableResourceProperty,
	shareIdentifier string,
	schedulingPriorityOverride int32,
	propagateTags bool,
) (*Job, error)

SubmitJob submits a new Batch job for execution.

func (*InMemoryBackend) SubmitServiceJob

func (b *InMemoryBackend) SubmitServiceJob(
	ctx context.Context,
	name, serviceEnv string,
	tags map[string]string,
) (*ServiceJob, error)

SubmitServiceJob creates a new service job in SUBMITTED status.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error

TagResource adds or updates tags on a resource identified by ARN.

func (*InMemoryBackend) TerminateJob

func (b *InMemoryBackend) TerminateJob(ctx context.Context, idOrARN, reason string) error

TerminateJob marks a job as FAILED with the given reason. Valid for any non-terminal state. Accepts job ID or ARN.

func (*InMemoryBackend) TerminateServiceJob

func (b *InMemoryBackend) TerminateServiceJob(ctx context.Context, serviceJobID, reason string) error

TerminateServiceJob marks a service job as FAILED.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error

UntagResource removes tags from a resource identified by ARN.

func (*InMemoryBackend) UpdateComputeEnvironment

func (b *InMemoryBackend) UpdateComputeEnvironment(
	ctx context.Context,
	nameOrARN, state, serviceRole string,
	computeResources *ComputeResources,
	updatePolicy *UpdatePolicy,
) (*ComputeEnvironment, error)

UpdateComputeEnvironment updates the state, service role, compute resources, and/or update policy.

func (*InMemoryBackend) UpdateConsumableResource

func (b *InMemoryBackend) UpdateConsumableResource(
	ctx context.Context,
	nameOrARN, operation string,
	quantity int64,
) (*ConsumableResource, error)

UpdateConsumableResource updates the quantity of a consumable resource.

func (*InMemoryBackend) UpdateJobQueue

func (b *InMemoryBackend) UpdateJobQueue(
	ctx context.Context,
	nameOrARN string,
	priority *int32,
	state string,
	ceOrder []ComputeEnvironmentOrder,
	jobStateTimeLimitActions []JobStateTimeLimitAction,
) (*JobQueue, error)

UpdateJobQueue updates a job queue's state, priority, CE order, and/or time-limit actions.

func (*InMemoryBackend) UpdateSchedulingPolicy

func (b *InMemoryBackend) UpdateSchedulingPolicy(
	ctx context.Context,
	policyARN string,
	fairsharePolicy *FairsharePolicy,
) error

UpdateSchedulingPolicy updates a scheduling policy's fairshare configuration.

func (*InMemoryBackend) UpdateServiceEnvironment

func (b *InMemoryBackend) UpdateServiceEnvironment(
	ctx context.Context,
	nameOrARN, state string,
) (*ServiceEnvironment, error)

UpdateServiceEnvironment updates the state of a service environment.

type Janitor

type Janitor struct {
	Backend           *InMemoryBackend
	Interval          time.Duration
	InactiveJobDefTTL time.Duration
	CompletedJobTTL   time.Duration
	TaskTimeout       time.Duration
}

Janitor is the Batch background worker that evicts INACTIVE job definitions after a configurable TTL to prevent unbounded growth of in-memory state. This matches AWS behavior where deregistered definitions eventually disappear. It also evicts completed and failed jobs after a configurable TTL, matching the AWS Batch job history retention behavior.

func NewJanitor

func NewJanitor(backend *InMemoryBackend, interval, inactiveJobDefTTL, completedJobTTL time.Duration) *Janitor

NewJanitor creates a new Batch Janitor for the given backend. Zero values for interval, inactiveJobDefTTL, or completedJobTTL fall back to defaults.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled.

func (*Janitor) SweepOnce

func (j *Janitor) SweepOnce(ctx context.Context)

SweepOnce runs a single sweep pass. Exposed for testing.

type Job

type Job struct {
	ContainerOverrides *ContainerOverrides `json:"containerOverrides,omitempty"`
	Tags               map[string]string   `json:"tags"`
	Parameters         map[string]string   `json:"parameters,omitempty"`
	StartedAt          *int64              `json:"startedAt,omitempty"`
	StoppedAt          *int64              `json:"stoppedAt,omitempty"`
	RetryStrategy      *RetryStrategy      `json:"retryStrategy,omitempty"`
	Timeout            *JobTimeout         `json:"timeout,omitempty"`
	ArrayProperties    *ArrayProperties    `json:"arrayProperties,omitempty"`

	JobDefinition                string                        `json:"jobDefinition"`
	ShareIdentifier              string                        `json:"shareIdentifier,omitempty"`
	StatusReason                 string                        `json:"statusReason,omitempty"`
	JobID                        string                        `json:"jobId"`
	JobARN                       string                        `json:"jobArn"`
	JobName                      string                        `json:"jobName"`
	JobQueue                     string                        `json:"jobQueue"`
	Status                       string                        `json:"status"`
	DependsOn                    []JobDependency               `json:"dependsOn,omitempty"`
	ConsumableResourceProperties *ConsumableResourceProperties `json:"consumableResourceProperties,omitempty"`
	Attempts                     []JobAttempt                  `json:"attempts,omitempty"`
	CreatedAt                    int64                         `json:"createdAt"`
	SchedulingPriorityOverride   int32                         `json:"schedulingPriorityOverride,omitempty"`
	PropagateTags                bool                          `json:"propagateTags,omitempty"`
	// contains filtered or unexported fields
}

Job represents a submitted Batch job.

type JobAttempt

type JobAttempt struct {
	Container    *JobAttemptContainer `json:"container,omitempty"`
	StartedAt    *int64               `json:"startedAt,omitempty"`
	StoppedAt    *int64               `json:"stoppedAt,omitempty"`
	StatusReason string               `json:"statusReason,omitempty"`
}

JobAttempt holds per-attempt lifecycle and result information.

type JobAttemptContainer

type JobAttemptContainer struct {
	LogStreamName string `json:"logStreamName,omitempty"`
	Reason        string `json:"reason,omitempty"`
	ExitCode      int32  `json:"exitCode,omitempty"`
}

JobAttemptContainer holds per-attempt container execution details.

type JobDefinition

type JobDefinition struct {
	DeregisteredAt      *time.Time           `json:"deregisteredAt,omitempty"`
	Tags                map[string]string    `json:"tags"`
	Parameters          map[string]string    `json:"parameters,omitempty"`
	ContainerProperties *ContainerProperties `json:"containerProperties,omitempty"`
	NodeProperties      *NodeProperties      `json:"nodeProperties,omitempty"`
	EksProperties       *EksProperties       `json:"eksProperties,omitempty"`
	RuntimePlatform     *RuntimePlatform     `json:"runtimePlatform,omitempty"`
	// Timeout is nested (wire key "timeout": {"attemptDurationSeconds": N}) to
	// match aws-sdk-go-v2/service/batch/types.JobDefinition.Timeout; it must
	// NOT be a flat "timeoutSeconds" integer.
	Timeout *JobTimeout `json:"timeout,omitempty"`

	ConsumableResourceProperties *ConsumableResourceProperties `json:"consumableResourceProperties,omitempty"`
	JobDefinitionName            string                        `json:"jobDefinitionName"`
	JobDefinitionArn             string                        `json:"jobDefinitionArn"`
	Type                         string                        `json:"type"`
	Status                       string                        `json:"status"`
	PlatformCapabilities         []string                      `json:"platformCapabilities,omitempty"`
	Revision                     int32                         `json:"revision"`
	SchedulingPriority           int32                         `json:"schedulingPriority,omitempty"`
	PropagateTags                bool                          `json:"propagateTags,omitempty"`
	// contains filtered or unexported fields
}

JobDefinition represents a Batch job definition.

type JobDependency

type JobDependency struct {
	JobID string `json:"jobId,omitempty"`
	Type  string `json:"type,omitempty"`
}

JobDependency represents a dependency between jobs.

type JobQueue

type JobQueue struct {
	Tags map[string]string `json:"tags"`

	JobQueueName             string                    `json:"jobQueueName"`
	JobQueueArn              string                    `json:"jobQueueArn"`
	State                    string                    `json:"state"`
	Status                   string                    `json:"status"`
	StatusReason             string                    `json:"statusReason,omitempty"`
	SchedulingPolicyArn      string                    `json:"schedulingPolicyArn,omitempty"`
	ComputeEnvironmentOrder  []ComputeEnvironmentOrder `json:"computeEnvironmentOrder,omitempty"`
	JobStateTimeLimitActions []JobStateTimeLimitAction `json:"jobStateTimeLimitActions,omitempty"`
	Priority                 int32                     `json:"priority"`
	// contains filtered or unexported fields
}

JobQueue represents a Batch job queue.

type JobQueueSnapshot

type JobQueueSnapshot struct {
	FrontOfQueue *FrontOfQueue `json:"frontOfQueue,omitempty"`
}

JobQueueSnapshot represents the front-of-queue state for a job queue.

type JobStateTimeLimitAction

type JobStateTimeLimitAction struct {
	Reason         string `json:"reason"`
	State          string `json:"state"`
	Action         string `json:"action"`
	MaxTimeSeconds int32  `json:"maxTimeSeconds"`
}

JobStateTimeLimitAction cancels jobs stuck in a given state beyond a time limit.

type JobTimeout

type JobTimeout struct {
	AttemptDurationSeconds int32 `json:"attemptDurationSeconds,omitempty"`
}

JobTimeout configures the maximum duration for a job attempt.

type KeyValuePair

type KeyValuePair struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

KeyValuePair is a name/value environment variable pair.

type LaunchTemplate

type LaunchTemplate struct {
	LaunchTemplateName string                   `json:"launchTemplateName,omitempty"`
	LaunchTemplateID   string                   `json:"launchTemplateId,omitempty"`
	Version            string                   `json:"version,omitempty"`
	Overrides          []LaunchTemplateOverride `json:"overrides,omitempty"`
}

LaunchTemplate specifies an EC2 launch template.

type LaunchTemplateOverride

type LaunchTemplateOverride struct {
	LaunchTemplateName  string   `json:"launchTemplateName,omitempty"`
	LaunchTemplateID    string   `json:"launchTemplateId,omitempty"`
	Version             string   `json:"version,omitempty"`
	TargetInstanceTypes []string `json:"targetInstanceTypes,omitempty"`
}

LaunchTemplateOverride specifies a launch template override for specific instance types.

type LinuxParameters

type LinuxParameters struct {
	Devices            []Device `json:"devices,omitempty"`
	Tmpfs              []Tmpfs  `json:"tmpfs,omitempty"`
	InitProcessEnabled bool     `json:"initProcessEnabled,omitempty"`
	SharedMemorySize   int32    `json:"sharedMemorySize,omitempty"`
	MaxSwap            int32    `json:"maxSwap,omitempty"`
	Swappiness         int32    `json:"swappiness,omitempty"`
}

LinuxParameters configures Linux-specific container settings.

type LogConfiguration

type LogConfiguration struct {
	Options   map[string]string `json:"options,omitempty"`
	LogDriver string            `json:"logDriver"`
}

LogConfiguration specifies the log driver configuration for a container.

type MountPoint

type MountPoint struct {
	ContainerPath string `json:"containerPath,omitempty"`
	SourceVolume  string `json:"sourceVolume,omitempty"`
	ReadOnly      bool   `json:"readOnly,omitempty"`
}

MountPoint maps a volume into a container.

type NetworkConfiguration

type NetworkConfiguration struct {
	AssignPublicIP string `json:"assignPublicIp,omitempty"`
}

NetworkConfiguration specifies network settings for Fargate containers.

type NodeProperties

type NodeProperties struct {
	NodeRangeProperties []NodeRangeProperty `json:"nodeRangeProperties"`
	NumNodes            int32               `json:"numNodes"`
	MainNode            int32               `json:"mainNode"`
}

NodeProperties specifies multi-node parallel job configuration.

type NodeRangeProperty

type NodeRangeProperty struct {
	ContainerProperties *ContainerProperties `json:"containerProperties,omitempty"`
	TargetNodes         string               `json:"targetNodes"`
}

NodeRangeProperty specifies container properties for a range of multi-node job nodes.

type Provider

type Provider struct{}

Provider implements service.Provider for Batch.

func (*Provider) Init

Init initializes the Batch backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type RepositoryCredentials

type RepositoryCredentials struct {
	CredentialsParameter string `json:"credentialsParameter"`
}

RepositoryCredentials specifies credentials for a private container registry.

type ResourceRequirement

type ResourceRequirement struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

ResourceRequirement specifies a compute resource requirement (VCPU, MEMORY, or GPU).

type RetryStrategy

type RetryStrategy struct {
	EvaluateOnExit []EvaluateOnExit `json:"evaluateOnExit,omitempty"`
	Attempts       int32            `json:"attempts,omitempty"`
}

RetryStrategy configures automatic retry behavior for a job.

type RuntimePlatform

type RuntimePlatform struct {
	OperatingSystemFamily string `json:"operatingSystemFamily,omitempty"`
	CPUArchitecture       string `json:"cpuArchitecture,omitempty"`
}

RuntimePlatform specifies the OS family and CPU architecture for a job.

type SchedulingPolicy

type SchedulingPolicy struct {
	Tags            map[string]string `json:"tags"`
	FairsharePolicy *FairsharePolicy  `json:"fairsharePolicy,omitempty"`

	Arn  string `json:"arn"`
	Name string `json:"name"`
	// contains filtered or unexported fields
}

SchedulingPolicy represents a Batch scheduling policy.

type Secret

type Secret struct {
	Name      string `json:"name"`
	ValueFrom string `json:"valueFrom"`
}

Secret specifies a secret to expose to a container via environment variable.

type ServiceEnvironment

type ServiceEnvironment struct {
	Tags map[string]string `json:"tags"`

	ServiceEnvironmentName string `json:"serviceEnvironmentName"`
	ServiceEnvironmentArn  string `json:"serviceEnvironmentArn"`
	ServiceEnvironmentType string `json:"serviceEnvironmentType"`
	State                  string `json:"state"`
	Status                 string `json:"status"`
	// contains filtered or unexported fields
}

ServiceEnvironment represents a Batch service environment.

type ServiceJob

type ServiceJob struct {
	Tags      map[string]string `json:"tags"`
	StartedAt *int64            `json:"startedAt,omitempty"`
	StoppedAt *int64            `json:"stoppedAt,omitempty"`

	ServiceJobID       string `json:"serviceJobId"`
	ServiceJobArn      string `json:"serviceJobArn"`
	ServiceJobName     string `json:"serviceJobName"`
	ServiceEnvironment string `json:"serviceEnvironment"`
	Status             string `json:"status"`
	StatusReason       string `json:"statusReason,omitempty"`
	CreatedAt          int64  `json:"createdAt"`
	// contains filtered or unexported fields
}

ServiceJob represents a Batch service job.

type Settings

type Settings struct {
	JanitorInterval   time.Duration `json:"janitor_interval"     env:"BATCH_JANITOR_INTERVAL"     default:"1m"  help:"Janitor tick interval."` //nolint:lll // Kong struct tag makes this line long
	InactiveJobDefTTL time.Duration ``                                                                                                         //nolint:lll // Kong struct tag makes this line long
	/* 139-byte string literal not displayed */
	CompletedJobTTL time.Duration `` //nolint:lll // Kong struct tag makes this line long
	/* 139-byte string literal not displayed */
}

Settings holds service-level configuration for the Batch backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command.

type ShareDistribution

type ShareDistribution struct {
	ShareIdentifier string  `json:"shareIdentifier"`
	WeightFactor    float32 `json:"weightFactor,omitempty"`
}

ShareDistribution specifies a fair-share weight for a share identifier.

type Tmpfs

type Tmpfs struct {
	ContainerPath string   `json:"containerPath"`
	MountOptions  []string `json:"mountOptions,omitempty"`
	Size          int32    `json:"size"`
}

Tmpfs specifies a tmpfs mount for a container.

type Ulimit

type Ulimit struct {
	Name      string `json:"name"`
	SoftLimit int32  `json:"softLimit"`
	HardLimit int32  `json:"hardLimit"`
}

Ulimit specifies a ulimit for a container.

type UpdatePolicy

type UpdatePolicy struct {
	TerminateJobsOnUpdate      bool  `json:"terminateJobsOnUpdate,omitempty"`
	JobExecutionTimeoutMinutes int64 `json:"jobExecutionTimeoutMinutes,omitempty"`
}

UpdatePolicy controls behaviour during in-place CE updates.

type Volume

type Volume struct {
	Host *HostVolume `json:"host,omitempty"`
	Name string      `json:"name"`
}

Volume specifies a volume available to containers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL