Fix error handling, only retry twice
This commit is contained in:
parent
a29d7396ef
commit
e36124cab6
@ -30,7 +30,6 @@ func StartPackageQueueWorker(ctx context.Context) {
|
||||
needsBuild := false
|
||||
buildVersion := ""
|
||||
buildAttempt := 0
|
||||
errPreviously := false
|
||||
v.Packages.ForEach(func(k string, v domain.PackageInfo) bool {
|
||||
if v.Status == domain.Current {
|
||||
return true
|
||||
@ -39,25 +38,26 @@ func StartPackageQueueWorker(ctx context.Context) {
|
||||
if version == "" {
|
||||
version = v.Version
|
||||
}
|
||||
if v.LastBuildStatus == domain.Error {
|
||||
errPreviously = true
|
||||
buildAttempt = 1
|
||||
}
|
||||
if v.Status == domain.Missing {
|
||||
needsBuild = true
|
||||
buildVersion = version
|
||||
buildAttempt = v.BuildAttempts
|
||||
return false
|
||||
}
|
||||
if v.Status == domain.Stale {
|
||||
needsBuild = true
|
||||
buildVersion = version
|
||||
buildAttempt = v.BuildAttempts
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
if needsBuild {
|
||||
if buildAttempt > 1 {
|
||||
return true
|
||||
}
|
||||
typ := domain.BuildTypeLTO
|
||||
if errPreviously {
|
||||
if buildAttempt == 1 {
|
||||
typ = domain.BuildTypeNormal
|
||||
}
|
||||
buildItem := domain.BuildQueueItem{
|
||||
@ -131,9 +131,11 @@ func processQueueAndStatus(ctx context.Context) {
|
||||
func updatePackageStatus(item *domain.BuildQueueItem, status domain.PackageStatus, buildStatus domain.PackageStatus) {
|
||||
item.Source.Packages.ForEach(func(k string, v domain.PackageInfo) bool {
|
||||
v.Status = status
|
||||
v.BuildAttempts++
|
||||
v.LastBuildStatus = domain.PackageStatus(buildStatus)
|
||||
if status == domain.Current {
|
||||
v.Version = item.BuildVersion
|
||||
v.BuildAttempts = 0
|
||||
v.NewVersion = ""
|
||||
}
|
||||
item.Source.Packages.Set(k, v)
|
||||
|
@ -34,6 +34,7 @@ type PackageInfo struct {
|
||||
Status PackageStatus
|
||||
NewVersion string
|
||||
LastBuildStatus PackageStatus
|
||||
BuildAttempts int
|
||||
}
|
||||
|
||||
type PackageStatus string
|
||||
|
@ -36,35 +36,56 @@ func ProcessPackages() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Combine packages before processing
|
||||
combinePackages(internalPackages)
|
||||
combinePackages(externalPackages)
|
||||
|
||||
ProcessStalePackages(internalPackages, externalPackages)
|
||||
ProcessMissingPackages(internalPackages, externalPackages)
|
||||
|
||||
updatedPackages := haxmap.New[string, domain.SourcePackage]()
|
||||
|
||||
internalPackages.ForEach(func(k string, v domain.SourcePackage) bool {
|
||||
curr, ok := currentPackagesFastMap.Get(k)
|
||||
if !ok {
|
||||
currentPackagesFastMap.Set(k, v)
|
||||
curr, exists := currentPackagesFastMap.Get(k)
|
||||
if !exists {
|
||||
updatedPackages.Set(k, v)
|
||||
return true
|
||||
}
|
||||
curr.Packages.ForEach(func(kk string, pk domain.PackageInfo) bool {
|
||||
v.Packages.ForEach(func(vv string, pv domain.PackageInfo) bool {
|
||||
if pv.PackageName == pk.PackageName {
|
||||
if pk.Status == domain.Error {
|
||||
pv.LastBuildStatus = domain.Error
|
||||
}
|
||||
curr.Packages.Set(vv, pv)
|
||||
|
||||
mergedPackage := domain.SourcePackage{
|
||||
Name: curr.Name,
|
||||
Packages: haxmap.New[string, domain.PackageInfo](),
|
||||
}
|
||||
|
||||
v.Packages.ForEach(func(pkgName string, newPkg domain.PackageInfo) bool {
|
||||
if existingPkg, ok := curr.Packages.Get(pkgName); ok {
|
||||
if newPkg.Version != existingPkg.Version ||
|
||||
newPkg.Status != existingPkg.Status ||
|
||||
newPkg.NewVersion != existingPkg.NewVersion {
|
||||
newPkg.LastBuildStatus = domain.Error
|
||||
newPkg.BuildAttempts = existingPkg.BuildAttempts
|
||||
mergedPackage.Packages.Set(pkgName, newPkg)
|
||||
} else {
|
||||
mergedPackage.Packages.Set(pkgName, existingPkg)
|
||||
}
|
||||
return true
|
||||
})
|
||||
} else {
|
||||
mergedPackage.Packages.Set(pkgName, newPkg)
|
||||
}
|
||||
return true
|
||||
})
|
||||
currentPackagesFastMap.Set(k, curr)
|
||||
|
||||
curr.Packages.ForEach(func(pkgName string, pkg domain.PackageInfo) bool {
|
||||
if _, exists := mergedPackage.Packages.Get(pkgName); !exists {
|
||||
mergedPackage.Packages.Set(pkgName, pkg)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
updatedPackages.Set(k, mergedPackage)
|
||||
return true
|
||||
})
|
||||
|
||||
currentPackagesFastMap = updatedPackages
|
||||
|
||||
LastUpdateTime = time.Now()
|
||||
helpers.ReloadCache()
|
||||
err = SaveToDb()
|
||||
|
Loading…
Reference in New Issue
Block a user