service

package
v1.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service holds the compute vertical's business rules: the cluster catalogue, the partitions it is carved into, and the login configs users reach a cluster through.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSlurmClusterConfigSharingService

func NewSlurmClusterConfigSharingService(
	db *gorm.DB,
	configs *repository.SlurmClusterConfigRepository,
	sharing *sharingrepo.Repository,
	groups *iamrepo.GroupRepository,
	users *iamrepo.UserRepository,
	members *iamrepo.GroupMemberRepository,
) *sharingsvc.Service

NewSlurmClusterConfigSharingService returns the sharing service for cluster configs.

Types

type ClusterDiscoveryService

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

ClusterDiscoveryService reads what a Slurm cluster already knows off the cluster itself — its partitions, and the allocations a login may charge — so that neither has to be retyped into a registration.

func NewClusterDiscoveryService

func NewClusterDiscoveryService(keys *credsvc.KeyAccess, configs *ConfigAccess, sshCtx *ssh.GlobalSSHContext) *ClusterDiscoveryService

NewClusterDiscoveryService returns a discovery service logging in through sshCtx, sharing its connection pool and interactive auth store with job submission.

func (*ClusterDiscoveryService) DiscoverAllocations

func (s *ClusterDiscoveryService) DiscoverAllocations(ctx context.Context, configID string) (*dto.AllocationDiscoveryResponse, error)

DiscoverAllocations returns the Slurm accounts the config's login may charge, with the partitions and QOS each is limited to.

It runs under a cluster config rather than a raw key, since an allocation belongs to a login on one cluster — which is exactly what a config is. Anyone who may submit under the config may ask: READ on it, as for submission. A config with an interactive key asks the caller to answer its prompts, as a run submitted under it would.

func (*ClusterDiscoveryService) DiscoverPartitions

DiscoverPartitions logs in to the head node and returns its partitions, in the shape a cluster registration takes them.

It is administrative, like registering the cluster it serves, and it logs in only under a key the caller owns: it is a way to make the server open an SSH session to a host of the caller's choosing, which nobody else's key may be lent to.

func (*ClusterDiscoveryService) WithRunner

WithRunner returns a copy of s running commands through run, for tests.

type ClusterPartitionService

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

ClusterPartitionService manages partitions as a sub-resource of their cluster.

Every operation is scoped by the cluster id from the path, and writes go through the partition repository rather than through the cluster's collection: mutating an owned, cascading collection risks deleting rows the caller never named.

func NewClusterPartitionService

func NewClusterPartitionService(db *gorm.DB, partitions *repository.ClusterPartitionRepository, clusters *repository.SlurmClusterRepository) *ClusterPartitionService

NewClusterPartitionService returns a partition service.

func (*ClusterPartitionService) Create

Create adds a partition to a cluster.

func (*ClusterPartitionService) Delete

func (s *ClusterPartitionService) Delete(ctx context.Context, clusterID, partitionID string) error

Delete removes a partition from a cluster.

func (*ClusterPartitionService) Get

func (s *ClusterPartitionService) Get(ctx context.Context, clusterID, partitionID string) (*dto.ClusterPartitionResponse, error)

Get returns one partition of a cluster.

func (*ClusterPartitionService) List

List returns every partition of a cluster.

func (*ClusterPartitionService) Update

Update changes a partition of a cluster.

type CommandRunner

type CommandRunner func(ctx context.Context, dial ssh.SSHDialConfig, command, target string) (string, string, error)

CommandRunner runs one command on a host, returning its stdout and stderr.

type ConfigAccess

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

ConfigAccess answers "may this caller submit under this config?" for services outside the compute package.

The process vertical asks it before letting a run be submitted under a config. Exposing the question rather than the tables is what keeps one definition of who may use a config: owner, admin, or a share, resolved exactly as it is here.

func NewConfigAccess

NewConfigAccess returns a checker over the config and sharing tables.

func (*ConfigAccess) RequireUsable

func (a *ConfigAccess) RequireUsable(ctx context.Context, id string) (*model.SlurmClusterConfig, error)

RequireUsable loads a config and checks the caller may submit under it: 404 when there is no such config, 403 when it is neither theirs nor shared with them.

READ is the bar rather than WRITE: a config is shared precisely so the people it reaches can run under it, and running under one does not change it.

func (*ConfigAccess) WithTx

func (a *ConfigAccess) WithTx(tx *gorm.DB) *ConfigAccess

WithTx returns a checker bound to tx, for checks made from inside a transaction.

type SlurmClusterConfigService

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

SlurmClusterConfigService manages the login configs jobs are submitted through.

Registering one is self-service: any authenticated caller may declare how they reach a cluster from the catalogue, under one of their own SSH credentials, and it belongs to them. Everyone else reaches it through its sharing rules — which is how they submit under a key they do not hold.

func NewSlurmClusterConfigService

NewSlurmClusterConfigService returns a cluster config service.

func (*SlurmClusterConfigService) Create

Create registers a config owned by the calling user, against an existing cluster and an existing SSH credential.

The owner is taken from the token, so there is no way to register a config on someone else's behalf.

func (*SlurmClusterConfigService) Delete

Delete removes a config together with its shares. Owner and admins only: a grantee holding WRITE may edit a config, but retiring the identity everyone else reaches the cluster through is not theirs to do.

func (*SlurmClusterConfigService) Get

Get returns one config, to an admin or to anyone a share reaches.

func (*SlurmClusterConfigService) List

List returns every config across every owner. Needs clusterconfig:list — it names who may submit as whom, and where.

func (*SlurmClusterConfigService) ListMine

ListMine returns the caller's own configs.

func (*SlurmClusterConfigService) ListSharedWithMe

ListSharedWithMe returns the configs other users have shared with the caller, directly or through a group, each carrying what it grants them.

func (*SlurmClusterConfigService) Update

Update changes a config, including which cluster it logs in to and which key it presents. It needs WRITE, which a share can confer.

The owner is deliberately left alone: re-deriving it from the caller's token would hand the config to whichever admin — or grantee — happened to issue the request.

type SlurmClusterService

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

SlurmClusterService manages Slurm clusters. Reads are open; writes are administrative.

A cluster is deployment topology holding no secret — a head node, a data endpoint and a set of queues — which is why it is readable by anyone and writable only by an admin. Who may log in to it, and as whom, is a SlurmClusterConfig and is governed by its own ownership and sharing rules.

func NewSlurmClusterService

NewSlurmClusterService returns a cluster service.

It holds the partition repository so a create can register a cluster's partitions in the same transaction as the cluster itself. Writes still go through that repository rather than through the cluster's owned collection, the same discipline the partition service keeps. The config repository is read-only here, and only so that deleting a cluster can report what still logs in to it.

func (*SlurmClusterService) Create

Create registers a cluster, along with any partitions the request carves it into.

The partitions are written in the same transaction as the cluster, so a cluster never becomes visible carrying half the layout it was registered with. A cluster that gains partitions later adds them through POST /api/v1/slurm-clusters/{slurmClusterId}/partitions instead.

func (*SlurmClusterService) Delete

func (s *SlurmClusterService) Delete(ctx context.Context, id string) error

Delete removes a cluster nothing logs in to, taking its partitions with it.

The foreign key from a config is RESTRICT, so the database would refuse this anyway; checking first turns an opaque constraint violation into a 409 naming how many configs still point at it. Their owners have to retire them, since an admin deleting the cluster out from under them would silently strand every share on those configs.

func (*SlurmClusterService) Get

Get returns one cluster.

func (*SlurmClusterService) List

List returns every cluster.

func (*SlurmClusterService) Update

Update changes a cluster's own fields, leaving its partitions untouched.

A body carrying partitions is rejected rather than ignored. They have no ids, so there is nothing to match an incoming partition to an existing row by: obeying the field would mean replacing the collection wholesale and deleting partitions the caller never mentioned, and ignoring it would silently drop what the caller asked for. The partition endpoints are where a cluster's layout changes.

Jump to

Keyboard shortcuts

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