podmantracker

package
v0.3.32 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

Podman Tracker (experimental)

Please consider to use the process based backend (default tracker) as it can spawn any process, i.e. also podman

Introduction

Podman Tracker implements the JobTracker interface used by the Go DRMAA2 implementation in order to use Podman as a backend for managing jobs as containers.

Functionality

Basic Usage

A JobTemplate requires:

  • JobCategory -> maps to a container image name
  • RemoteCommand -> which is the command executed within the given container image
Job Control Mapping
DRMAA2 Job Control Podman
Suspend Pauses the container (does not work with rootless and cgroups v1 according to podman)
Resume Continues a paused container
Terminate Kills a running container
Hold Unsupported
Release Unsupported
State Mapping
DRMAA2 State Podman State
Failed Container is not "Restarting", "Paused", "Running" had has exit code != 0
Done Container is not "Restarting", "Paused", "Running", and has exit code 0
Suspended Container is paused (if supported)
Running Container state is "Running" or "Restarting" (sets substate "restarting")
Queued -
Undetermined Container inspect fails

DeleteJob

DeleteJob equals podman rm and is removing an installed container. It must be terminated / finished before.

Job Template Mapping

Mapping between the job template and the Podman container config is only implemented in the most minimalistic way. More to come.

DRMAA2 JobTemplate Podman Container Config Request
RemoteCommand Cmd[0]
Args Cmd[1:]
JobCategory Image
CandidateMachines[0] spec.Hostname (container's hostname)
WorkingDirectory spec.WorkDir (working dir in the container, / if not set)
JobEnviornment spec.Env
ExtensionList["user"] spec.User (user in container)
ExtensionList["exposedPorts] Port forwarding in format [hostip:]hostPort:containerPort,... / spec.
ExtensionList["privileged"] spec.Privileged
ExtensionList["restart"] spec.RestartPolicy / like "unless-stopped", default "no" / use with care
ExtensionList["ipc"] spec.IpcNS namespace (default private) / like docker --ipc "host"
ExtensionList["uts"] spec.UtsNS namespace (default private) / like docker --uts "host"
ExtensionList["pid"] spec.PidNS namespace (default private) / like docker --pid "host"
ExtensionList["rm"] --rm "true" or "TRUE"
Job Info Mapping
Job Arrays

Since Array Jobs are not supported by Podman the job array functionality is implemented by creating n tasks sequentially in a loop. The array job ID contains all IDs of the created Podman containers.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerInfo

func ContainerInfo(ctx context.Context, id string) (drmaa2interface.JobInfo, error)

func DeleteContainer

func DeleteContainer(ctx context.Context, id string) error

func GetContainerState

func GetContainerState(ctx context.Context, id string) (drmaa2interface.JobState, string, error)

func ListContainerImages

func ListContainerImages(ctx context.Context) ([]string, error)

func ListPodmanContainers

func ListPodmanContainers(ctx context.Context) ([]string, error)

func NewAllocator

func NewAllocator() *allocator

func PauseContainer

func PauseContainer(ctx context.Context, id string) error

func ResumeContainer

func ResumeContainer(ctx context.Context, id string) error

func RunPodmanContainer

func RunPodmanContainer(ctx context.Context, jt drmaa2interface.JobTemplate, disablePull bool) (string, error)

RunPodmanContainer converts a DRMAA2 job template into a container spec and runs the container with podman.

The context must provide the podman connection: ctx.Value(clientKey).(*Connection)

func TerminateContainer

func TerminateContainer(ctx context.Context, id string) error

Types

type PodmanTracker

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

PodmanTracker implements the JobTracker interface for managing containers as jobs.

func New

func New(jobSessionName string, params PodmanTrackerParams) (*PodmanTracker, error)

New creates a new connection to Podman and returns a JobTracker interface for Podman. If connectionURIOverride is set it uses this URI for the new Podman connection otherwise the connection is established through the socket.

According to Podman:

"A valid URI connection should be scheme://
 For example tcp://localhost:<port>
 or unix:///run/podman/podman.sock
 or ssh://<user>@<host>[:port]/run/podman/podman.sock?secure=True"

func (*PodmanTracker) AddArrayJob

func (p *PodmanTracker) AddArrayJob(jt drmaa2interface.JobTemplate, begin int, end int, step int, maxParallel int) (string, error)

func (*PodmanTracker) AddJob

func (p *PodmanTracker) AddJob(template drmaa2interface.JobTemplate) (string, error)

func (*PodmanTracker) DeleteJob

func (p *PodmanTracker) DeleteJob(jobid string) error

DeleteJob removes the container and its volumes from the node. The container must be in an end state (i.e. not running anymore).

func (*PodmanTracker) JobControl

func (p *PodmanTracker) JobControl(jobid, action string) error

func (*PodmanTracker) JobInfo

func (p *PodmanTracker) JobInfo(jobid string) (drmaa2interface.JobInfo, error)

func (*PodmanTracker) JobState

func (p *PodmanTracker) JobState(jobid string) (drmaa2interface.JobState, string, error)

func (*PodmanTracker) ListArrayJobs

func (p *PodmanTracker) ListArrayJobs(arrayjobid string) ([]string, error)

func (*PodmanTracker) ListJobCategories

func (p *PodmanTracker) ListJobCategories() ([]string, error)

ListJobCategories returns all localy available container images which can be used in JobCategory of the JobTemplate.

func (*PodmanTracker) ListJobs

func (p *PodmanTracker) ListJobs() ([]string, error)

func (*PodmanTracker) Wait

func (p *PodmanTracker) Wait(jobid string, timeout time.Duration, states ...drmaa2interface.JobState) error

Wait until the job has a certain DRMAA2 state or return an error if the state is unreachable.

type PodmanTrackerParams

type PodmanTrackerParams struct {
	ConnectionURIOverride string
	DisableImagePull      bool
}

PodmanTrackerParams provide parameters which can be passed to the SessionManager in order to influence the behviour of podman.

Jump to

Keyboard shortcuts

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