Skip to content

Commit

Permalink
Fixed image build issues with packages lacking tests. (#6074)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindhu Karri <[email protected]>
Co-authored-by: Pawel Winogrodzki <[email protected]>
  • Loading branch information
3 people authored and jslobodzian committed Aug 28, 2023
1 parent c9e69c2 commit f3fee7c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions toolkit/tools/scheduler/schedulerutils/buildlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func IsReservedFile(rpmPath string, reservedRPMs []string) bool {
// - packagesNamesToRebuild,
// - local packages listed in the image config, and
// - kernels in the image config (if built locally).
func calculatePackagesToBuild(packagesNamesToBuild, packagesNamesToRebuild []*pkgjson.PackageVer, imageConfig, baseDirPath string, dependencyGraph *pkggraph.PkgGraph) (packageVersToBuild []*pkgjson.PackageVer, err error) {
func calculatePackagesToBuild(packagesNamesToBuild, packagesNamesToRebuild []*pkgjson.PackageVer, imageConfig, baseDirPath string, dependencyGraph *pkggraph.PkgGraph, nodeGetter func(*pkggraph.LookupNode) *pkggraph.PkgNode) (packageVersToBuild []*pkgjson.PackageVer, err error) {
packageVersToBuild = append(packagesNamesToBuild, packagesNamesToRebuild...)

packageVersFromConfig, err := extractPackagesFromConfig(imageConfig, baseDirPath)
Expand All @@ -116,7 +116,7 @@ func calculatePackagesToBuild(packagesNamesToBuild, packagesNamesToRebuild []*pk
return
}

packageVersFromConfig, err = filterLocalPackagesOnly(packageVersFromConfig, dependencyGraph)
packageVersFromConfig, err = filterLocalPackagesOnly(packageVersFromConfig, dependencyGraph, nodeGetter)
if err != nil {
err = fmt.Errorf("failed to filter local packages from the image config, error:\n%w", err)
return
Expand Down Expand Up @@ -153,7 +153,7 @@ func extractPackagesFromConfig(configFile, baseDirPath string) (packageList []*p
}

// filterLocalPackagesOnly returns the subset of packageVersionsInConfig that only contains local packages.
func filterLocalPackagesOnly(packageVersionsInConfig []*pkgjson.PackageVer, dependencyGraph *pkggraph.PkgGraph) (filteredPackages []*pkgjson.PackageVer, err error) {
func filterLocalPackagesOnly(packageVersionsInConfig []*pkgjson.PackageVer, dependencyGraph *pkggraph.PkgGraph, nodeGetter func(*pkggraph.LookupNode) *pkggraph.PkgNode) (filteredPackages []*pkgjson.PackageVer, err error) {
logger.Log.Debug("Filtering out external packages from list of packages extracted from the image config file.")

for _, pkgVer := range packageVersionsInConfig {
Expand All @@ -162,7 +162,8 @@ func filterLocalPackagesOnly(packageVersionsInConfig []*pkgjson.PackageVer, depe
// A pkgNode for a local package has the following characteristics:
// 1) The pkgNode exists in the graph (is not nil).
// 2) The pkgNode has a build node. External packages will only have a run node.
if pkgNode != nil && pkgNode.BuildNode != nil {
filteredNode := nodeGetter(pkgNode)
if filteredNode != nil {
filteredPackages = append(filteredPackages, pkgVer)
} else {
logger.Log.Debugf("Found external package to filter out: %v.", pkgVer)
Expand Down Expand Up @@ -275,7 +276,7 @@ func parseAndGeneratePackageList(dependencyGraph *pkggraph.PkgGraph, buildList,
return
}

finalPackagesToBuild, err = calculatePackagesToBuild(packagesToBuild, packagesToRebuild, imageConfig, baseDirPath, dependencyGraph)
finalPackagesToBuild, err = calculatePackagesToBuild(packagesToBuild, packagesToRebuild, imageConfig, baseDirPath, dependencyGraph, nodeGetter)
if err != nil {
err = fmt.Errorf("unable to generate the final package build list, error:\n%s", err)
return
Expand Down

0 comments on commit f3fee7c

Please sign in to comment.