This is an automated email from the ASF dual-hosted git repository.
srijeet0406 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 9ef23d41fc updated cert expirations to only show Active DSes (#6757)
9ef23d41fc is described below
commit 9ef23d41fc97c7b8867afaa17a21287439b06f4d
Author: mattjackson220 <[email protected]>
AuthorDate: Fri Apr 22 13:18:55 2022 -0600
updated cert expirations to only show Active DSes (#6757)
* updated cert expirations to only show Active DSes
* update per comments
* updated per comment
---
.../trafficvault/backends/postgres/postgres.go | 28 ++++++++++++++++------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git
a/traffic_ops/traffic_ops_golang/trafficvault/backends/postgres/postgres.go
b/traffic_ops/traffic_ops_golang/trafficvault/backends/postgres/postgres.go
index b03b48d77d..f537a8ad55 100644
--- a/traffic_ops/traffic_ops_golang/trafficvault/backends/postgres/postgres.go
+++ b/traffic_ops/traffic_ops_golang/trafficvault/backends/postgres/postgres.go
@@ -165,7 +165,7 @@ func (p *Postgres) GetExpirationInformation(tx *sql.Tx, ctx
context.Context, day
}
defer p.commitTransaction(tvTx, dbCtx, cancelFunc)
- var fedList []string
+ fedMap := map[string]bool{}
fedRows, err := tx.Query("SELECT DISTINCT(ds.xml_id) FROM
federation_deliveryservice AS fd JOIN deliveryservice AS ds ON ds.id =
fd.deliveryservice")
if err != nil {
return []tc.SSLKeyExpirationInformation{}, err
@@ -177,7 +177,23 @@ func (p *Postgres) GetExpirationInformation(tx *sql.Tx,
ctx context.Context, day
if err = fedRows.Scan(&fedString); err != nil {
return []tc.SSLKeyExpirationInformation{}, err
}
- fedList = append(fedList, fedString)
+ fedMap[fedString] = true
+ }
+
+ inactiveQuery := "SELECT xml_id FROM deliveryservice WHERE NOT active"
+ iaRows, err := tx.Query(inactiveQuery)
+ if err != nil {
+ return []tc.SSLKeyExpirationInformation{}, err
+ }
+ defer iaRows.Close()
+
+ inactiveList := map[string]bool{}
+ for iaRows.Next() {
+ var inactiveXmlId string
+ if err = iaRows.Scan(&inactiveXmlId); err != nil {
+ return []tc.SSLKeyExpirationInformation{}, err
+ }
+ inactiveList[inactiveXmlId] = true
}
query := "SELECT deliveryservice, cdn, provider, expiration FROM sslkey
WHERE version='latest'"
@@ -199,12 +215,10 @@ func (p *Postgres) GetExpirationInformation(tx *sql.Tx,
ctx context.Context, day
if err = rows.Scan(&expirationInfo.DeliveryService,
&expirationInfo.CDN, &expirationInfo.Provider, &expirationInfo.Expiration); err
!= nil {
return []tc.SSLKeyExpirationInformation{}, err
}
- expirationInfo.Federated = false
- for _, fed := range fedList {
- if fed == expirationInfo.DeliveryService {
- expirationInfo.Federated = true
- }
+ if inactiveList[expirationInfo.DeliveryService] {
+ continue
}
+ expirationInfo.Federated =
fedMap[expirationInfo.DeliveryService]
expirationInfos = append(expirationInfos, expirationInfo)
}