traeak commented on code in PR #6859:
URL: https://github.com/apache/trafficcontrol/pull/6859#discussion_r922298134


##########
lib/go-atscfg/parentdotconfig.go:
##########
@@ -802,32 +837,100 @@ type originURI struct {
 const deliveryServicesAllParentsKey = "all_parents"
 
 type parentDSParams struct {
-       Algorithm                       ParentAbstractionServiceRetryPolicy
+       Algorithm           ParentAbstractionServiceRetryPolicy
+       QueryStringHandling string
+
+       HasRetryParams                  bool
        ParentRetry                     string
-       UnavailableServerRetryResponses string
        MaxSimpleRetries                string
        MaxUnavailableServerRetries     string
-       QueryStringHandling             string
+       SimpleServerRetryResponses      string
+       UnavailableServerRetryResponses string
        TryAllPrimariesBeforeSecondary  bool
-       UsePeering                      bool
-       MergeGroups                     []string
+
+       UsePeering  bool
+       MergeGroups []string
+}
+
+func (dsp *parentDSParams) FillParentRetries(keys ParentConfigRetryKeys, 
dsParams map[string]string, dsid string) (bool, []string) {
+       var warnings []string
+       hasValues := false
+
+       if v, ok := dsParams[keys.Algorithm]; ok && strings.TrimSpace(v) != "" {
+               policy := 
ParentSelectAlgorithmToParentAbstractionServiceRetryPolicy(v)
+               if policy != ParentAbstractionServiceRetryPolicyInvalid {
+                       dsp.Algorithm = policy
+                       hasValues = true
+               } else {
+                       warnings = append(warnings, "DS '"+dsid+"' had 
malformed "+keys.Algorithm+" parameter '"+v+"', not using!")
+               }
+       }
+
+       if v, ok := dsParams[keys.ParentRetry]; ok {
+               dsp.ParentRetry = v
+               hasValues = true
+       }
+
+       if v, ok := dsParams[keys.MaxSimpleRetries]; ok {
+               dsp.MaxSimpleRetries = v
+               hasValues = true
+       }
+       if v, ok := dsParams[keys.MaxUnavailableRetries]; ok {
+               dsp.MaxUnavailableServerRetries = v
+               hasValues = true
+       }
+
+       if v, ok := dsParams[keys.SimpleRetryResponses]; ok {
+               if unavailableServerRetryResponsesValid(v) {
+                       dsp.SimpleServerRetryResponses = v
+                       hasValues = true
+               } else {
+                       warnings = append(warnings, "DS '"+dsid+"' had 
malformed "+keys.SimpleRetryResponses+" parameter '"+v+"', not using!")
+               }
+       }
+
+       if v, ok := dsParams[keys.UnavailableRetryResponses]; ok {
+               if unavailableServerRetryResponsesValid(v) {
+                       dsp.UnavailableServerRetryResponses = v
+                       hasValues = true
+               } else {
+                       warnings = append(warnings, "DS '"+dsid+"' had 
malformed "+keys.UnavailableRetryResponses+" parameter '"+v+"', not using!")
+               }
+       }
+
+       // Unfortunately this may be s
+       if v, ok := dsParams[keys.SecondaryMode]; ok {
+               if v == "false" {
+                       dsp.TryAllPrimariesBeforeSecondary = false
+               } else {
+                       dsp.TryAllPrimariesBeforeSecondary = true
+                       if v != "" {
+                               warnings = append(warnings, "DS '"+dsid+"' had 
Parameter "+keys.SecondaryMode+" which is used if it exists, the value is 
ignored (unless false) ! Non-empty value '"+v+"' will be ignored!")
+                       }
+               }
+       }
+
+       return hasValues, warnings
 }
 
 // getDSParams returns the Delivery Service Profile Parameters used in 
parent.config, and any warnings.
 // If Parameters don't exist, defaults are returned. Non-MSO Delivery Services 
default to no custom retry logic (we should reevaluate that).
 // Note these Parameters are only used for MSO for legacy 
DeliveryServiceServers DeliveryServices.
 //      Topology DSes use them for all DSes, MSO and non-MSO.
-func getParentDSParams(ds DeliveryService, profileParentConfigParams 
map[string]map[string]string) (parentDSParams, []string) {
+func getParentDSParams(ds DeliveryService, profileParentConfigParams 
map[string]map[string]string, serverPlacement TopologyPlacement, isMSO bool) 
(parentDSParams, []string) {
        warnings := []string{}
        params := parentDSParams{}
-       isMSO := ds.MultiSiteOrigin != nil && *ds.MultiSiteOrigin
-       if isMSO {
+
+       // Default values
+       if serverPlacement.IsLastCacheTier && isMSO {
                params.Algorithm = ParentConfigDSParamDefaultMSOAlgorithm
                params.ParentRetry = ParentConfigDSParamDefaultMSOParentRetry
                params.UnavailableServerRetryResponses = 
ParentConfigDSParamDefaultMSOUnavailableServerRetryResponses
                params.MaxSimpleRetries = 
strconv.Itoa(ParentConfigDSParamDefaultMaxSimpleRetries)
                params.MaxUnavailableServerRetries = 
strconv.Itoa(ParentConfigDSParamDefaultMaxUnavailableServerRetries)
+               params.HasRetryParams = true

Review Comment:
   Not faking.  If there are no overridden parameters then the defaults are 
taken which means no parameters are specified on the parent.config line.  
Before this PR args aren't allowed for first and inner, now they must be 
checked.



-- 
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]

Reply via email to