-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ConfigMap as a ValueSource in Param in TaskRuns and PipelineRuns #8642
base: main
Are you sure you want to change the base?
Conversation
- Added a new field ValueSource to v1.Param - Added validation to v1 CRD for Param and ParamValue based on a new feature flga `enable-valuefrom-in-param` - Added new methods to the reconciler in order to resolve these vallue sources during the first reconcile then upate the k8s resource - Added documentation and integration tests for the new feature - Fixed preexisting unit tests that were failing before the new validation (the params in the test cases were set up incorrectly) Signed-off-by: Mostafa Abdelwahab <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Related discussion about the feature #1744 |
The following is the coverage report on the affected files.
|
Few notes:
This is probably due to the recent script change of adding the OpenAPI schema to the CRD yamls pipeline/hack/update-codegen.sh Line 114 in 781c280
|
/kind feature |
There are many files in the PR. Here are the "entrypoints" of the code changes
|
/assign |
@mostafaCamel can this PR be broken down into multiple smaller PRs? maybe add this feature initially to taskruns and then in another PR to pipeline runs ? also, I see that the related TEP is not merged and hasn't had any discussion (at least in the comments on github). It would be advisable to discuss this in the community call as well if you would like to move this along faster. Thank you for the early PR though, definitely helps the community to understand the feature from a technical standpoint a lot better. |
Just skimmed through #1744 and have better context of this. It would be good to merge the TEP and move it to implementable state before we get back to the PR. |
Sounds good. Thanks Vibhav. I can wait until the TEP is merged then will break down the PR. I can also further break it into a pull request for api/ webhook validation (which will also generate the swagger and openapi changes), then a PR for taskrun reconciler (+ integration tests) then a PR for pipelinerun reconciler (+integration tests ) and a final PR for documentation |
@@ -690,3 +693,21 @@ type PipelineTaskRunTemplate struct { | |||
// +optional | |||
ServiceAccountName string `json:"serviceAccountName,omitempty"` | |||
} | |||
|
|||
// returns true if the RunSpecs are different in params (by value source resolution only) and deeply eual otherwise | |||
func (baseline *PipelineRunSpec) IsDifferentFromDesiredStateOnlyByValueSourceResolutionInParams(new *PipelineRunSpec) bool { |
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 my first PR to this repo so I am not sure if I should create a go interface with DeepCopy() and other methods and fields used here so that I avoid duplicating the code. There is a method that does the same thing for TaskRunSpec https://github.com/tektoncd/pipeline/pull/8642/files#diff-f6f395c4b788e7dad3da4c944d41e8b7e03540f0b49735417423ade04da8462bR532
FeatureFlags: &config.FeatureFlags{EnableValueFromInParam: tc.enableValueFromInParam}, | ||
Defaults: &config.Defaults{}, | ||
}) | ||
err := v1.ValidateParameters(ctx, tc.params) |
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.
Ideally I would have tested in this unit test that the method ValidateValueAndValueSourceInEachParam
was called but go does not provide mocks (unlike python)
if err != nil { | ||
return nil, fmt.Errorf("failed to marshal Params patch bytes: %w", err) | ||
} | ||
return c.PipelineClientSet.TektonV1().PipelineRuns(pr.Namespace).Patch(ctx, pr.Name, types.JSONPatchType, patchParamBytes, metav1.PatchOptions{}, "") |
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 haven't been able to unit test the reconciler changes because of Patch: the unit test was failing with requeue after: 27969h18m22.144989s
. When I tried to use Update instead, the unit test failed with Returned an error {"targetMethod": "ReconcileKind", "error": "Operation cannot be fulfilled on taskruns.tekton.dev \"test-task-param-run-valuesource-patch\": resourceVersion mismatch, got: 00001, wanted: 00003"}
I probably need to fix this testing behavior to add support for patching / non-status Update in
Line 131 in 781c280
return func(action ktesting.Action) (bool, runtime.Object, error) { |
t.Fatalf("Succeeded in creating PipelineRun `%s` with valuesource in params even though the feature flag is turned off", pipelineRun.Name) | ||
} | ||
|
||
updateConfigMap(ctx, c.KubeClient, system.Namespace(), config.GetFeatureFlagsConfigName(), map[string]string{ |
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 assuming that this does not affect other integration tests due to the teardown procedure + there is already a separate namespace per integration test anyways
@@ -20,8 +20,6 @@ metadata: | |||
spec: | |||
params: | |||
- name: message | |||
enum: ["v1", "v2"] |
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.
Changed made by mistake. I will undo it in my next amended commit
enable-valuefrom-in-param
Changes
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes