From e10da788420c9339e0afe6b48966cdb623c23198 Mon Sep 17 00:00:00 2001 From: Forrest Babcock Date: Mon, 28 Oct 2024 18:47:27 -0400 Subject: [PATCH 1/2] NO-JIRA: debug jiraloader component --- pkg/dataloader/jiraloader/jiraloader.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/dataloader/jiraloader/jiraloader.go b/pkg/dataloader/jiraloader/jiraloader.go index d5d8af07c..42c3ab71a 100644 --- a/pkg/dataloader/jiraloader/jiraloader.go +++ b/pkg/dataloader/jiraloader/jiraloader.go @@ -128,6 +128,7 @@ func (jl *JiraLoader) componentLoader() { var components []v1jira.Component err = json.Unmarshal(body, &components) if err != nil { + log.Infof("JIRA Component Request Body Length: %d\n\n%s\n\n", len(body), body) jl.errors = append(jl.errors, err) return } From a5b9bb26385d5f207659248dfc4697d2845c2e9a Mon Sep 17 00:00:00 2001 From: Forrest Babcock Date: Mon, 28 Oct 2024 19:29:28 -0400 Subject: [PATCH 2/2] NO-JIRA: debug jiraloader component --- pkg/api/pull_requests.go | 5 +++++ pkg/db/query/payload_queries.go | 15 +++++++++++++++ pkg/sippyserver/server.go | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/pkg/api/pull_requests.go b/pkg/api/pull_requests.go index 9e2ba1094..3b9cb07b9 100644 --- a/pkg/api/pull_requests.go +++ b/pkg/api/pull_requests.go @@ -3,6 +3,7 @@ package api import ( apitype "github.com/openshift/sippy/pkg/apis/api" "github.com/openshift/sippy/pkg/db" + "github.com/openshift/sippy/pkg/db/models" "github.com/openshift/sippy/pkg/db/query" "github.com/openshift/sippy/pkg/filter" ) @@ -10,3 +11,7 @@ import ( func GetPullRequestsReportFromDB(dbc *db.DB, release string, filterOpts *filter.FilterOptions) ([]apitype.PullRequest, error) { return query.PullRequestReport(dbc, filterOpts, release) } + +func GetPayloadDiffPullRequests(dbc *db.DB, fromPayload, toPayload string) ([]models.ReleasePullRequest, error) { + return query.GetPayloadDiff(dbc.DB, fromPayload, toPayload) +} diff --git a/pkg/db/query/payload_queries.go b/pkg/db/query/payload_queries.go index 2b02b47ae..1ec5bdae9 100644 --- a/pkg/db/query/payload_queries.go +++ b/pkg/db/query/payload_queries.go @@ -1,6 +1,7 @@ package query import ( + "fmt" "time" "gorm.io/gorm" @@ -8,6 +9,20 @@ import ( "github.com/openshift/sippy/pkg/db/models" ) +func GetPayloadDiff(db *gorm.DB, fromPayload, toPayload string) ([]models.ReleasePullRequest, error) { + results := make([]models.ReleasePullRequest, 0) + query := fmt.Sprintf(`SELECT url,pull_request_id,name,description,bug_url FROM release_pull_requests + WHERE id IN ( SELECT release_pull_request_id FROM release_tag_pull_requests WHERE release_tag_id IN (SELECT id FROM release_tags WHERE release_tag ='%s')) + AND id NOT IN ( SELECT release_pull_request_id FROM release_tag_pull_requests WHERE release_tag_id IN (SELECT id FROM release_tags WHERE release_tag ='%s')) ORDER BY url`, toPayload, fromPayload) + result := db.Raw(query).Scan(&results) + + if result.Error != nil { + return nil, result.Error + } + + return results, nil +} + // GetLastAcceptedByArchitectureAndStream returns the last accepted payload for each architecture/stream combo. func GetLastAcceptedByArchitectureAndStream(db *gorm.DB, release string, reportEnd time.Time) ([]models.ReleaseTag, error) { results := make([]models.ReleaseTag, 0) diff --git a/pkg/sippyserver/server.go b/pkg/sippyserver/server.go index 2f5d85072..f84d8e896 100644 --- a/pkg/sippyserver/server.go +++ b/pkg/sippyserver/server.go @@ -471,6 +471,23 @@ func (s *Server) jsonReleaseHealthReport(w http.ResponseWriter, req *http.Reques api.RespondWithJSON(http.StatusOK, w, results) } +func (s *Server) jsonPayloadDiff(w http.ResponseWriter, req *http.Request) { + fromPayload := req.URL.Query().Get("fromPayload") + toPayload := req.URL.Query().Get("toPayload") + results, err := api.GetPayloadDiffPullRequests(s.db, fromPayload, toPayload) + + if err != nil { + log.WithError(err).Error("error generating payload diff") + api.RespondWithJSON(http.StatusInternalServerError, w, map[string]interface{}{ + "code": http.StatusInternalServerError, + "message": err.Error(), + }) + return + } + + api.RespondWithJSON(http.StatusOK, w, results) +} + func (s *Server) jsonTestAnalysis(w http.ResponseWriter, req *http.Request, dbFN func(*db.DB, *filter.Filter, string, string, time.Time) (map[string][]api.CountByDate, error)) { testName := req.URL.Query().Get("test") if testName == "" { @@ -1617,6 +1634,12 @@ func (s *Server) Serve() { Capabilities: []string{LocalDBCapability}, HandlerFunc: s.jsonGetPayloadTestFailures, }, + { + EndpointPath: "/api/payloads/diff", + Description: "Reports pull requests that differ between payloads", + Capabilities: []string{LocalDBCapability}, + HandlerFunc: s.jsonPayloadDiff, + }, } for _, ep := range endpoints {