dg4prez closed pull request #2157: Added json response field use_reval_pending
to update_status endpoint. Fixes #1595
URL: https://github.com/apache/incubator-trafficcontrol/pull/2157
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/lib/go-tc/servers.go b/lib/go-tc/servers.go
index 7c58206b6..7d2e5d5a3 100644
--- a/lib/go-tc/servers.go
+++ b/lib/go-tc/servers.go
@@ -132,6 +132,7 @@ type ServerUpdateStatus struct {
HostName string `json:"host_name"`
UpdatePending bool `json:"upd_pending"`
RevalPending bool `json:"reval_pending"`
+ UseRevalPending bool `json:"use_reval_pending"`
HostId int `json:"host_id"`
Status string `json:"status"`
ParentPending bool `json:"parent_pending"`
diff --git a/traffic_ops/traffic_ops_golang/server/servers_update_status.go
b/traffic_ops/traffic_ops_golang/server/servers_update_status.go
index 80e00ff43..da2e49d08 100644
--- a/traffic_ops/traffic_ops_golang/server/servers_update_status.go
+++ b/traffic_ops/traffic_ops_golang/server/servers_update_status.go
@@ -64,14 +64,14 @@ func getServerUpdateStatus(hostName string, db *sqlx.DB)
([]tc.ServerUpdateStatu
`WITH parentservers AS (SELECT ps.id, ps.cachegroup, ps.cdn_id,
ps.upd_pending, ps.reval_pending FROM server ps
LEFT JOIN status AS pstatus ON pstatus.id = ps.status
WHERE pstatus.name != 'OFFLINE' ),
- use_reval AS (SELECT value::boolean FROM parameter WHERE name =
'use_reval_pending' AND config_file = 'global' UNION ALL SELECT FALSE FETCH
FIRST 1 ROW ONLY)
- SELECT s.id, s.host_name, type.name AS type,
(s.reval_pending::boolean AND use_reval.value) as combined_reval_pending,
s.upd_pending, status.name AS status, COALESCE(bool_or(ps.upd_pending), FALSE)
AS parent_upd_pending, COALESCE(bool_or(ps.reval_pending), FALSE) AS
parent_reval_pending FROM use_reval, server s
+ use_reval_pending AS (SELECT value::boolean FROM parameter WHERE name
= 'use_reval_pending' AND config_file = 'global' UNION ALL SELECT FALSE FETCH
FIRST 1 ROW ONLY)
+ SELECT s.id, s.host_name, type.name AS type,
(s.reval_pending::boolean) as server_reval_pending, use_reval_pending.value,
s.upd_pending, status.name AS status, COALESCE(bool_or(ps.upd_pending), FALSE)
AS parent_upd_pending, COALESCE(bool_or(ps.reval_pending), FALSE) AS
parent_reval_pending FROM use_reval_pending, server s
LEFT JOIN status ON s.status = status.id
LEFT JOIN cachegroup cg ON s.cachegroup = cg.id
LEFT JOIN type ON type.id = s.type
LEFT JOIN parentservers ps ON ps.cachegroup = cg.parent_cachegroup_id
AND ps.cdn_id = s.cdn_id AND type.name = 'EDGE'` //remove the EDGE reference if
other server types should have their parents processed
- groupBy := ` GROUP BY s.id, s.host_name, type.name,
combined_reval_pending, s.upd_pending, status.name ORDER BY s.id;`
+ groupBy := ` GROUP BY s.id, s.host_name, type.name,
server_reval_pending, use_reval_pending.value, s.upd_pending, status.name ORDER
BY s.id;`
updateStatuses := []tc.ServerUpdateStatus{}
var rows *sql.Rows
@@ -94,7 +94,7 @@ func getServerUpdateStatus(hostName string, db *sqlx.DB)
([]tc.ServerUpdateStatu
for rows.Next() {
var serverUpdateStatus tc.ServerUpdateStatus
var serverType string
- if err := rows.Scan(&serverUpdateStatus.HostId,
&serverUpdateStatus.HostName, &serverType, &serverUpdateStatus.RevalPending,
&serverUpdateStatus.UpdatePending, &serverUpdateStatus.Status,
&serverUpdateStatus.ParentPending, &serverUpdateStatus.ParentRevalPending); err
!= nil {
+ if err := rows.Scan(&serverUpdateStatus.HostId,
&serverUpdateStatus.HostName, &serverType, &serverUpdateStatus.RevalPending,
&serverUpdateStatus.UseRevalPending, &serverUpdateStatus.UpdatePending,
&serverUpdateStatus.Status, &serverUpdateStatus.ParentPending,
&serverUpdateStatus.ParentRevalPending); err != nil {
log.Error.Printf("could not scan server update status:
%s\n", err)
return nil, tc.DBError
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services