This is an automated email from the ASF dual-hosted git repository. zrhoffman pushed a commit to branch 6.0.x in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 2c33c29b42e06aa869a0b0009d2c7d18d74456b2 Author: Rawlin Peters <[email protected]> AuthorDate: Mon Oct 18 13:44:42 2021 -0600 Reduce DNSSEC refresh change log noise (#6279) Only create a changelog entry if any keys actually changed or an error occurred. Also, differentiate between errors storing into Traffic Vault and other types of errors. Closes: #6268 --- CHANGELOG.md | 1 + traffic_ops/traffic_ops_golang/cdn/dnssecrefresh.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61632ed..0d8ef08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Changed - [#5927](https://github.com/apache/trafficcontrol/issues/5927) Updated CDN-in-a-Box to not run a Riak container by default but instead only run it if the optional flag is provided. +- Changed the DNSSEC refresh Traffic Ops API to only create a new change log entry if any keys were actually refreshed or an error occurred (in order to reduce changelog noise) ## [6.0.0] - 2021-08-30 ### Added diff --git a/traffic_ops/traffic_ops_golang/cdn/dnssecrefresh.go b/traffic_ops/traffic_ops_golang/cdn/dnssecrefresh.go index 015fc1a..4db4e24 100644 --- a/traffic_ops/traffic_ops_golang/cdn/dnssecrefresh.go +++ b/traffic_ops/traffic_ops_golang/cdn/dnssecrefresh.go @@ -185,6 +185,7 @@ func doDNSSECKeyRefresh(tx *sql.Tx, asyncDB *sqlx.DB, tv trafficvault.TrafficVau errCount := 0 updateCount := 0 + putErr := false for _, cdnInf := range cdnDNSSECKeyParams { keys, ok, err := tv.GetDNSSECKeys(string(cdnInf.CDNName), tx, context.Background()) // TODO get all in a map beforehand if err != nil { @@ -327,19 +328,25 @@ func doDNSSECKeyRefresh(tx *sql.Tx, asyncDB *sqlx.DB, tv trafficvault.TrafficVau if updateCount > 0 { if err := tv.PutDNSSECKeys(string(cdnInf.CDNName), keys, tx, context.Background()); err != nil { log.Errorln("refreshing DNSSEC Keys: putting keys into Traffic Vault for cdn '" + string(cdnInf.CDNName) + "': " + err.Error()) - errCount++ + putErr = true } } } clMsg := fmt.Sprintf("Refreshed %d DNSSEC keys", updateCount) status := api.AsyncSucceeded msg := fmt.Sprintf("DNSSEC refresh completed successfully (%d keys were updated)", updateCount) - if errCount > 0 { + if putErr { + status = api.AsyncFailed + msg = fmt.Sprintf("DNSSEC refresh failed (attempted to update %d keys, but an error occurred while attempting to store in Traffic Vault)", updateCount) + clMsg = fmt.Sprintf("Attempted to refresh %d DNSSEC keys, but an error occurred while attempting to store in Traffic Vault", updateCount) + } else if errCount > 0 { status = api.AsyncFailed - msg = fmt.Sprintf("DNSSEC refresh failed (%d keys were updated, but %d errors occurred)", updateCount, errCount) + msg = fmt.Sprintf("DNSSEC refresh failed (updated %d keys, but %d errors occurred)", updateCount, errCount) clMsg = fmt.Sprintf("Refreshed %d DNSSEC keys, but %d errors occurred", updateCount, errCount) } - api.CreateChangeLogRawTx(api.ApiChange, clMsg, user, tx) + if updateCount > 0 || errCount > 0 || putErr { + api.CreateChangeLogRawTx(api.ApiChange, clMsg, user, tx) + } if asyncErr := api.UpdateAsyncStatus(asyncDB, status, msg, jobID, true); asyncErr != nil { log.Errorf("updating async status for id %d: %v", jobID, asyncErr) }
