Skip to content

Commit

Permalink
Merge pull request ClusterCockpit#249 from ClusterCockpit/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
moebiusband73 authored Mar 19, 2024
2 parents 81fe492 + c65694b commit e45ecbd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
39 changes: 31 additions & 8 deletions internal/api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ type UpdateUserApiResponse struct {

// StopJobApiRequest model
type StopJobApiRequest struct {
// Stop Time of job as epoch
JobId *int64 `json:"jobId" example:"123000"`
Cluster *string `json:"cluster" example:"fritz"`
StartTime *int64 `json:"startTime" example:"1649723812"`
State schema.JobState `json:"jobState" validate:"required" example:"completed"`
StopTime int64 `json:"stopTime" validate:"required" example:"1649763839"`
State schema.JobState `json:"jobState" validate:"required" example:"completed"` // Final job state
JobId *int64 `json:"jobId" example:"123000"` // Cluster Job ID of job
Cluster *string `json:"cluster" example:"fritz"` // Cluster of job
StartTime *int64 `json:"startTime" example:"1649723812"` // Start Time of job as epoch
}

// DeleteJobApiRequest model
Expand Down Expand Up @@ -176,9 +175,9 @@ type GetCompleteJobApiResponse struct {
}

type JobMetricWithName struct {
Metric *schema.JobMetric `json:"metric"`
Name string `json:"name"`
Scope schema.MetricScope `json:"scope"`
Metric *schema.JobMetric `json:"metric"`
}

type ApiReturnedUser struct {
Expand Down Expand Up @@ -482,6 +481,18 @@ func (api *RestApi) getCompleteJobById(rw http.ResponseWriter, r *http.Request)
return
}

job.Tags, err = api.JobRepository.GetTags(&job.ID)
if err != nil {
handleError(err, http.StatusInternalServerError, rw)
return

}
if _, err = api.JobRepository.FetchMetadata(job); err != nil {

handleError(err, http.StatusInternalServerError, rw)
return
}

var scopes []schema.MetricScope

if job.NumNodes == 1 {
Expand All @@ -492,7 +503,7 @@ func (api *RestApi) getCompleteJobById(rw http.ResponseWriter, r *http.Request)

var data schema.JobData

if r.URL.Query().Has("all-metrics") {
if r.URL.Query().Get("all-metrics") == "true" {
data, err = metricdata.LoadData(job, nil, scopes, r.Context())
if err != nil {
log.Warn("Error while loading job data")
Expand Down Expand Up @@ -564,6 +575,18 @@ func (api *RestApi) getJobById(rw http.ResponseWriter, r *http.Request) {
return
}

job.Tags, err = api.JobRepository.GetTags(&job.ID)
if err != nil {
handleError(err, http.StatusInternalServerError, rw)
return

}
if _, err = api.JobRepository.FetchMetadata(job); err != nil {

handleError(err, http.StatusInternalServerError, rw)
return
}

var metrics GetJobApiRequest
if err = decode(r.Body, &metrics); err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest)
Expand Down Expand Up @@ -1218,7 +1241,7 @@ func (api *RestApi) createUser(rw http.ResponseWriter, r *http.Request) {
return
}

rw.Write([]byte(fmt.Sprintf("User %v successfully created!\n", username)))
fmt.Fprintf(rw, "User %v successfully created!\n", username)
}

// deleteUser godoc
Expand Down
10 changes: 4 additions & 6 deletions internal/repository/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ var (
)

type JobRepository struct {
DB *sqlx.DB
driver string

stmtCache *sq.StmtCache
cache *lrucache.Cache

DB *sqlx.DB
stmtCache *sq.StmtCache
cache *lrucache.Cache
archiveChannel chan *schema.Job
driver string
archivePending sync.WaitGroup
}

Expand Down

0 comments on commit e45ecbd

Please sign in to comment.