Strictly use module side repo during module builds and target only current project setting branches

This commit is contained in:
Mustafa Gezen 2022-11-19 21:08:54 +01:00
parent 3319abf62b
commit be2b871fff
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
5 changed files with 22 additions and 5 deletions

View File

@ -478,12 +478,15 @@ func (c *Controller) BuildWorkflow(ctx workflow.Context, req *peridotpb.SubmitBu
if extraOptions.ExtraYumrepofsRepos == nil { if extraOptions.ExtraYumrepofsRepos == nil {
extraOptions.ExtraYumrepofsRepos = []*peridotpb.ExtraYumrepofsRepo{} extraOptions.ExtraYumrepofsRepos = []*peridotpb.ExtraYumrepofsRepo{}
} }
if extraOptions.ExcludePackages == nil {
extraOptions.ExcludePackages = []string{}
}
extraOptions.ExtraYumrepofsRepos = append(extraOptions.ExtraYumrepofsRepos, &peridotpb.ExtraYumrepofsRepo{ extraOptions.ExtraYumrepofsRepos = append(extraOptions.ExtraYumrepofsRepos, &peridotpb.ExtraYumrepofsRepo{
Name: repo.Name, Name: repo.Name,
ModuleHotfixes: true, ModuleHotfixes: true,
IgnoreExclude: true, IgnoreExclude: true,
}) })
extraOptions.ExcludePackages = excludes extraOptions.ExcludePackages = append(extraOptions.ExcludePackages, excludes...)
var buildIds []string var buildIds []string
for _, build := range buildNvrs { for _, build := range buildNvrs {

View File

@ -49,6 +49,8 @@ import (
"google.golang.org/protobuf/types/known/wrapperspb" "google.golang.org/protobuf/types/known/wrapperspb"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"io/ioutil" "io/ioutil"
"path/filepath"
"peridot.resf.org/apollo/rpmutils"
"peridot.resf.org/peridot/composetools" "peridot.resf.org/peridot/composetools"
"peridot.resf.org/peridot/db/models" "peridot.resf.org/peridot/db/models"
peridotpb "peridot.resf.org/peridot/pb" peridotpb "peridot.resf.org/peridot/pb"
@ -230,6 +232,9 @@ func (c *Controller) BuildModuleWorkflow(ctx workflow.Context, req *peridotpb.Su
if len(req.Branches) > 0 && !utils.StrContains(revision.ScmBranchName, req.Branches) { if len(req.Branches) > 0 && !utils.StrContains(revision.ScmBranchName, req.Branches) {
continue continue
} }
if !strings.HasPrefix(revision.ScmBranchName, fmt.Sprintf("%s%d%s-stream", project.TargetBranchPrefix, project.MajorVersion, project.BranchSuffix.String)) {
continue
}
if branchIndex[revision.ScmBranchName] { if branchIndex[revision.ScmBranchName] {
continue continue
} }
@ -539,6 +544,8 @@ func (c *Controller) BuildModuleStreamWorkflow(ctx workflow.Context, req *perido
{ {
Name: repo.Name, Name: repo.Name,
ModuleHotfixes: true, ModuleHotfixes: true,
Priority: -1,
IgnoreExclude: true,
}, },
} }
} }
@ -549,8 +556,8 @@ func (c *Controller) BuildModuleStreamWorkflow(ctx workflow.Context, req *perido
// Building all project architectures is the default and cannot currently be overridden by the MD. // Building all project architectures is the default and cannot currently be overridden by the MD.
// The MD can't override generated values such as repository or cache either yet. // The MD can't override generated values such as repository or cache either yet.
// Name specified by the component is also currently ignored and the key is forcefully used. // Name specified by the component is also currently ignored and the key is forcefully used.
// We are not respecting platform or buildrequires at all since we don't have an active registry yet.
// Whatever is available in the latest revision of yumrepofs for the project is what's used (including external repos). // Whatever is available in the latest revision of yumrepofs for the project is what's used (including external repos).
var nonY1Excludes []string
for _, buildOrder := range buildOrders { for _, buildOrder := range buildOrders {
var futures []FutureContext var futures []FutureContext
for _, component := range buildOrderIndex[buildOrder] { for _, component := range buildOrderIndex[buildOrder] {
@ -590,6 +597,7 @@ func (c *Controller) BuildModuleStreamWorkflow(ctx workflow.Context, req *perido
BuildBatchId: streamBuildOptions.BuildBatchId, BuildBatchId: streamBuildOptions.BuildBatchId,
Modules: buildRequiresModules, Modules: buildRequiresModules,
ForceDist: streamBuildOptions.Dist, ForceDist: streamBuildOptions.Dist,
ExcludePackages: nonY1Excludes,
} }
task, err := c.db.CreateTask(nil, "noarch", peridotpb.TaskType_TASK_TYPE_BUILD, &req.ProjectId, &parentTaskId) task, err := c.db.CreateTask(nil, "noarch", peridotpb.TaskType_TASK_TYPE_BUILD, &req.ProjectId, &parentTaskId)
@ -614,6 +622,12 @@ func (c *Controller) BuildModuleStreamWorkflow(ctx workflow.Context, req *perido
return nil, err return nil, err
} }
buildTask.Builds = append(buildTask.Builds, &btask) buildTask.Builds = append(buildTask.Builds, &btask)
for _, a := range btask.Artifacts {
match := rpmutils.NVR().FindStringSubmatch(filepath.Base(a.Name))
if !utils.StrContains(match[1], nonY1Excludes) {
nonY1Excludes = append(nonY1Excludes, match[1])
}
}
if repo != nil { if repo != nil {
yumrepoCtx := workflow.WithChildOptions(ctx, workflow.ChildWorkflowOptions{ yumrepoCtx := workflow.WithChildOptions(ctx, workflow.ChildWorkflowOptions{

View File

@ -24,7 +24,7 @@ resfdeploy.new({
cpu: '2', cpu: '2',
memory: '15G', memory: '15G',
}, },
node_pool_request: { node_pool_request: if kubernetes.prod() then {
key: 'peridot.rockylinux.org/workflow-tolerates-arch', key: 'peridot.rockylinux.org/workflow-tolerates-arch',
value: 'amd64', value: 'amd64',
}, },

View File

@ -498,8 +498,7 @@ func (a *Access) GetBuildIDsByPackageNameAndBranchName(name string, branchName s
inner join project_package_versions ppv on ppv.package_version_id = b.package_version_id inner join project_package_versions ppv on ppv.package_version_id = b.package_version_id
inner join import_revisions ir on ir.package_version_id = b.package_version_id inner join import_revisions ir on ir.package_version_id = b.package_version_id
where where
b.project_id = $3 p.name = $1
and p.name = $1
and ir.scm_branch_name like '%-stream-' || $2 and ir.scm_branch_name like '%-stream-' || $2
order by b.created_at asc order by b.created_at asc
`, `,

View File

@ -297,6 +297,7 @@ message ExtraYumrepofsRepo {
string name = 1; string name = 1;
bool module_hotfixes = 2; bool module_hotfixes = 2;
bool ignore_exclude = 3; bool ignore_exclude = 3;
int32 priority = 4;
} }
// These options can be used to customize the behavior of the service // These options can be used to customize the behavior of the service