From c96619d894db27c99bdf738d61237b3241121e93 Mon Sep 17 00:00:00 2001 From: Arief Rahmansyah Date: Wed, 8 May 2024 13:36:25 +0700 Subject: [PATCH] Refactor JobState to string (#379) --- api/turing/api/ensembler_images_api.go | 3 +-- api/turing/imagebuilder/imagebuilder.go | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/api/turing/api/ensembler_images_api.go b/api/turing/api/ensembler_images_api.go index 94f11970d..64630ad7b 100644 --- a/api/turing/api/ensembler_images_api.go +++ b/api/turing/api/ensembler_images_api.go @@ -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, @@ -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()) } }() diff --git a/api/turing/imagebuilder/imagebuilder.go b/api/turing/imagebuilder/imagebuilder.go index ae8d15ec9..d0225fbee 100644 --- a/api/turing/imagebuilder/imagebuilder.go +++ b/api/turing/imagebuilder/imagebuilder.go @@ -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 @@ -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