Simplify struct SessionInfo and adjoining code
This commit is contained in:
committed by
=Michael Hohn
parent
9d1a891c72
commit
0cffb3c849
7
Makefile
7
Makefile
@@ -1,6 +1,11 @@
|
|||||||
build:
|
all: server agent
|
||||||
|
|
||||||
|
server:
|
||||||
cd cmd/server && GOOS=linux GOARCH=arm64 go build
|
cd cmd/server && GOOS=linux GOARCH=arm64 go build
|
||||||
|
|
||||||
|
agent:
|
||||||
|
cd cmd/agent && GOOS=linux GOARCH=arm64 go build
|
||||||
|
|
||||||
fullbuild:
|
fullbuild:
|
||||||
cd cmd/server && GOOS=linux GOARCH=arm64 go build -a
|
cd cmd/server && GOOS=linux GOARCH=arm64 go build -a
|
||||||
|
|
||||||
|
|||||||
@@ -216,12 +216,18 @@ func (c *CommanderSingle) MRVAStatusCommon(w http.ResponseWriter, r *http.Reques
|
|||||||
}
|
}
|
||||||
|
|
||||||
jobs, err := c.v.State.GetJobList(int(sessionId))
|
jobs, err := c.v.State.GetJobList(int(sessionId))
|
||||||
if err != nil || len(jobs) == 0 {
|
if err != nil {
|
||||||
msg := "No jobs found for given session id"
|
msg := "No jobs found for given session id"
|
||||||
slog.Error(msg, "id", variantAnalysisID)
|
slog.Error(msg, "id", variantAnalysisID)
|
||||||
http.Error(w, msg, http.StatusNotFound)
|
http.Error(w, msg, http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(jobs) == 0 {
|
||||||
|
// TODO Empty joblist found; short-circuit the rest of this func
|
||||||
|
// c.submitStatusResponse(w, job.Spec, jobInfo)
|
||||||
|
slog.Error("TODO empty joblist found", "id", variantAnalysisID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// The status reports one status for all jobs belonging to an id.
|
// The status reports one status for all jobs belonging to an id.
|
||||||
// So we simply report the status of a job as the status of all.
|
// So we simply report the status of a job as the status of all.
|
||||||
@@ -452,28 +458,21 @@ func (c *CommanderSingle) MRVARequestCommon(w http.ResponseWriter, r *http.Reque
|
|||||||
|
|
||||||
notFoundRepos, analysisRepos := c.v.CodeQLDBStore.FindAvailableDBs(repoNWOs)
|
notFoundRepos, analysisRepos := c.v.CodeQLDBStore.FindAvailableDBs(repoNWOs)
|
||||||
|
|
||||||
if len(*analysisRepos) == 0 {
|
|
||||||
slog.Warn("No repositories found for analysis")
|
|
||||||
}
|
|
||||||
|
|
||||||
// XX: session_is is separate from the query pack ref. Value may be equal
|
|
||||||
c.startAnalyses(analysisRepos, queryPackLocation, sessionId, queryLanguage)
|
|
||||||
|
|
||||||
sessionInfo := SessionInfo{
|
sessionInfo := SessionInfo{
|
||||||
ID: sessionId,
|
// TODO verify: these fields are never used
|
||||||
Owner: "unused",
|
// Owner: "unused",
|
||||||
ControllerRepo: "unused",
|
// ControllerRepo: "unused",
|
||||||
|
// Repositories: repoNWOs,
|
||||||
|
// OverLimitRepos: nil, /* FIXME */
|
||||||
|
// AnalysisRepos: analysisRepos,
|
||||||
|
|
||||||
QueryPack: strconv.Itoa(sessionId), // TODO
|
ID: sessionId,
|
||||||
Language: queryLanguage,
|
QueryPack: strconv.Itoa(sessionId), // TODO
|
||||||
Repositories: repoNWOs,
|
Language: queryLanguage,
|
||||||
|
|
||||||
AccessMismatchRepos: nil, /* FIXME */
|
AccessMismatchRepos: nil, /* FIXME */
|
||||||
NotFoundRepos: notFoundRepos,
|
NotFoundRepos: notFoundRepos,
|
||||||
NoCodeqlDBRepos: nil, /* FIXME */
|
NoCodeqlDBRepos: nil, /* FIXME */
|
||||||
OverLimitRepos: nil, /* FIXME */
|
|
||||||
|
|
||||||
AnalysisRepos: analysisRepos,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slog.Debug("Forming and sending response for submitted analysis job", "id", sessionInfo.ID)
|
slog.Debug("Forming and sending response for submitted analysis job", "id", sessionInfo.ID)
|
||||||
@@ -483,9 +482,15 @@ func (c *CommanderSingle) MRVARequestCommon(w http.ResponseWriter, r *http.Reque
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(submitResponseJson)
|
w.Write(submitResponseJson)
|
||||||
|
|
||||||
|
// Start analysis only if repositories were found
|
||||||
|
if len(*analysisRepos) == 0 {
|
||||||
|
slog.Warn("No repositories found for analysis")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.startAnalyses(analysisRepos, queryPackLocation, sessionId, queryLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommanderSingle) MRVARequestID(w http.ResponseWriter, r *http.Request) {
|
func (c *CommanderSingle) MRVARequestID(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -9,17 +9,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SessionInfo struct {
|
type SessionInfo struct {
|
||||||
ID int
|
// TODO verify: these fields are never used
|
||||||
Owner string
|
// Owner string
|
||||||
ControllerRepo string
|
// ControllerRepo string
|
||||||
QueryPack string
|
// Repositories []common.NameWithOwner
|
||||||
Language string
|
// OverLimitRepos []common.NameWithOwner
|
||||||
Repositories []common.NameWithOwner
|
// AnalysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation
|
||||||
|
|
||||||
|
ID int
|
||||||
|
QueryPack string
|
||||||
|
Language string
|
||||||
|
|
||||||
AccessMismatchRepos []common.NameWithOwner
|
AccessMismatchRepos []common.NameWithOwner
|
||||||
NotFoundRepos []common.NameWithOwner
|
NotFoundRepos []common.NameWithOwner
|
||||||
NoCodeqlDBRepos []common.NameWithOwner
|
NoCodeqlDBRepos []common.NameWithOwner
|
||||||
OverLimitRepos []common.NameWithOwner
|
|
||||||
AnalysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommanderSingle struct {
|
type CommanderSingle struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user