hatchery

package
v0.0.0-...-08f4b0c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNopaymodels = errors.New("no paymodels found")

Functions

func MakeARequestWithContext

func MakeARequestWithContext(ctx context.Context, method string, apiEndpoint string, accessToken string, contentType string, headers map[string]string, body *bytes.Buffer) (*http.Response, error)

API key related helper functions Make http request with header and body

func NewEKSClientset

func NewEKSClientset(ctx context.Context, userName string, payModel PayModel) (corev1.CoreV1Interface, error)

Generate EKS kubeconfig using AWS role

func RegisterHatchery

func RegisterHatchery(mux *httptrace.ServeMux)

RegisterHatchery setup endpoints with the http engine

func RegisterSystem

func RegisterSystem(mux *httptrace.ServeMux)

func SetupAndTeardownTest

func SetupAndTeardownTest() func()

func StrToInt

func StrToInt(str string) (string, error)

func TGWRoutes

func TGWRoutes(userName string, tgwRoutetableId *string, tgwAttachmentId *string, svc *ec2.EC2, local bool, teardown bool, sess *CREDS) error

func VPCRoutes

func VPCRoutes(remote_network_info *NetworkInfo, main_network_info *NetworkInfo, tgwId *string, ec2_remote *ec2.EC2, ec2_local *ec2.EC2, teardown bool) error

func ValidateAuthzConfig

func ValidateAuthzConfig(logger *log.Logger, authzConfig AuthzConfig) error

Types

type APIKeyStruct

type APIKeyStruct struct {
	APIKey string `json:"api_key"`
	KeyID  string `json:"key_id"`
}

type AllPayModels

type AllPayModels struct {
	CurrentPayModel *PayModel  `json:"current_pay_model"`
	PayModels       []PayModel `json:"all_pay_models"`
}

type AppConfigInfo

type AppConfigInfo struct {
	AppType string `json:"type"`
	Path    string
	Name    string
}

AppConfigInfo provides the type and path of a supplementary config path

type AuthRequestResponse

type AuthRequestResponse struct {
	Auth bool `json:"auth"`
}

type AuthzConfig

type AuthzConfig struct {
	Version          float32 `json:"version"`
	AuthzVersion_0_1 AuthzVersion_0_1
}

func (*AuthzConfig) UnmarshalJSON

func (authzConfig *AuthzConfig) UnmarshalJSON(data []byte) error

type AuthzVersion_0_1

type AuthzVersion_0_1 struct {
	And           []AuthzVersion_0_1 `json:"and"`
	Or            []AuthzVersion_0_1 `json:"or"`
	ResourcePaths []string           `json:"resource_paths"`
	PayModels     []string           `json:"pay_models"`
}

type CREDS

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

func NewSVC

func NewSVC(sess *session.Session, roleArn string) CREDS

func (*CREDS) CreateEcsTaskExecutionRole

func (creds *CREDS) CreateEcsTaskExecutionRole() (*string, error)

func (*CREDS) CreateLoadBalancer

func (creds *CREDS) CreateLoadBalancer(userName string) (*elbv2.CreateLoadBalancerOutput, *string, *elbv2.CreateListenerOutput, error)

func (*CREDS) CreateLogGroup

func (sess *CREDS) CreateLogGroup(LogGroupName string, creds *credentials.Credentials) (string, error)

Create CloudWatch LogGroup for hatchery containers

func (*CREDS) CreateTaskDefinition

func (sess *CREDS) CreateTaskDefinition(input *CreateTaskDefinitionInput, userName string, hash string, awsAcctID string) (string, error)

Create/Update Task Definition in ECS

func (*CREDS) EFSFileSystem

func (creds *CREDS) EFSFileSystem(userName string) (*EFS, error)

func (*CREDS) NetworkConfig

func (creds *CREDS) NetworkConfig(userName string) (ecs.NetworkConfiguration, error)

type ComposeDeployDetails

type ComposeDeployDetails struct {
	Resources ComposeResources
}

ComposeDeployDetails holds supplemental information useful for scheduling a service

type ComposeFull

type ComposeFull struct {
	// name of the root service mapped to the magic port
	RootService string `yaml:"-"`
	Services    map[string]ComposeService
}

ComposeFull holds all the data harvested from a docker-compose.yaml file

func DockstoreComposeFromBytes

func DockstoreComposeFromBytes(yamlBytes []byte) (model *ComposeFull, err error)

DockstoreComposeFromBytes load and sanitize a compose app from given yaml bytes

func DockstoreComposeFromFile

func DockstoreComposeFromFile(filePath string) (model *ComposeFull, err error)

DockstoreComposeFromFile loads a hatchery application (container) config from a compose.yaml file

func DockstoreComposeFromStr

func DockstoreComposeFromStr(composeYaml string) (model *ComposeFull, err error)

DockstoreComposeFromStr load and sanitize a compose app from a given yaml string

func (*ComposeFull) BuildHatchApp

func (model *ComposeFull) BuildHatchApp() (*Container, error)

BuildHatchApp generates a hatchery container config from a dockstore compose application config

func (*ComposeFull) Sanitize

func (model *ComposeFull) Sanitize() error

Sanitize scans, validates, and decorates a given ComposeFull model

type ComposeHealthCheck

type ComposeHealthCheck struct {
	Test     []string
	Interval string
	Timeout  string
	Retries  int
}

ComposeHealthCheck holds the healthcheck details for a service

type ComposeResourceSpec

type ComposeResourceSpec struct {
	Memory string
	CPU    string `yaml:"cpus,omitempty"`
}

ComposeResourceSpec holds the cpu and memory values for a resource request

func (*ComposeResourceSpec) BuildK8sResource

func (rspec *ComposeResourceSpec) BuildK8sResource() map[k8sv1.ResourceName]resource.Quantity

BuildK8sResource from a compose resource spec

type ComposeResources

type ComposeResources struct {
	Requests ComposeResourceSpec `yaml:"reservations,omitempty"`
	Limits   ComposeResourceSpec
}

ComposeResources holds the resource requests and limits for a service (contianer)

type ComposeService

type ComposeService struct {
	Image           string
	Name            string
	Environment     []string
	Entrypoint      []string
	Command         []string
	Volumes         []string
	Ports           []string
	UserUID         int64    `yaml:"user_uid"`
	GroupUID        int64    `yaml:"group_uid"`
	FSGID           int64    `yaml:"fs_gid"`
	SecurityContext []string `yaml:"security_context"`
	Deploy          ComposeDeployDetails
	Healthcheck     ComposeHealthCheck
}

ComposeService is an entry in the services block of docker-compose

func (*ComposeService) ToK8sContainer

func (service *ComposeService) ToK8sContainer(friend *k8sv1.Container) (mountUserVolume bool, mountSharedMemory bool, err error)

ToK8sContainer copies data from the given service to the container friend Returns true if this container mounts the user volume. We try to avoid mounting that thing if possible while it's still EBS based.

type Container

type Container struct {
	Name               string            `json:"name"`
	CPULimit           string            `json:"cpu-limit"`
	MemoryLimit        string            `json:"memory-limit"`
	Image              string            `json:"image"`
	PullPolicy         string            `json:"pull_policy"`
	Env                map[string]string `json:"env"`
	TargetPort         int32             `json:"target-port"`
	Args               []string          `json:"args"`
	Command            []string          `json:"command"`
	PathRewrite        string            `json:"path-rewrite"`
	UseTLS             string            `json:"use-tls"`
	ReadyProbe         string            `json:"ready-probe"`
	LifecyclePreStop   []string          `json:"lifecycle-pre-stop"`
	LifecyclePostStart []string          `json:"lifecycle-post-start"`
	UserUID            int64             `json:"user-uid"`
	GroupUID           int64             `json:"group-uid"`
	FSGID              int64             `json:"fs-gid"`
	UserVolumeLocation string            `json:"user-volume-location"`
	Gen3VolumeLocation string            `json:"gen3-volume-location"`
	UseSharedMemory    string            `json:"use-shared-memory"`
	Friends            []k8sv1.Container `json:"friends"`
	NextflowConfig     NextflowConfig    `json:"nextflow"`
	License            LicenseInfo       `json:"license"`
	Authz              AuthzConfig       `json:"authz"`
}

Container Struct to hold the configuration for Pod Container

type ContainerStates

type ContainerStates struct {
	Name  string               `json:"name"`
	State k8sv1.ContainerState `json:"state"`
	Ready bool                 `json:"ready"`
}

type CreateTaskDefinitionInput

type CreateTaskDefinitionInput struct {
	Cpu              string
	EnvVars          []EnvVar
	ExecutionRoleArn string
	Image            string
	Memory           string
	Name             string
	Port             int64
	LogGroupName     string
	Volumes          []*ecs.Volume
	MountPoints      []*ecs.MountPoint
	LogRegion        string
	TaskRole         string
	Type             string
	EntryPoint       []string
	Args             []string
	SidecarContainer ecs.ContainerDefinition
}

func (*CreateTaskDefinitionInput) Environment

func (input *CreateTaskDefinitionInput) Environment() []*ecs.KeyValuePair

type DbConfig

type DbConfig struct {
	DynamoDb dynamodbiface.DynamoDBAPI
}

type EFS

type EFS struct {
	EFSArn        string
	FileSystemId  string
	AccessPointId string
}

type EnvVar

type EnvVar struct {
	Key   string
	Value string
}

type FullHatcheryConfig

type FullHatcheryConfig struct {
	Config        HatcheryConfig
	ContainersMap map[string]Container
	PayModelMap   map[string]PayModel
	Logger        *log.Logger
}

FullHatcheryConfig bucket result from loadConfig

var Config *FullHatcheryConfig

Config package-global shared hatchery config

func LoadConfig

func LoadConfig(configFilePath string, loggerIn *log.Logger) (config *FullHatcheryConfig, err error)

LoadConfig from a json file

type Gen3LicenseUserMap

type Gen3LicenseUserMap struct {
	ItemId             string `json:"itemId"`
	Environment        string `json:"environment"`
	LicenseType        string `json:"licenseType"`
	IsActive           string `json:"isActive"`
	UserId             string `json:"userId"`
	LicenseId          int    `json:"licenseId"`
	FirstUsedTimestamp int    `json:"firstUsedTimestamp"`
	LastUsedTimestamp  int    `json:"lastUsedTimestamp"`
}

type HatcheryConfig

type HatcheryConfig struct {
	UserNamespace   string   `json:"user-namespace"`
	DefaultPayModel PayModel `json:"default-pay-model"`
	// DisableLocalWS         bool             `json:"disable-local-ws"`
	PayModels              []PayModel           `json:"pay-models"`
	PayModelsDynamodbTable string               `json:"pay-models-dynamodb-table"`
	LicenseUserMapsTable   string               `json:"license-user-maps-dynamodb-table"`
	LicenseUserMapsGSI     string               `json:"license-user-maps-global-secondary-index"`
	License                LicenseInfo          `json:"license"`
	SubDir                 string               `json:"sub-dir"`
	Containers             []Container          `json:"containers"`
	UserVolumeSize         string               `json:"user-volume-size"`
	Sidecar                SidecarContainer     `json:"sidecar"`
	MoreConfigs            []AppConfigInfo      `json:"more-configs"`
	PrismaConfig           PrismaConfig         `json:"prisma"`
	NextflowGlobalConfig   NextflowGlobalConfig `json:"nextflow-global"`
}

HatcheryConfig is the root of all the configuration

type InstallBundle

type InstallBundle struct {
	WsAddress string `json:"wsAddress"`
	Bundle    string `json:"installBundle"`
}

type LicenseInfo

type LicenseInfo struct {
	Enabled         bool   `json:"enabled"`
	LicenseType     string `json:"license-type"`
	MaxLicenseIds   int    `json:"max-license-ids"`
	G3autoName      string `json:"g3auto-name"`
	G3autoKey       string `json:"g3auto-key"`
	FilePath        string `json:"file-path"`
	WorkspaceFlavor string `json:"workspace-flavor"`
}

LicenseInfo contains configuration for Gen3 supplied licenses.

type NetworkInfo

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

type NextflowConfig

type NextflowConfig struct {
	Enabled                bool     `json:"enabled"`
	JobImageWhitelist      []string `json:"job-image-whitelist"`
	S3BucketWhitelist      []string `json:"s3-bucket-whitelist"`
	ComputeEnvironmentType string   `json:"compute-environment-type"`
	InstanceAmi            string   `json:"instance-ami"`
	InstanceAmiBuilderArn  string   `json:"instance-ami-builder-arn"`
	InstanceType           string   `json:"instance-type"`
	InstanceMinVCpus       int32    `json:"instance-min-vcpus"`
	InstanceMaxVCpus       int32    `json:"instance-max-vcpus"`
}

Configuration specific to Nextflow containers

type NextflowGlobalConfig

type NextflowGlobalConfig struct {
	SampleConfigPublicImage   string `json:"sample-config-public-image"`
	ImageBuilderReaderRoleArn string `json:"imagebuilder-reader-role-arn"`
}

Global configuration shared by all Nextflow containers

type PayModel

type PayModel struct {
	Id              string  `json:"bmh_workspace_id"`
	Name            string  `json:"workspace_type"`
	User            string  `json:"user_id"`
	AWSAccountId    string  `json:"account_id"`
	Status          string  `json:"request_status"`
	Local           bool    `json:"local"`
	Region          string  `json:"region"`
	Ecs             bool    `json:"ecs"`
	Subnet          int     `json:"subnet"`
	HardLimit       float32 `json:"hard-limit"`
	SoftLimit       float32 `json:"soft-limit"`
	TotalUsage      float32 `json:"total-usage"`
	CurrentPayModel bool    `json:"current_pay_model"`
}

TODO remove PayModel from config once DynamoDB contains all necessary data

type PodConditions

type PodConditions struct {
	Type   string `json:"type"`
	Status string `json:"status"`
}

type PrismaConfig

type PrismaConfig struct {
	ConsoleAddress string `json:"console-address"`
	ConsoleVersion string `json:"console-version"`
	Enable         bool   `json:"enable"`
}

Config to allow for Prisma Agents

type SidecarContainer

type SidecarContainer struct {
	CPULimit         string            `json:"cpu-limit"`
	MemoryLimit      string            `json:"memory-limit"`
	Image            string            `json:"image"`
	Env              map[string]string `json:"env"`
	Args             []string          `json:"args"`
	Command          []string          `json:"command"`
	LifecyclePreStop []string          `json:"lifecycle-pre-stop"`
}

SidecarContainer holds fuse sidecar configuration

type TextOutput

type TextOutput struct {
	Text string
}

type Token

type Token struct {
	Token string `json:"token"`
}

type WorkspaceKernelStatusStruct

type WorkspaceKernelStatusStruct struct {
	LastActivityTime string `json:"last_activity"`
}

type WorkspaceStatus

type WorkspaceStatus struct {
	Status           string            `json:"status"`
	Conditions       []PodConditions   `json:"conditions"`
	ContainerStates  []ContainerStates `json:"containerStates"`
	IdleTimeLimit    int               `json:"idleTimeLimit"`
	LastActivityTime int64             `json:"lastActivityTime"`
	WorkspaceType    string            `json:"workspaceType"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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