ocket8888 commented on a change in pull request #5544:
URL: https://github.com/apache/trafficcontrol/pull/5544#discussion_r578801498



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/autorenewcerts.go
##########
@@ -216,17 +267,35 @@ func RunAutorenewal(existingCerts []ExistingCerts, cfg 
*config.Config, ctx conte
                        } else {
                                userErr, sysErr, statusCode := 
renewAcmeCerts(cfg, keyObj.DeliveryService, ctx, currentUser)
                                if userErr != nil {
+                                       errorCount++
                                        dsExpInfo.Error = userErr
                                } else if sysErr != nil {
+                                       errorCount++
                                        dsExpInfo.Error = sysErr
                                } else if statusCode != http.StatusOK {
+                                       errorCount++
                                        dsExpInfo.Error = errors.New("Status 
code not 200: " + strconv.Itoa(statusCode))
+                               } else {
+                                       renewedCount++
                                }
                                keysFound.AcmeExpirations = 
append(keysFound.AcmeExpirations, dsExpInfo)
                        }
 
                }
 
+               if err = api.UpdateAsyncStatus(db, api.AsyncPending, "ACME 
renewal in progress. "+strconv.Itoa(renewedCount)+" certs renewed, 
"+strconv.Itoa(errorCount)+" errors.", asyncStatusId, false); err != nil {
+                       log.Errorf("updating async status for id %v: %v", 
asyncStatusId, err.Error())
+               }
+
+       }
+
+       // put status as succeeded if any certs were successfully renewed
+       asyncStatus := api.AsyncSucceeded
+       if errorCount > 0 && renewedCount == 0 {
+               asyncStatus = api.AsyncFailed
+       }
+       if err = api.UpdateAsyncStatus(db, asyncStatus, "ACME renewal complete. 
"+strconv.Itoa(renewedCount)+" certs renewed, "+strconv.Itoa(errorCount)+" 
errors.", asyncStatusId, true); err != nil {
+               log.Errorf("updating async status for id %v: %v", 
asyncStatusId, err.Error())

Review comment:
       you don't need to change this, but just so you're aware, the `%v` will 
call `.Error()` for you, so you don't need to do it in the argument list.




----------------------------------------------------------------
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:
[email protected]


Reply via email to