From 8d2115f204097a2fd341b2c997270c849cb1c1fd Mon Sep 17 00:00:00 2001 From: sindhu-karri <33163197+sindhu-karri@users.noreply.github.com> Date: Tue, 29 Aug 2023 00:13:49 +0530 Subject: [PATCH] Fixed image build issues with packages lacking tests. (#6074) Co-authored-by: Sindhu Karri Co-authored-by: Pawel Winogrodzki --- toolkit/tools/scheduler/schedulerutils/buildlist.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/toolkit/tools/scheduler/schedulerutils/buildlist.go b/toolkit/tools/scheduler/schedulerutils/buildlist.go index 94e7b52512..4459a4d458 100644 --- a/toolkit/tools/scheduler/schedulerutils/buildlist.go +++ b/toolkit/tools/scheduler/schedulerutils/buildlist.go @@ -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) @@ -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 @@ -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 { @@ -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) @@ -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