Documentation ¶
Index ¶
- Constants
- Variables
- func CheckWorkerModelRegister(ctx context.Context, h Interface, modelPath string) error
- func Create(ctx context.Context, h Interface) error
- func GetMetrics() *sdk.HatcheryMetrics
- func InitMetrics(ctx context.Context) error
- func ModelInterpolateSecrets(hWithModels InterfaceWithModels, model *sdk.Model) error
- func NewWorkerToken(hatcheryName string, privateKey *rsa.PrivateKey, expiration time.Time, ...) (string, error)
- func NewWorkerTokenV2(hatcheryName string, privateKey *rsa.PrivateKey, expiration time.Time, ...) (string, error)
- func ParseArgs(str string) []string
- func ParseRequirementModel(rm string) (string, map[string]string)
- func PrepareCommonLogMessage(hatcheryServiceName string, hatcheryServiceID int64, ...) cdslog.Message
- func SendSpawnInfo(ctx context.Context, h Interface, jobID string, spawnMsg sdk.SpawnMsg)
- func WorkerPool(ctx context.Context, h Interface, statusFilter ...string) ([]sdk.Worker, error)
- type CacheNbAttemptsJobIDs
- type Interface
- type InterfaceWithModels
- type JobIdentifiers
- type JobIdentifiersV1
- type JobIdentifiersV2
- type SpawnArguments
- type SpawnArgumentsJWT
- type SpawnArgumentsJWTV2
- type WorkerJWTClaims
- type WorkerJWTClaimsV2
Constants ¶
const ( LabelServiceJobID = "CDS_JOB_ID" LabelServiceRunJobID = "CDS_RUN_JOB_ID" LabelServiceProjectKey = "CDS_PROJECT_KEY" LabelServiceWorkflowName = "CDS_WORKFLOW_NAME" LabelServiceWorkflowID = "CDS_WORKFLOW_ID" LabelServiceRunID = "CDS_WORKFLOW_RUN_ID" LabelServiceNodeRunName = "CDS_NODE_RUN_NAME" LabelServiceNodeRunID = "CDS_NODE_RUN_ID" LabelServiceJobName = "CDS_JOB_NAME" LabelServiceID = "CDS_SERVICE_ID" LabelServiceReqName = "CDS_SERVICE_NAME" LabelServiceWorker = "service_worker" LabelServiceVersion = "CDS_SERVICE_VERSION" LabelServiceRunNumber = "CDS_SERVICE_RUN_NUMBER" LabelServiceRunAttempt = "CDS_SERVICE_RUN_ATTEMPT" LabelServiceRegion = "CDS_SERVICE_REGION" ValueLabelServiceVersion1 = "service_v1" ValueLabelServiceVersion2 = "service_v2" )
const MemoryRegisterContainer int64 = 128
MemoryRegisterContainer is the RAM used for spawning a docker container for register a worker model. 128 Mo
Variables ¶
var ( // Client is a CDS Client Client cdsclient.HTTPClient CacheNbAttemptsIDsTTL = 1 * time.Hour )
var ( LogFieldJobID = log.Field("action_metadata_job_id") LogFieldStep = log.Field("hatchery_step") LogFieldStepDelay = log.Field("hatchery_step_delay_num") LogFieldProjectID = log.Field("worker_project_id") LogFieldProject = log.Field("worker_project") LogFieldWorkflow = log.Field("worker_workflow") LogFieldNodeRunID = log.Field("worker_node_run_id") LogFieldNodeRun = log.Field("worker_node_run") LogFieldModel = log.Field("worker_model") LogFieldServiceCount = log.Field("worker_service_count_num") )
Functions ¶
func CheckWorkerModelRegister ¶
CheckWorkerModelRegister checks if a model has been registered, if not it raises an error on the API
func GetMetrics ¶
func GetMetrics() *sdk.HatcheryMetrics
GetMetrics returns the metric stats measures
func InitMetrics ¶
func ModelInterpolateSecrets ¶
func ModelInterpolateSecrets(hWithModels InterfaceWithModels, model *sdk.Model) error
ModelInterpolateSecrets interpolates secrets that can exists inside given model.
func NewWorkerToken ¶
func NewWorkerToken(hatcheryName string, privateKey *rsa.PrivateKey, expiration time.Time, w SpawnArguments) (string, error)
NewWorkerToken .
func NewWorkerTokenV2 ¶ added in v0.53.0
func NewWorkerTokenV2(hatcheryName string, privateKey *rsa.PrivateKey, expiration time.Time, w SpawnArguments) (string, error)
NewWorkerTokenV2 .
func ParseArgs ¶
ParseArgs splits str on spaces into a slice of strings taking into account any quoting (using ” or "") even inside args, and any backslash-escaping even without quotes:
`abc def` → ["abc", "def"] ` abc def ` → ["abc", "def"] ` '' "" ` → ["", ""] ` a'bc' d"e"f ` → ["abc", "def"] `'a\bc\'' "def" ` → ["abc'", "def"] ` abc\ def ` → ["abc def"]
func ParseRequirementModel ¶
ParseRequirementModel parses a requirement model than returns the image name and the environment variables.
Example of input:
"postgres:latest env_1=blabla env_2=blabla env_3 env_4='zip'"
func PrepareCommonLogMessage ¶ added in v0.53.1
func SendSpawnInfo ¶
SendSpawnInfo sends a spawnInfo
Types ¶
type CacheNbAttemptsJobIDs ¶
type CacheNbAttemptsJobIDs struct {
// contains filtered or unexported fields
}
func (*CacheNbAttemptsJobIDs) Key ¶
func (c *CacheNbAttemptsJobIDs) Key(id int64) string
func (*CacheNbAttemptsJobIDs) NewAttempt ¶
func (c *CacheNbAttemptsJobIDs) NewAttempt(key string) int
type Interface ¶
type Interface interface { Name() string Type() string InitHatchery(ctx context.Context) error SpawnWorker(ctx context.Context, spawnArgs SpawnArguments) error CanSpawn(ctx context.Context, model sdk.WorkerStarterWorkerModel, jobID string, requirements []sdk.Requirement) bool WorkersStarted(ctx context.Context) ([]string, error) Service() *sdk.Service CDSClient() cdsclient.Interface CDSClientV2() cdsclient.HatcheryServiceClient Configuration() service.HatcheryCommonConfiguration Serve(ctx context.Context) error GetPrivateKey() *rsa.PrivateKey GetGoRoutines() *sdk.GoRoutines GetMapPendingWorkerCreation() *sdk.HatcheryPendingWorkerCreation GetRegion() string }
Interface describe an interface for each hatchery mode Init create new clients for different api SpawnWorker creates a new vm instance CanSpawn return wether or not hatchery can spawn model WorkersStartedByModel returns the number of instances of given model started but not necessarily register on CDS yet WorkersStarted returns the number of instances started but not necessarily register on CDS yet Hatchery returns hatchery instance Client returns cdsclient instance ModelType returns type of hatchery NeedRegistration return true if worker model need regsitration ID returns hatchery id
type InterfaceWithModels ¶
type JobIdentifiers ¶
type JobIdentifiers struct { JobIdentifiersV1 JobIdentifiersV1 JobIdentifiersV2 JobIdentifiersV2 }
func GetServiceIdentifiersFromLabels ¶ added in v0.53.1
func GetServiceIdentifiersFromLabels(labels map[string]string) *JobIdentifiers
func (JobIdentifiers) IsJobV2 ¶ added in v0.53.1
func (j JobIdentifiers) IsJobV2() bool
type JobIdentifiersV1 ¶ added in v0.53.1
type JobIdentifiersV2 ¶ added in v0.53.1
type SpawnArguments ¶
type SpawnArguments struct { WorkerName string `json:"worker_model"` WorkerToken string Model sdk.WorkerStarterWorkerModel `json:"model"` JobName string `json:"job_name"` JobID string `json:"job_id"` NodeRunID int64 `json:"node_run_id"` NodeRunName string `json:"node_run_name"` Requirements []sdk.Requirement `json:"requirements"` RegisterOnly bool `json:"register_only"` HatcheryName string `json:"hatchery_name"` ProjectKey string `json:"project_key"` WorkflowName string `json:"workflow_name"` WorkflowID int64 `json:"workflow_id"` RunID string `json:"run_id"` RunJobID string `json:"run_job_id"` Region string `json:"region"` Services map[string]sdk.V2JobService `json:"services,omitempty"` RunNumber int64 `json:"run_number"` RunAttempt int64 `json:"run_attempt"` }
SpawnArguments contains arguments to func SpawnWorker
func (*SpawnArguments) ModelName ¶
func (s *SpawnArguments) ModelName() string
type SpawnArgumentsJWT ¶ added in v0.52.0
type SpawnArgumentsJWT struct { WorkerName string `json:"worker_model,omitempty"` Model struct { ID int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` } `json:"model,omitempty"` JobID int64 `json:"job_id,omitempty"` RegisterOnly bool `json:"register_only"` HatcheryName string `json:"hatchery_name,omitempty"` }
func (SpawnArgumentsJWT) Validate ¶ added in v0.52.0
func (s SpawnArgumentsJWT) Validate() error
type SpawnArgumentsJWTV2 ¶ added in v0.53.0
type SpawnArgumentsJWTV2 struct { WorkerName string `json:"worker_model,omitempty"` ModelName string `json:"model_name,omitempty"` RunJobID string `json:"run_job_id,omitempty"` HatcheryName string `json:"hatchery_name,omitempty"` }
func (SpawnArgumentsJWTV2) Validate ¶ added in v0.53.0
func (s SpawnArgumentsJWTV2) Validate() error
type WorkerJWTClaims ¶
type WorkerJWTClaims struct { jwt.StandardClaims Worker SpawnArgumentsJWT }
WorkerJWTClaims is the specific claims format for Worker JWT
type WorkerJWTClaimsV2 ¶ added in v0.53.0
type WorkerJWTClaimsV2 struct { jwt.StandardClaims Worker SpawnArgumentsJWTV2 }
WorkerJWTClaims is the specific claims format for Worker JWT
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock_hatchery is a generated GoMock package.
|
Package mock_hatchery is a generated GoMock package. |