This is an automated email from the ASF dual-hosted git repository.

zrhoffman 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 348bc02975 Fix hc nil panic on blank parent.config lines (#6994)
348bc02975 is described below

commit 348bc029755a80aeac019fe996c66578bccad594
Author: Robert O Butts <[email protected]>
AuthorDate: Fri Jul 29 12:23:32 2022 -0600

    Fix hc nil panic on blank parent.config lines (#6994)
---
 CHANGELOG.md                                          | 1 +
 tc-health-client/tmagent/test_files/etc/parent.config | 1 +
 tc-health-client/tmagent/tmagent.go                   | 4 ++++
 3 files changed, 6 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8fec71c9e5..efff8be2bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -68,6 +68,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#6834](https://github.com/apache/trafficcontrol/issues/6834) - In API 4.0, 
fixed `GET` for `/servers` to display all profiles irrespective of the index 
position. Also, replaced query param `profileId` with `profileName`.
 - [#6299](https://github.com/apache/trafficcontrol/issues/6299) User 
representations don't match
 - [#6896](https://github.com/apache/trafficcontrol/issues/6896) Fixed the 
`POST api/cachegroups/id/queue_updates` endpoint so that it doesn't give an 
internal server error anymore.
+- [#6994](https://github.com/apache/trafficcontrol/issues/6994) Fixed the 
Health Client to not crash if parent.config has a blank line.
 - [#6933](https://github.com/apache/trafficcontrol/issues/6933) Fixed 
tc-health-client to handle credentials files with special characters in 
variables
 - [#6776](https://github.com/apache/trafficcontrol/issues/6776) User 
properties only required sometimes
 - Fixed TO API `GET /deliveryservicesserver` causing error when an IMS request 
is made with the `cdn` and `maxRevalDurationDays` parameters set.
diff --git a/tc-health-client/tmagent/test_files/etc/parent.config 
b/tc-health-client/tmagent/test_files/etc/parent.config
index b5b8bffe83..4f31ca63eb 100644
--- a/tc-health-client/tmagent/test_files/etc/parent.config
+++ b/tc-health-client/tmagent/test_files/etc/parent.config
@@ -17,5 +17,6 @@
 # under the License.
 #
 dest_domain=foo.com port=80 
parent="cdn-mid-01.bar.net:80|1.0;cdn-mid-02.bar.net:80|1.0;cdn-mid-03.bar.net:80|1.0;cdn-mid-04.bar.net:80|1.0;"
 round_robin=consistent_hash go_direct=false qstring=consider go_direct=true
+
 #
 dest_domain=foo.com port=80 
parent="cdn-mid-05.foo.net:80|1.0;cdn-mid-06.foo.net:80|1.0;cdn-mid-07.foo.net:80|1.0;cdn-mid-08.foo.net:80|1.0;"
 round_robin=consistent_hash go_direct=false qstring=ignore go_direct=false
diff --git a/tc-health-client/tmagent/tmagent.go 
b/tc-health-client/tmagent/tmagent.go
index 1783311eaf..a12d70a96d 100644
--- a/tc-health-client/tmagent/tmagent.go
+++ b/tc-health-client/tmagent/tmagent.go
@@ -744,6 +744,10 @@ func (c *ParentInfo) readParentConfig(parentStatus 
map[string]ParentStatus) erro
        scanner := bufio.NewScanner(f)
        for scanner.Scan() {
                sbytes := scanner.Bytes()
+               sbytes = bytes.TrimSpace(sbytes)
+               if len(sbytes) == 0 {
+                       continue // skip blank lines
+               }
                if sbytes[0] == 35 { // skip comment lines, 35 is a '#'.
                        continue
                }

Reply via email to