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