ocket8888 commented on code in PR #6544:
URL: https://github.com/apache/trafficcontrol/pull/6544#discussion_r841945751
##########
lib/go-atscfg/cachedotconfig.go:
##########
@@ -67,22 +67,24 @@ func makeCacheDotConfigEdge(
}
warnings := []string{}
- if server.Profile == nil {
- return Cfg{}, makeErr(warnings, "server missing profile")
+ if server.ProfileNames == nil && len(server.ProfileNames) == 0 {
+ return Cfg{}, makeErr(warnings, "server missing profiles")
}
profileServerIDsMap := map[int]struct{}{}
for _, sv := range servers {
- if sv.Profile == nil {
+ if sv.ProfileNames == nil && len(sv.ProfileNames) == 0 {
warnings = append(warnings, "servers had server with
nil profile, skipping!")
continue
}
if sv.ID == nil {
warnings = append(warnings, "servers had server with
nil id, skipping!")
continue
}
- if *sv.Profile != *server.Profile {
- continue
+ for i, _ := range server.ProfileNames {
+ if sv.ProfileNames[i] != server.ProfileNames[i] {
+ continue
+ }
Review Comment:
> This already is checked on line 70 and 76.
> Also, why is this required?
That's the length check I'm talking about. Lines 70 and 76 only make sure
the slice isn't empty. If `server.ProfileNames` has 3 entries and
`sv.ProfileNames` has 2, then checking `sv.ProfileNames[i] !=
server.ProfileNames[i]` will segfault when `i` is `2`. If `sv` has _more_
Profile names than `server`, this function would never notice that the two
arrays aren't the same unless you check their lengths against each other.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]