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 ¶
- func NewSlurmClusterConfigSharingService(db *gorm.DB, configs *repository.SlurmClusterConfigRepository, ...) *sharingsvc.Service
- type ClusterDiscoveryService
- func (s *ClusterDiscoveryService) DiscoverAllocations(ctx context.Context, configID string) (*dto.AllocationDiscoveryResponse, error)
- func (s *ClusterDiscoveryService) DiscoverPartitions(ctx context.Context, req *dto.PartitionDiscoveryRequest) (*dto.PartitionDiscoveryResponse, error)
- func (s *ClusterDiscoveryService) WithRunner(run CommandRunner) *ClusterDiscoveryService
- type ClusterPartitionService
- func (s *ClusterPartitionService) Create(ctx context.Context, clusterID string, req *dto.ClusterPartitionRequest) (*dto.ClusterPartitionResponse, error)
- func (s *ClusterPartitionService) Delete(ctx context.Context, clusterID, partitionID string) error
- func (s *ClusterPartitionService) Get(ctx context.Context, clusterID, partitionID string) (*dto.ClusterPartitionResponse, error)
- func (s *ClusterPartitionService) List(ctx context.Context, clusterID string) ([]dto.ClusterPartitionResponse, error)
- func (s *ClusterPartitionService) Update(ctx context.Context, clusterID, partitionID string, ...) (*dto.ClusterPartitionResponse, error)
- type CommandRunner
- type ConfigAccess
- type SlurmClusterConfigService
- func (s *SlurmClusterConfigService) Create(ctx context.Context, req *dto.SlurmClusterConfigRequest) (*dto.SlurmClusterConfigResponse, error)
- func (s *SlurmClusterConfigService) Delete(ctx context.Context, id string) error
- func (s *SlurmClusterConfigService) Get(ctx context.Context, id string) (*dto.SlurmClusterConfigResponse, error)
- func (s *SlurmClusterConfigService) List(ctx context.Context) ([]dto.SlurmClusterConfigResponse, error)
- func (s *SlurmClusterConfigService) ListMine(ctx context.Context) ([]dto.SlurmClusterConfigResponse, error)
- func (s *SlurmClusterConfigService) ListSharedWithMe(ctx context.Context) ([]dto.SlurmClusterConfigResponse, error)
- func (s *SlurmClusterConfigService) Update(ctx context.Context, id string, req *dto.SlurmClusterConfigRequest) (*dto.SlurmClusterConfigResponse, error)
- type SlurmClusterService
- func (s *SlurmClusterService) Create(ctx context.Context, req *dto.SlurmClusterRequest) (*dto.SlurmClusterResponse, error)
- func (s *SlurmClusterService) Delete(ctx context.Context, id string) error
- func (s *SlurmClusterService) Get(ctx context.Context, id string) (*dto.SlurmClusterResponse, error)
- func (s *SlurmClusterService) List(ctx context.Context) ([]dto.SlurmClusterResponse, error)
- func (s *SlurmClusterService) Update(ctx context.Context, id string, req *dto.SlurmClusterRequest) (*dto.SlurmClusterResponse, error)
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 ¶
func (s *ClusterDiscoveryService) DiscoverPartitions(ctx context.Context, req *dto.PartitionDiscoveryRequest) (*dto.PartitionDiscoveryResponse, error)
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 ¶
func (s *ClusterDiscoveryService) WithRunner(run CommandRunner) *ClusterDiscoveryService
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 ¶
func (s *ClusterPartitionService) Create(ctx context.Context, clusterID string, req *dto.ClusterPartitionRequest) (*dto.ClusterPartitionResponse, error)
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 ¶
func (s *ClusterPartitionService) List(ctx context.Context, clusterID string) ([]dto.ClusterPartitionResponse, error)
List returns every partition of a cluster.
func (*ClusterPartitionService) Update ¶
func (s *ClusterPartitionService) Update(ctx context.Context, clusterID, partitionID string, req *dto.ClusterPartitionRequest) (*dto.ClusterPartitionResponse, error)
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 ¶
func NewConfigAccess( configs *repository.SlurmClusterConfigRepository, sharing *sharingrepo.Repository, members *iamrepo.GroupMemberRepository, ) *ConfigAccess
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 ¶
func NewSlurmClusterConfigService( db *gorm.DB, configs *repository.SlurmClusterConfigRepository, sharing *sharingrepo.Repository, clusters *repository.SlurmClusterRepository, keys *credsvc.KeyAccess, users *iamrepo.UserRepository, members *iamrepo.GroupMemberRepository, ) *SlurmClusterConfigService
NewSlurmClusterConfigService returns a cluster config service.
func (*SlurmClusterConfigService) Create ¶
func (s *SlurmClusterConfigService) Create(ctx context.Context, req *dto.SlurmClusterConfigRequest) (*dto.SlurmClusterConfigResponse, error)
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 ¶
func (s *SlurmClusterConfigService) Delete(ctx context.Context, id string) error
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 ¶
func (s *SlurmClusterConfigService) Get(ctx context.Context, id string) (*dto.SlurmClusterConfigResponse, error)
Get returns one config, to an admin or to anyone a share reaches.
func (*SlurmClusterConfigService) List ¶
func (s *SlurmClusterConfigService) List(ctx context.Context) ([]dto.SlurmClusterConfigResponse, error)
List returns every config across every owner. Needs clusterconfig:list — it names who may submit as whom, and where.
func (*SlurmClusterConfigService) ListMine ¶
func (s *SlurmClusterConfigService) ListMine(ctx context.Context) ([]dto.SlurmClusterConfigResponse, error)
ListMine returns the caller's own configs.
func (*SlurmClusterConfigService) ListSharedWithMe ¶
func (s *SlurmClusterConfigService) ListSharedWithMe(ctx context.Context) ([]dto.SlurmClusterConfigResponse, error)
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 ¶
func (s *SlurmClusterConfigService) Update(ctx context.Context, id string, req *dto.SlurmClusterConfigRequest) (*dto.SlurmClusterConfigResponse, error)
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 ¶
func NewSlurmClusterService( db *gorm.DB, clusters *repository.SlurmClusterRepository, partitions *repository.ClusterPartitionRepository, configs *repository.SlurmClusterConfigRepository, ) *SlurmClusterService
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 ¶
func (s *SlurmClusterService) Create(ctx context.Context, req *dto.SlurmClusterRequest) (*dto.SlurmClusterResponse, error)
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 ¶
func (s *SlurmClusterService) Get(ctx context.Context, id string) (*dto.SlurmClusterResponse, error)
Get returns one cluster.
func (*SlurmClusterService) List ¶
func (s *SlurmClusterService) List(ctx context.Context) ([]dto.SlurmClusterResponse, error)
List returns every cluster.
func (*SlurmClusterService) Update ¶
func (s *SlurmClusterService) Update(ctx context.Context, id string, req *dto.SlurmClusterRequest) (*dto.SlurmClusterResponse, error)
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.