-
Notifications
You must be signed in to change notification settings - Fork 20
Rehearse jobs that use changed ci-operator configs #101
Rehearse jobs that use changed ci-operator configs #101
Conversation
506d9f4 to
85bfaa2
Compare
| } | ||
|
|
||
| changedCiopConfigs := diffs.GetChangedCiopConfigs(ciopMasterConfig, ciopPrConfig, logger) | ||
| changedPresubmits.AddAll(diffs.GetPresubmitsForCiopConfigs(prowPRConfig, changedCiopConfigs, logger)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
droslean
left a comment
There was a problem hiding this 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.
pkg/diffs/diffs.go
Outdated
| if job.Agent != string(pjapi.KubernetesAgent) { | ||
| continue | ||
| } | ||
| for _, container := range job.Spec.Containers { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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. |
85bfaa2 to
e750492
Compare
|
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.
e750492 to
988fc1f
Compare
stevekuznetsov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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:
/cc @stevekuznetsov @bbguimaraes @droslean