mirror: add more logging

This commit is contained in:
Lorenzo Bolla
2021-05-05 20:44:57 +02:00
parent 79a7cf864e
commit 5a65ce6adb

View File

@@ -2,6 +2,7 @@ package api
import (
"fmt"
"log"
"sort"
"strings"
"sync"
@@ -310,6 +311,8 @@ func apiMirrorsUpdate(c *gin.Context) {
b.Architectures = remote.Architectures
b.Components = remote.Components
log.Printf("%s: Starting mirror update\n", b.Name)
if c.Bind(&b) != nil {
return
}
@@ -457,6 +460,7 @@ func apiMirrorsUpdate(c *gin.Context) {
}
}()
log.Printf("%s: Spawning background processes...\n", b.Name)
var wg sync.WaitGroup
for i := 0; i < context.Config().DownloadConcurrency; i++ {
wg.Add(1)
@@ -503,7 +507,9 @@ func apiMirrorsUpdate(c *gin.Context) {
}
// Wait for all download goroutines to finish
log.Printf("%s: Waiting for background processes to finish...\n", b.Name)
wg.Wait()
log.Printf("%s: Background processes finished\n", b.Name)
close(taskFinished)
for idx := range queue {
@@ -535,15 +541,18 @@ func apiMirrorsUpdate(c *gin.Context) {
}
if len(errors) > 0 {
log.Printf("%s: Unable to update because of previous errors\n", b.Name)
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
}
log.Printf("%s: Finalizing download\n", b.Name)
remote.FinalizeDownload(collectionFactory, out)
err = collectionFactory.RemoteRepoCollection().Update(remote)
if err != nil {
return fmt.Errorf("unable to update: %s", err)
}
log.Printf("%s: Mirror updated successfully!\n", b.Name)
return nil
})