-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redesign PAC Resolver #1762
Redesign PAC Resolver #1762
Conversation
2ec4209
to
ea9e50a
Compare
/retest |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1762 +/- ##
==========================================
+ Coverage 65.08% 65.13% +0.04%
==========================================
Files 174 174
Lines 13167 13185 +18
==========================================
+ Hits 8570 8588 +18
+ Misses 4029 4028 -1
- Partials 568 569 +1 ☔ View full report in Codecov by Sentry. |
@piyush-garg Thank you for the PR
|
if pipelinerun.GetObjectMeta().GetAnnotations() == nil { | ||
continue | ||
} |
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.
We have this check below
if len(pipelinerun.GetObjectMeta().GetAnnotations()) == 0 {
continue
}
can we avoid this nil check ??
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.
first i am checking if it is nil or not, then if it is not nil then checking if it has any key value pairs.
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.
these checks i have kept, same like before, it were there in old resolver too
@@ -32,74 +31,161 @@ func alreadySeen[T NamedItem](items []T, item T) bool { | |||
// | |||
// The precedence logic for Pipeline is first from PipelineRun annotations and | |||
// then from Tekton directory. | |||
func getRemotes(ctx context.Context, rt *matcher.RemoteTasks, types TektonTypes) (TektonTypes, error) { | |||
remoteType := &TektonTypes{} | |||
func resolveRemoteResources(ctx context.Context, rt *matcher.RemoteTasks, types TektonTypes, ropt *Opts) ([]*tektonv1.PipelineRun, error) { |
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 function is too big can we split into smaller function specific to task and pipeline
8eea80a
to
10e1e9a
Compare
/test |
@piyush-garg
|
/retest |
1935bbb
to
f6089f8
Compare
Added e2e tests for all three |
This will redesign resolver to work with multiple edge case scenarios. Previously pac resolver was filtering pipelinerun based on annotations but it was resolving all pipelines in .tekton dir leading to resolving unnecessary pipelines and other issue was it was storing task based on task name, instead of annotation name and version, so different version of task were not used across pipelineruns in .tekton dir Now with new design we are first filtering pipelinerun based on annotations, and then processing all pipelineruns one by one and only resolving pipeline related to these pipelineruns. Also we are now maintaining map of tasks with name and version at event level to not re fetch the task and now inline spec replacement in pipelinerun is done one by one so respective task as mentioned in annotation with name and version is used Also before filtering the pipelineruns, we should make sure that no two pipelineruns exists with same name in .tekton dir Added tests for the three scenarios
f6089f8
to
9ba9da2
Compare
/test |
var task *tektonv1.Task | ||
// if task is already fetched in the event, then just copy the task | ||
if alreadyFetchedResource(fetchedResourcesForEvent.Tasks, remoteTask) { | ||
rt.Logger.Debugf("skipping already fetched task %s in annotations on pipelinerun %s", remoteTask, pipelinerun.GetName()) |
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.
Ok if i understand properly how the code flow goes, it's the first fetched task that wins? I think we want to document this in the docs as if there is two tasks with the same name the first grabbed from the .tektondir or the first one listed from the annotation (top to botoom i think?) will win, is that correct?
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 i am trying to first get the task from if anything mentioned in annotations(first pipelinerun, then pipeline), if not then i try to see if there is task available with that name in .tekton dir
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 am following this https://pipelinesascode.com/docs/guide/resolver/#tasks-or-pipelines-precedence
LGTM tested and reviewed this and this looks good, thanks @piyush-garg |
This will redesign resolver to work with
multiple edge case scenarios.
Previously pac resolver was filtering
pipelinerun based on annotations but it was
resolving all pipelines in .tekton dir
leading to resolving unnecessary pipelines
and other issue was it was storing task
based on task name, instead of annotation name
and version, so different version of task
were not used across pipelineruns in .tekton dir
Now with new design we are first filtering
pipelinerun based on annotations, and then
processing all pipelineruns one by one
and only resolving pipeline related to these
pipelineruns. Also we are now maintaining map
of tasks with name and version at event level
to not re fetch the task and now inline spec
replacement in pipelinerun is done one by one
so respective task as mentioned in annotation
with name and version is used
Also before filtering the pipelineruns, we should
make sure that no two pipelineruns exists with
same name in .tekton dir
Added tests for the three scenarios
Submitter Checklist
📝 Please ensure your commit message is clear and informative. For guidance on crafting effective commit messages, refer to the How to write a git commit message guide. We prefer the commit message to be included in the PR body itself rather than a link to an external website (ie: Jira ticket).
♽ Before submitting a PR, run make test lint to avoid unnecessary CI processing. For an even more efficient workflow, consider installing pre-commit and running pre-commit install in the root of this repository.
✨ We use linters to maintain clean and consistent code. Please ensure you've run make lint before submitting a PR. Some linters offer a --fix mode, which can be executed with the command make fix-linters (ensure markdownlint and golangci-lint tools are installed first).
📖 If you're introducing a user-facing feature or changing existing behavior, please ensure it's properly documented.
🧪 While 100% coverage isn't a requirement, we encourage unit tests for any code changes where possible.
🎁 If feasible, please check if an end-to-end test can be added. See README for more details.
🔎 If there's any flakiness in the CI tests, don't necessarily ignore it. It's better to address the issue before merging, or provide a valid reason to bypass it if fixing isn't possible (e.g., token rate limitations).