svc

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//JobVolumeTypeInput determines the volume to be input
	JobVolumeTypeInput = JobVolumeType("input")

	//JobVolumeTypeOutput determines the volume to output
	JobVolumeTypeOutput = JobVolumeType("output")
)

Variables

View Source
var ErrMinikubeOnly = errors.New("temp DI can only be created on Minikube")

ErrMinikubeOnly is returned when a temp di is created on something thats not minikube

View Source
var (
	//JobDefaultBackoffLimit determines how often we will retry a pod's job on when its failing
	JobDefaultBackoffLimit = int32(3)
)
View Source
var NodeLimitedQuota = ListQuotaItem{}

NodeLimitedQuota is used when no quota is configured

Functions

func ExtractRegistry

func ExtractRegistry(image string) (string, string, string, string)

ExtractRegistry takes a string as input and divides it in image, project, registry, tag

func IsDatasetSpecErr

func IsDatasetSpecErr(err error) bool

IsDatasetSpecErr is returned when a invalid input/output spec was given

func IsRaceConditionErr

func IsRaceConditionErr(err error) bool

IsRaceConditionErr is returned when we couldn't retrieve any logs for the job

func IsValidationErr

func IsValidationErr(err error) bool

IsValidationErr asserts for a validation error

Types

type AddNerdDependenciesInput

type AddNerdDependenciesInput struct {
	Dependencies []string
}

AddNerdDependenciesInput is used to configure the resource creation

type CreateDatasetInput

type CreateDatasetInput struct {
	Name string `validate:"printascii"`
	Size uint64

	StoreOptions    transferstore.StoreOptions       `validate:"required"`
	ArchiverOptions transferarchiver.ArchiverOptions `validate:"required"`
}

CreateDatasetInput is the input to CreateDataset

type CreateDatasetOutput

type CreateDatasetOutput struct {
	Name string
}

CreateDatasetOutput is the output to CreateDataset

type CreateSecretInput

type CreateSecretInput struct {
	Image    string `validate:"printascii"`
	Registry string `validate:"required"`
	Project  string
	Tag      string
	Username string `validate:"required"`
	Password string `validate:"required"`
}

CreateSecretInput is the input to CreateSecret

type CreateSecretOutput

type CreateSecretOutput struct {
	Name string
}

CreateSecretOutput is the output to CreateSecret

type DI

type DI interface {
	Kube() kubernetes.Interface
	Crd() crd.Interface
	APIExt() apiext.Interface
	Validator() Validator
	Logger() Logger
	Namespace() string
}

DI provides dependencies for our services

func TempDI

func TempDI(name string) (di DI, clean func(), err error)

TempDI returns a temporary DI for the Kube service that sets up a temporary namespace which can be deleted using clean. Mostly usefull for testing purposes. If name is empty a 16 byte random one will be generated

type DatasetDetails

type DatasetDetails struct {
	CreatedAt  time.Time
	Size       uint64
	InputFor   []string
	OutputFrom []string
}

DatasetDetails tells us more about the dataset by looking at underlying resources

type DeleteDatasetInput

type DeleteDatasetInput struct {
	Name string `validate:"min=1,printascii"`
}

DeleteDatasetInput is the input to DeleteDataset

type DeleteDatasetOutput

type DeleteDatasetOutput struct{}

DeleteDatasetOutput is the output to DeleteDataset

type DeleteJobInput

type DeleteJobInput struct {
	Name string `validate:"min=1,printascii"`
}

DeleteJobInput is the input to DeleteJob

type DeleteJobOutput

type DeleteJobOutput struct{}

DeleteJobOutput is the output to DeleteJob

type DeleteSecretInput

type DeleteSecretInput struct {
	Name string `validate:"min=1,printascii"`
}

DeleteSecretInput is the input to DeleteSecret

type DeleteSecretOutput

type DeleteSecretOutput struct{}

DeleteSecretOutput is the output to DeleteSecret

type FetchJobLogsInput

type FetchJobLogsInput struct {
	Tail int64  `validate:"min=0"`
	Name string `validate:"min=1,printascii"`
}

FetchJobLogsInput is the input to FetchJobLogs

type FetchJobLogsOutput

type FetchJobLogsOutput struct {
	Data []byte
}

FetchJobLogsOutput is the output to FetchJobLogs

type GetDatasetInput

type GetDatasetInput struct {
	Name string `validate:"printascii"`
}

GetDatasetInput is the input to GetDataset

type GetDatasetOutput

type GetDatasetOutput struct {
	Name string
	Size uint64

	InputFor   []string
	OutputFrom []string

	StoreOptions    transferstore.StoreOptions
	ArchiverOptions transferarchiver.ArchiverOptions
}

GetDatasetOutput is the output to GetDataset

func GetDatasetOutputFromSpec

func GetDatasetOutputFromSpec(dataset *datasetsv1.Dataset) *GetDatasetOutput

GetDatasetOutputFromSpec allows easy output creation from dataset

type GetSecretInput

type GetSecretInput struct {
	Name string `validate:"printascii"`
}

GetSecretInput is the input to GetSecret

type GetSecretOutput

type GetSecretOutput struct {
	Name      string
	Size      int
	Image     string
	CreatedAt time.Time
	Type      string
}

GetSecretOutput is the output to GetSecret

type JobDetails

type JobDetails struct {
	SeenAt               time.Time
	Phase                JobDetailsPhase
	Scheduled            bool   //indicate if the pod was scheduled
	Parallelism          int32  //job width, if 0 this means it was stopped
	WaitingReason        string //why the job -> pod -> container is waiting
	WaitingMessage       string //explains why we're waiting
	TerminatedReason     string //termination of main container
	TerminatedMessage    string //explains why its terminated
	TerminatedExitCode   int32  //exit code it was terminated with
	UnschedulableReason  string //when scheduling condition is false
	UnschedulableMessage string
	FailedCreateEvents   []JobEvent
}

JobDetails tells us more about the job by looking at underlying resources

type JobDetailsPhase

type JobDetailsPhase string

JobDetailsPhase is a high level description of the underlying pod

var (
	// JobDetailsPhasePending means the pod has been accepted by the system, but one or more of the containers
	// has not been started. This includes time before being bound to a node, as well as time spent
	// pulling images onto the host.
	JobDetailsPhasePending JobDetailsPhase = "Pending"
	// JobDetailsPhaseRunning means the pod has been bound to a node and all of the containers have been started.
	// At least one container is still running or is in the process of being restarted.
	JobDetailsPhaseRunning JobDetailsPhase = "Running"
	// JobDetailsPhaseSucceeded means that all containers in the pod have voluntarily terminated
	// with a container exit code of 0, and the system is not going to restart any of these containers.
	JobDetailsPhaseSucceeded JobDetailsPhase = "Succeeded"
	// JobDetailsPhaseFailed means that all containers in the pod have terminated, and at least one container has
	// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
	JobDetailsPhaseFailed JobDetailsPhase = "Failed"
	// JobDetailsPhaseUnknown means that for some reason the state of the pod could not be obtained, typically due
	// to an error in communicating with the host of the pod.
	JobDetailsPhaseUnknown JobDetailsPhase = "Unknown"
)

type JobEvent

type JobEvent struct {
	Message string
}

JobEvent contains infromation from the events

type JobVolume

type JobVolume struct {
	MountPath     string `validate:"is-abs-path"`
	InputDataset  string
	OutputDataset string
}

JobVolume can be used in a job

type JobVolumeType

type JobVolumeType string

JobVolumeType determines if its content will be uploaded or downloaded

type Kube

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

Kube interacts with the kubernetes backend

func NewKube

func NewKube(di DI) (k *Kube)

NewKube will setup the Kubernetes service

func (*Kube) AddNerdDependencies

func (k *Kube) AddNerdDependencies(ctx context.Context, in *AddNerdDependenciesInput) (err error)

AddNerdDependencies will deploy necessary daemonsets, controllers and roles so that a private cluster can be used by the cli

func (*Kube) CreateDataset

func (k *Kube) CreateDataset(ctx context.Context, in *CreateDatasetInput) (out *CreateDatasetOutput, err error)

CreateDataset will create a dataset on kubernetes

func (*Kube) CreateSecret

func (k *Kube) CreateSecret(ctx context.Context, in *CreateSecretInput) (out *CreateSecretOutput, err error)

CreateSecret will create a secret on kubernetes

func (*Kube) DeleteDataset

func (k *Kube) DeleteDataset(ctx context.Context, in *DeleteDatasetInput) (out *DeleteDatasetOutput, err error)

DeleteDataset will create a dataset on kubernetes

func (*Kube) DeleteJob

func (k *Kube) DeleteJob(ctx context.Context, in *DeleteJobInput) (out *DeleteJobOutput, err error)

DeleteJob will create a job on kubernetes

func (*Kube) DeleteSecret

func (k *Kube) DeleteSecret(ctx context.Context, in *DeleteSecretInput) (out *DeleteSecretOutput, err error)

DeleteSecret will create a dataset on kubernetes

func (*Kube) FetchJobLogs

func (k *Kube) FetchJobLogs(ctx context.Context, in *FetchJobLogsInput) (out *FetchJobLogsOutput, err error)

FetchJobLogs will create a job on kubernetes

func (*Kube) GetDataset

func (k *Kube) GetDataset(ctx context.Context, in *GetDatasetInput) (out *GetDatasetOutput, err error)

GetDataset will retrieve a dataset from kubernetes

func (*Kube) GetSecret

func (k *Kube) GetSecret(ctx context.Context, in *GetSecretInput) (out *GetSecretOutput, err error)

GetSecret will retrieve the secret matching the provided name from kubernetes

func (*Kube) IsNerdCompliant

func (k *Kube) IsNerdCompliant(ctx context.Context) (ok bool, dependencies []string, err error)

IsNerdCompliant checks if the nlz-utils are running on the current cluster

func (*Kube) ListDatasets

func (k *Kube) ListDatasets(ctx context.Context, in *ListDatasetsInput) (out *ListDatasetsOutput, err error)

ListDatasets will create a dataset on kubernetes

func (*Kube) ListJobs

func (k *Kube) ListJobs(ctx context.Context, in *ListJobsInput) (out *ListJobsOutput, err error)

ListJobs will list jobs on kubernetes

func (*Kube) ListQuotas

func (k *Kube) ListQuotas(ctx context.Context, in *ListQuotasInput) (out *ListQuotasOutput, err error)

ListQuotas will list quotas on kubernetes

func (*Kube) ListSecrets

func (k *Kube) ListSecrets(ctx context.Context, in *ListSecretsInput) (out *ListSecretsOutput, err error)

ListSecrets will create a secret on kubernetes

func (*Kube) RunJob

func (k *Kube) RunJob(ctx context.Context, in *RunJobInput) (out *RunJobOutput, err error)

RunJob will create a job on kubernetes

func (*Kube) UpdateDataset

func (k *Kube) UpdateDataset(ctx context.Context, in *UpdateDatasetInput) (out *UpdateDatasetOutput, err error)

UpdateDataset will update a dataset resource. Fields that can be updated: name, input, output and size. Input and output are the jobs the dataset is used for or coming from.

func (*Kube) UpdateSecret

func (k *Kube) UpdateSecret(ctx context.Context, in *UpdateSecretInput) (out *UpdateSecretOutput, err error)

UpdateSecret will update a secret resource. Fields that can be updated: name, input, output and size. Input and output are the jobs the secret is used for or coming from.

type ListDatasetItem

type ListDatasetItem struct {
	Name    string
	Details DatasetDetails
}

ListDatasetItem is a dataset listing item

type ListDatasetsInput

type ListDatasetsInput struct{}

ListDatasetsInput is the input to ListDatasets

type ListDatasetsOutput

type ListDatasetsOutput struct {
	Items []*ListDatasetItem
}

ListDatasetsOutput is the output to ListDatasets

type ListJobItem

type ListJobItem struct {
	Name        string
	Image       string
	Input       []string
	Output      []string
	Memory      int64
	VCPU        int64
	CreatedAt   time.Time
	DeletedAt   time.Time
	ActiveAt    time.Time
	CompletedAt time.Time
	FailedAt    time.Time

	Details JobDetails
}

ListJobItem is a job listing item

type ListJobsInput

type ListJobsInput struct{}

ListJobsInput is the input to ListJobs

type ListJobsOutput

type ListJobsOutput struct {
	Items []*ListJobItem
}

ListJobsOutput is the output to ListJobs

type ListQuotaItem

type ListQuotaItem struct {
	RequestCPU    int64
	LimitCPU      int64
	LimitMemory   int64
	RequestMemory int64

	UseRequestCPU    int64
	UseLimitCPU      int64
	UseLimitMemory   int64
	UseRequestMemory int64

	Labels map[string]string
}

ListQuotaItem describes a namespace quota

type ListQuotasInput

type ListQuotasInput struct{}

ListQuotasInput is the input to ListQuotas

type ListQuotasOutput

type ListQuotasOutput struct {
	Items []*ListQuotaItem
}

ListQuotasOutput is the output to ListQuotas

type ListSecretItem

type ListSecretItem struct {
	Name    string
	Details SecretDetails
}

ListSecretItem is a secret listing item

type ListSecretsInput

type ListSecretsInput struct {
	Labels []string
}

ListSecretsInput is the input to ListSecrets

type ListSecretsOutput

type ListSecretsOutput struct {
	Items []*ListSecretItem
}

ListSecretsOutput is the output to ListSecrets

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
}

Logger describes the logging dependency the services require

type RunJobInput

type RunJobInput struct {
	Image        string `validate:"min=1"`
	Name         string `validate:"printascii"`
	Env          map[string]string
	BackoffLimit *int32
	Args         []string
	Volumes      []JobVolume
	Memory       string
	VCPU         string
	Secret       string
}

RunJobInput is the input to RunJob

type RunJobOutput

type RunJobOutput struct {
	Name string
}

RunJobOutput is the output to RunJob

type SecretDetails

type SecretDetails struct {
	CreatedAt time.Time
	Size      int
	Type      string
	Image     string
}

SecretDetails tells us more about the secret by looking at underlying resources

type UpdateDatasetInput

type UpdateDatasetInput struct {
	Name       string `validate:"printascii"`
	NewName    string `validate:"printascii"`
	Size       *uint64
	InputFor   string
	OutputFrom string
}

UpdateDatasetInput is the input for UpdateDataset

type UpdateDatasetOutput

type UpdateDatasetOutput struct {
	Name string
}

UpdateDatasetOutput is the output for UpdateDataset

type UpdateSecretInput

type UpdateSecretInput struct {
	Name     string `validate:"printascii"`
	Username string
	Password string
}

UpdateSecretInput is the input for UpdateSecret

type UpdateSecretOutput

type UpdateSecretOutput struct {
	Name string
}

UpdateSecretOutput is the output for UpdateSecret

type Validator

type Validator interface {
	StructCtx(ctx context.Context, s interface{}) (err error)
	Struct(s interface{}) (err error)
}

Validator describes the validation dependency we require

Jump to

Keyboard shortcuts

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