You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/01/16 18:31:31 UTC
[GitHub] [trafficcontrol] rawlinp commented on a change in pull request
#4304: Fix atscfg not adding hdr_rw_mid files to meta cfg
rawlinp commented on a change in pull request #4304: Fix atscfg not adding hdr_rw_mid files to meta cfg
URL: https://github.com/apache/trafficcontrol/pull/4304#discussion_r367556559
##########
File path: traffic_ops/ort/atstccfg/cfgfile/meta.go
##########
@@ -183,31 +183,58 @@ func GetConfigFileMeta(cfg config.TCCfg, serverNameOrID string) (string, error)
return "", errors.New("getting delivery services: " + err.Error())
}
- dsIDs := []int{}
- for _, ds := range deliveryServices {
- if ds.ID == nil {
- // TODO log error?
- continue
+ dsNames := map[tc.DeliveryServiceName]struct{}{}
+ if tc.CacheTypeFromString(server.Type) != tc.CacheTypeMid {
+ dsIDs := []int{}
+ for _, ds := range deliveryServices {
+ if ds.ID == nil {
+ // TODO log error?
+ continue
+ }
+ dsIDs = append(dsIDs, *ds.ID)
}
- dsIDs = append(dsIDs, *ds.ID)
- }
- serverIDs := []int{server.ID}
+ serverIDs := []int{server.ID}
- dsServers, err := toreq.GetDeliveryServiceServers(cfg, dsIDs, serverIDs)
- if err != nil {
- return "", errors.New("getting meta config delivery service servers: " + err.Error())
- }
+ dsServers, err := toreq.GetDeliveryServiceServers(cfg, dsIDs, serverIDs)
+ if err != nil {
+ return "", errors.New("getting meta config delivery service servers: " + err.Error())
+ }
- dssMap := map[int]struct{}{} // set of map[dsID]. We know we only asked for our own server, so we don't care about the servers returned.
- for _, dss := range dsServers {
- if dss.DeliveryService == nil {
- continue // TODO log?
+ dssMap := map[int]struct{}{} // set of map[dsID]. We know we only asked for our own server, so we don't care about the servers returned.
+ for _, dss := range dsServers {
+ if dss.DeliveryService == nil {
+ continue // TODO log?
+ }
+ dssMap[*dss.DeliveryService] = struct{}{}
+ }
+ for _, ds := range deliveryServices {
+ if ds.ID == nil {
+ continue
+ }
+ if ds.XMLID == nil {
+ continue // TODO log?
+ }
+ if _, ok := dssMap[*ds.ID]; !ok {
+ continue
+ }
+ dsNames[tc.DeliveryServiceName(*ds.XMLID)] = struct{}{}
+ }
+ } else {
Review comment:
nit: I think if-else code is generally easier to read when the shorter block comes first (i.e. inverting the logic to `if tc.CacheTypeFromString(server.Type) == tc.CacheTypeMid` and moving this block up).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services