Skip to content

Commit

Permalink
Refactor JobState to string (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Rahmansyah authored May 8, 2024
1 parent 9b21e1b commit c96619d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions api/turing/api/ensembler_images_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (c EnsemblerImagesController) BuildImage(
if err != nil {
return InternalServerError("unable to get MLP project for the router", err.Error())
}
log.Infof("project: %v", project)

ensembler, err := c.EnsemblersService.FindByID(
*options.EnsemblerID,
Expand All @@ -87,7 +86,7 @@ func (c EnsemblerImagesController) BuildImage(

go func() {
if err := c.EnsemblerImagesService.BuildImage(project, pyFuncEnsembler, request.RunnerType); err != nil {
log.Errorf("unable to build ensembler image", err.Error())
log.Errorf("unable to build ensembler image: %s", err.Error())
}
}()

Expand Down
15 changes: 9 additions & 6 deletions api/turing/imagebuilder/imagebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (js JobStatus) IsActive() bool {
return js.State == JobStateActive
}

type JobState int
type JobState string

const (
// jobDeletionTimeoutInSeconds is the maximum time to wait for a job to be deleted from a cluster
Expand All @@ -60,14 +60,17 @@ const (
jobDeletionTickDurationInMilliseconds = 100
// jobCompletionTickDurationInSeconds is the interval at which the API server checks if a job has completed
jobCompletionTickDurationInSeconds = 5
)

const (
// JobStateActive is the status of the image building job is active
JobStateActive = JobState(iota)
// JobStateFailed is when the image building job has failed
JobStateFailed
JobStateActive JobState = "active"
// JobStateSucceeded is when the image building job has succeeded
JobStateSucceeded
JobStateSucceeded JobState = "succeeded"
// JobStateFailed is when the image building job has failed
JobStateFailed JobState = "failed"
// JobStateUnknown is when the image building job status is unknown
JobStateUnknown
JobStateUnknown JobState = "unknown"
)

// BuildImageRequest contains the information needed to build the OCI image
Expand Down

0 comments on commit c96619d

Please sign in to comment.