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