Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Conversation

@petr-muller
Copy link
Member

Post-#96, we are able to detect which ci-operator configs changed in a PR. To start rehearsing the jobs affected by changed ci-operator configs, we needed to implement these two remaining capabilities:

  1. Walk through all presubmits and find which ones reference one of the changed configs
  2. Merge the two discovered sets of rehearsal jobs without creating duplicates.

/cc @stevekuznetsov @bbguimaraes @droslean

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 6, 2019
@petr-muller petr-muller force-pushed the ciop-change-rehearse branch from 506d9f4 to 85bfaa2 Compare March 6, 2019 22:28
}

changedCiopConfigs := diffs.GetChangedCiopConfigs(ciopMasterConfig, ciopPrConfig, logger)
changedPresubmits.AddAll(diffs.GetPresubmitsForCiopConfigs(prowPRConfig, changedCiopConfigs, logger))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that you needed to do this in the test, too, is smelly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that test basically mimics our main().

"org/destination-repo": {prowconfig.Presubmit{JobBase: prowconfig.JobBase{Name: "destination-job-for-org-destination-repo"}}},
},
}, {
description: "merge jobs with same name for a single repo, result has the one originally in destination",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we need unique names to work this might be better as an error, but meh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot be an error. In rehearse, when both ci-operator config and a presubmit that uses it change, we'll want to rehearse the same job for two reasons, so it ends up being returned by two different "what jobs do we need to rehearse" methods, and those results need to be merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah

// TemplatesPath is the path of the templates from release repo
TemplatesPath = "ci-operator/templates"
// Name of the configmap that stores all ci-operator configs
CiOperatorConfigsCMName = "ci-operator-configs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true -- we are sharded. See the ConfigMapName() method on the config.Info struct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware of that, I want to tackle that tomorrow. IMHO it's worth a separate PR. I only moved this constant, not created it. Rehearse is a little broken after the sharding anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #104

// ConfigureRehearsalJobs filters the jobs that should be rehearsed, then return a list of them re-configured with the
// ci-operator's configuration inlined.
func ConfigureRehearsalJobs(toBeRehearsed map[string][]prowconfig.Presubmit, ciopConfigs config.CompoundCiopConfig, prNumber int, loggers Loggers, allowVolumes bool) []*prowconfig.Presubmit {
func ConfigureRehearsalJobs(toBeRehearsed config.Presubmits, ciopConfigs config.CompoundCiopConfig, prNumber int, loggers Loggers, allowVolumes bool) []*prowconfig.Presubmit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might have been nicer to do the type changes in a separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. It's basically just a rename, I did a separate commit, and it was mostly driven by the need for the AddAll method.

Copy link
Member

@droslean droslean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this PR is ok. But still there are some cases missing.

If there is a changed ci-op config and a changed presubmit that its using that config, there is no need to do all of this, and instead we can just rehearse the changed presubmit with the changed ci-op config inlined. I am pretty sure that in most cases this is what will happen since if someone will change his ci-op config, prowgen will generate different presubmit.

So, the only thing left in this PR is to do this procedure only if there is no other changed presubmit that uses the changed ci-op config.

if job.Agent != string(pjapi.KubernetesAgent) {
continue
}
for _, container := range job.Spec.Containers {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to iterate here. just use job.Spec.Containers[0]
There is a validation already happening in the upstream library.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIll do.

changedPresubmits := diffs.GetChangedPresubmits(masterConfig.Prow, prConfig.Prow, logger)
rehearsals := rehearse.ConfigureRehearsalJobs(changedPresubmits, prConfig.CiOperator, prNumber, loggers, o.allowVolumes)
toRehearse := diffs.GetChangedPresubmits(masterConfig.Prow, prConfig.Prow, logger)
toRehearse.AddAll(diffs.GetPresubmitsForCiopConfigs(prConfig.Prow, changedCiopConfigs, logger))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the intention here is to add all the jobs that are using the changed ci-op config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the jobs that are using some of the changed ci-op configs, there could be more...

AddAll prevents job being present twice, so if a job was already in toRehearse because it was changed directly, it's not added again.

@petr-muller
Copy link
Member Author

If there is a changed ci-op config and a changed presubmit that its using that config, there is no need to do all of this, and instead we can just rehearse the changed presubmit with the changed ci-op config inlined. I am pretty sure that in most cases this is what will happen since if someone will change his ci-op config, prowgen will generate different presubmit.

So, the only thing left in this PR is to do this procedure only if there is no other changed presubmit that uses the changed ci-op config.

Can you elaborate on the changes that you are requesting? We detect which jobs changed directly. Then we detect which ciop configs changed and which jobs are using them, and merge these jobs with those changed directly. The resulting set of jobs will be rehearsed. What do you think should be done differently?

@droslean
Copy link
Member

droslean commented Mar 7, 2019

Can you elaborate on the changes that you are requesting? We detect which jobs changed directly. Then we detect which ciop configs changed and which jobs are using them, and merge these jobs with those changed directly. The resulting set of jobs will be rehearsed. What do you think should be done differently?

I wanted to be more selective in which jobs we should rehearse instead of running them all when we detect a changed ci-op config. I think what its implemented in this PR is a good start and we can be more selective in the future.

@petr-muller petr-muller force-pushed the ciop-change-rehearse branch from 85bfaa2 to e750492 Compare March 7, 2019 13:51
@petr-muller
Copy link
Member Author

Addressed the actionable comments.

These methods will be useful when we have multiple causes of rehearse
triggers, so we will need to simply merge instances of these maps
without creating duplicities.
Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: petr-muller, stevekuznetsov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [petr-muller,stevekuznetsov]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit ffa6e04 into openshift:master Mar 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants