fix: reconciled status names between server/agent/vscode-codeql
This commit is contained in:
committed by
=Michael Hohn
parent
f066c767e2
commit
2409728960
@@ -4,17 +4,18 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hohn/mrvacommander/pkg/artifactstore"
|
||||
"github.com/hohn/mrvacommander/pkg/codeql"
|
||||
"github.com/hohn/mrvacommander/pkg/common"
|
||||
"github.com/hohn/mrvacommander/pkg/qldbstore"
|
||||
"github.com/hohn/mrvacommander/pkg/queue"
|
||||
"github.com/hohn/mrvacommander/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/elastic/go-sysinfo"
|
||||
"github.com/google/uuid"
|
||||
@@ -153,7 +154,7 @@ func RunAnalysisJob(
|
||||
Spec: job.Spec,
|
||||
ResultCount: 0,
|
||||
ResultLocation: artifactstore.ArtifactLocation{},
|
||||
Status: common.StatusError,
|
||||
Status: common.StatusFailed,
|
||||
}
|
||||
|
||||
// Create a temporary directory
|
||||
@@ -218,7 +219,7 @@ func RunAnalysisJob(
|
||||
Spec: job.Spec,
|
||||
ResultCount: runResult.ResultCount,
|
||||
ResultLocation: resultsLocation,
|
||||
Status: common.StatusSuccess,
|
||||
Status: common.StatusSucceeded,
|
||||
SourceLocationPrefix: runResult.SourceLocationPrefix,
|
||||
DatabaseSHA: runResult.DatabaseSHA,
|
||||
}
|
||||
|
||||
@@ -10,25 +10,28 @@ type NameWithOwner struct {
|
||||
type Status int
|
||||
|
||||
const (
|
||||
StatusInProgress = iota
|
||||
StatusQueued
|
||||
StatusError
|
||||
StatusSuccess
|
||||
StatusPending Status = iota
|
||||
StatusInProgress
|
||||
StatusSucceeded
|
||||
StatusFailed
|
||||
StatusCanceled
|
||||
StatusTimedOut
|
||||
)
|
||||
|
||||
func (s Status) ToExternalString() string {
|
||||
switch s {
|
||||
case StatusPending:
|
||||
return "pending"
|
||||
case StatusInProgress:
|
||||
return "in_progress"
|
||||
case StatusQueued:
|
||||
return "queued"
|
||||
case StatusError:
|
||||
return "error"
|
||||
case StatusSuccess:
|
||||
return "inProgress"
|
||||
case StatusSucceeded:
|
||||
return "succeeded"
|
||||
case StatusFailed:
|
||||
return "failed"
|
||||
case StatusCanceled:
|
||||
return "canceled"
|
||||
case StatusTimedOut:
|
||||
return "timedOut"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (c *CommanderSingle) startAnalyses(
|
||||
QueryLanguage: queryLanguage,
|
||||
}
|
||||
c.v.Queue.Jobs() <- info
|
||||
c.v.State.SetStatus(jobSpec, common.StatusQueued)
|
||||
c.v.State.SetStatus(jobSpec, common.StatusPending)
|
||||
c.v.State.AddJob(info)
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func (c *CommanderSingle) submitEmptyStatusResponse(w http.ResponseWriter,
|
||||
scannedRepos := []common.ScannedRepo{}
|
||||
|
||||
var jobStatus common.Status
|
||||
jobStatus = common.StatusSuccess
|
||||
jobStatus = common.StatusSucceeded
|
||||
|
||||
status := common.StatusResponse{
|
||||
SessionId: jsSessionID,
|
||||
@@ -191,7 +191,7 @@ func (c *CommanderSingle) submitStatusResponse(w http.ResponseWriter, js common.
|
||||
var artifactSize int
|
||||
var resultCount int
|
||||
|
||||
if status != common.StatusSuccess {
|
||||
if status != common.StatusSucceeded {
|
||||
// If the job is not successful, we don't need to get the result
|
||||
artifactSize = 0
|
||||
resultCount = 0
|
||||
@@ -436,7 +436,7 @@ func (c *CommanderSingle) sendArtifactDownloadResponse(w http.ResponseWriter, jo
|
||||
return
|
||||
}
|
||||
|
||||
if jobStatus == common.StatusSuccess {
|
||||
if jobStatus == common.StatusSucceeded {
|
||||
jobResult, err := c.v.State.GetResult(jobSpec)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
|
||||
@@ -3,9 +3,10 @@ package state
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"sync"
|
||||
|
||||
"github.com/hohn/mrvacommander/pkg/common"
|
||||
"github.com/hohn/mrvacommander/pkg/queue"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type LocalState struct {
|
||||
@@ -97,7 +98,7 @@ func (s *LocalState) GetStatus(js common.JobSpec) (common.Status, error) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
if _, ok := s.status[js]; !ok {
|
||||
return common.StatusError, fmt.Errorf("status not found for job spec %v", js)
|
||||
return common.StatusFailed, fmt.Errorf("status not found for job spec %v", js)
|
||||
}
|
||||
return s.status[js], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user