diff --git a/Makefile b/Makefile index f3a46ec..507d335 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ -build: +all: server agent + +server: cd cmd/server && GOOS=linux GOARCH=arm64 go build +agent: + cd cmd/agent && GOOS=linux GOARCH=arm64 go build + fullbuild: cd cmd/server && GOOS=linux GOARCH=arm64 go build -a diff --git a/pkg/server/server.go b/pkg/server/server.go index 64f8b49..b6751b6 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -216,12 +216,18 @@ func (c *CommanderSingle) MRVAStatusCommon(w http.ResponseWriter, r *http.Reques } 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" slog.Error(msg, "id", variantAnalysisID) http.Error(w, msg, http.StatusNotFound) 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. // 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) - 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{ - ID: sessionId, - Owner: "unused", - ControllerRepo: "unused", + // TODO verify: these fields are never used + // Owner: "unused", + // ControllerRepo: "unused", + // Repositories: repoNWOs, + // OverLimitRepos: nil, /* FIXME */ + // AnalysisRepos: analysisRepos, - QueryPack: strconv.Itoa(sessionId), // TODO - Language: queryLanguage, - Repositories: repoNWOs, + ID: sessionId, + QueryPack: strconv.Itoa(sessionId), // TODO + Language: queryLanguage, AccessMismatchRepos: nil, /* FIXME */ NotFoundRepos: notFoundRepos, NoCodeqlDBRepos: nil, /* FIXME */ - OverLimitRepos: nil, /* FIXME */ - - AnalysisRepos: analysisRepos, } 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) return } - w.Header().Set("Content-Type", "application/json") 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) { diff --git a/pkg/server/types.go b/pkg/server/types.go index 854b889..c989f3c 100644 --- a/pkg/server/types.go +++ b/pkg/server/types.go @@ -9,17 +9,20 @@ import ( ) type SessionInfo struct { - ID int - Owner string - ControllerRepo string - QueryPack string - Language string - Repositories []common.NameWithOwner + // TODO verify: these fields are never used + // Owner string + // ControllerRepo string + // Repositories []common.NameWithOwner + // OverLimitRepos []common.NameWithOwner + // AnalysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation + + ID int + QueryPack string + Language string + AccessMismatchRepos []common.NameWithOwner NotFoundRepos []common.NameWithOwner NoCodeqlDBRepos []common.NameWithOwner - OverLimitRepos []common.NameWithOwner - AnalysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation } type CommanderSingle struct {