Skip to content
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

[TEP-0100] Implementation for embedded TaskRun and Run statuses in PipelineRuns #4739

Merged
merged 1 commit into from
Apr 15, 2022

Conversation

abayer
Copy link
Contributor

@abayer abayer commented Apr 6, 2022

Changes

See:

This implements TEP-0100, allowing for choosing between the original full embedded TaskRun and
Run statuses in PipelineRun statuses, minimal child references to the underlying TaskRun and
Runs, or both, building on top of all the other PRs referenced above.

/kind tep
/kind feature

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

Added implementation for minimal `TaskRun` and `Run` statuses within `PipelineRun` statuses. 

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). kind/feature Categorizes issue or PR as related to a new feature. labels Apr 6, 2022
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 6, 2022
@abayer
Copy link
Contributor Author

abayer commented Apr 6, 2022

/assign @lbernick
/assign @jerop

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 84.0% -5.5
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 86.3% 2.0
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@abayer
Copy link
Contributor Author

abayer commented Apr 6, 2022

/retest

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 84.0% -5.5
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 86.3% 2.0
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@@ -44,6 +48,9 @@ func TestTaskRunRetry(t *testing.T) {
knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf)
defer tearDown(ctx, t, c, namespace)

// Skip if the "embedded-status" feature flag has any value but "full".
Copy link
Member

Choose a reason for hiding this comment

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

this comment appears stale

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, that's still relevant in my mind - v1alpha1 should, in theory, always be full. Though in practice because of how we have the type aliases set up, I guess you could mess around there. Eh, I'm fine either way.

Copy link
Member

Choose a reason for hiding this comment

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

either way makes sense, but the comment here doesn't reflect the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oy, duh, fixed. =)

// If pr.Status.ChildReferences is populated, use that as source of truth for TaskRun and Run names.
if len(pr.Status.ChildReferences) > 0 {
// Loop over the ChildReferences in the PipelineRun status.
for _, cr := range pr.Status.ChildReferences {
Copy link
Member

Choose a reason for hiding this comment

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

I might prefer a helper function which returns the runs and taskruns to cancel based on the embedded status value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lemme see what I can do here.


return nil
}

func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) {
func updatePipelineRunStatusFromSlices(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, runs []*v1alpha1.Run) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: could this function be updatePipelineRunStatusFromChildObjects? IMO including things like "slices" in variable names can be redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I did not like the name but couldn't think of a better one.

if fullEmbedded {
updatePipelineRunStatusFromTaskRuns(logger, pr, taskRuns, taskNameByPipelineTask)
updatePipelineRunStatusFromRuns(logger, pr, runs)
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this else block should be necessary. If something depends on these values being non-nil let's change that code instead of initializing these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lemme see how much breaks if we don't initialize 'em.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, nothing but tests - nice!

// updatePipelineRunStatusFromTaskRuns takes a PipelineRun, a list of TaskRuns within that PipelineRun, and a map of
// existing PipelineTask names to TaskRun (or Run) names, and updates the PipelineRun's .Status.TaskRuns, including
// ensuring that any (deprecated) condition checks are represented.
func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun, taskRunNameByPipelineTask map[string]string) {
Copy link
Member

Choose a reason for hiding this comment

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

this function should be able to stay the same, no? (except for the small change removing the nil check for trs which I asked for :) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes here are either minor cleanup/renames (I really didn't like the taskrun variable name - I twitch when I see a variable name overriding an imported package name!), necessary signature changes, or the condition check changes with getNewConditionChecksForTaskRun. That said, I'll unrename things and clean up one or two inadvertent changes I made.

Copy link
Member

Choose a reason for hiding this comment

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

cleanup changes are great! I think they belong in a separate PR though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point there's just the one bit of cleanup left - switching if trs == nil || len(trs) == 0 { to if len(trs) == 0 {.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(oops accidentally hit resolve!)

for _, tr := range trs {
// Only process TaskRuns that are owned by this PipelineRun.
// This skips TaskRuns that are indirectly created by the PipelineRun (e.g. by custom tasks).
if len(tr.OwnerReferences) < 1 || tr.OwnerReferences[0].UID != pr.ObjectMeta.UID {
Copy link
Member

Choose a reason for hiding this comment

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

this block is repeated in a few places, can it be reused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shows up twice for TaskRun and twice for Run - not sure if it's worth doing that as two functions, but I'm open to it.

Copy link
Member

Choose a reason for hiding this comment

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

these two functions in general share a lot of code, could you experiment to see how it can be consolidated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lemme see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So fwiw on this particular block, I just tried going with a helper function or two (i.e., either one function each for TaskRun and Run, or one generic one with a type switch) and it didn't really make things any clearer, since we still have to have a block here for the continue. I'm still seeing if there are any other shared bits I can consolidate, but this particular one doesn't feel worth doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, turns out that once I decided to try doing the filtering of condition TaskRuns before entering the main loop, I saw the obvious and realized that we could just filter out the "not owned by this PipelineRun" TaskRuns and Runs before entering the main loop as well. 🤦 =) How does 6c8d615 look?

actualPrStatus.ChildReferences = fixedChildRefs
}

// Sort the ChildReferences to deal with annoying ordering issues.
Copy link
Member

Choose a reason for hiding this comment

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

rather than sorting the output, I think you can provide extra inputs/flags to cmp.Diff to get it to ignore ordering of some fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeaaaah - I just cargo-culted that over from the original ...FromTaskRuns test blindly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And actually, I'm not sure if cmpopts.SortSlices would make much of a difference here - it'd just be moving the same code around to be a parameter rather than standing alone...

@@ -585,7 +594,13 @@ func getConditionCheckName(taskRunStatus map[string]*v1beta1.PipelineRunTaskRunS
}

// GetTaskRunName should return a unique name for a `TaskRun` if one has not already been defined, and the existing one otherwise.
func GetTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus, ptName, prName string) string {
func GetTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus, childRefs []v1beta1.ChildStatusReference, ptName, prName string) string {
Copy link
Member

Choose a reason for hiding this comment

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

super nit: I think you can import and use constants for the kind of Run and TaskRun (here and elsewhere in the PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I swear that I couldn't figure out where to find that to import. Maybe I missed something?

Copy link
Member

Choose a reason for hiding this comment

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

they're here but actually on second thought importing and using the controller name is a bit weird :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, I did look at that and decided it felt too squirelly - I don't quite trust that the controller names are always going to be guaranteed to map one to one with the kinds. Feels like it might be worthwhile to add constants specifically for the kind name somewhere...

if len(pr.Status.Runs) != 2 {
t.Fatalf("PipelineRun had unexpected .status.runs; got %d, want 2", len(pr.Status.Runs))
var runNames []string
if embeddedStatusValue != config.MinimalEmbeddedStatus {
Copy link
Member

Choose a reason for hiding this comment

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

I think the branches are off here, you probably want

if embeddedStatusValue != config.MinimalEmbeddedStatus {}
if embeddedStatusValue != config.FullEmbeddedStatus{}

both here and below (ensuring config.BothEmbeddedStatus is tested correctly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member

Choose a reason for hiding this comment

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

same thing on line 218 and in custom_task_test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I feel a silly man. Fixed.


// GetEmbeddedStatusValue gets the current value for the "embedded-status" feature flag.
// If the flag is not set, it returns the default value.
func GetEmbeddedStatusValue(ctx context.Context, t *testing.T, kubeClient kubernetes.Interface) string {
Copy link
Member

Choose a reason for hiding this comment

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

super nit: this function can just be called "getEmbeddedStatus"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 84.0% -5.5
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 86.2% 2.0
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 84.0% -5.5
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 85.4% 1.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

len(prs.ChildReferences))
}

for _, cr := range prs.ChildReferences {
Copy link
Member

Choose a reason for hiding this comment

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

thanks for adding this function! just a few quick comments:

  • I would collect the names of child refs not in taskruns/runs and return an error containing all of them; this is more informative
  • make sure you're handling the case where childRef isn't a taskrun or a run
  • please add some tests for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 on all of that!


return nil
}

func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) {
func updatePipelineRunStatusFromSlices(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, runs []*v1alpha1.Run) {
taskNameByPipelineTask := make(map[string]string)
Copy link
Member

Choose a reason for hiding this comment

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

got it-- any way to factor out the condition checks and pass them into the updatePipelineRunStatus functions? it seems like the updatePipelineRunStatus functions could be made more modular: they should just take some info and use it to update the PR status, without having to return data that will be used in other updates

for _, tr := range trs {
// Only process TaskRuns that are owned by this PipelineRun.
// This skips TaskRuns that are indirectly created by the PipelineRun (e.g. by custom tasks).
if len(tr.OwnerReferences) < 1 || tr.OwnerReferences[0].UID != pr.ObjectMeta.UID {
Copy link
Member

Choose a reason for hiding this comment

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

these two functions in general share a lot of code, could you experiment to see how it can be consolidated?

@@ -585,7 +594,13 @@ func getConditionCheckName(taskRunStatus map[string]*v1beta1.PipelineRunTaskRunS
}

// GetTaskRunName should return a unique name for a `TaskRun` if one has not already been defined, and the existing one otherwise.
func GetTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus, ptName, prName string) string {
func GetTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus, childRefs []v1beta1.ChildStatusReference, ptName, prName string) string {
Copy link
Member

Choose a reason for hiding this comment

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

they're here but actually on second thought importing and using the controller name is a bit weird :/

if len(pr.Status.Runs) != 2 {
t.Fatalf("PipelineRun had unexpected .status.runs; got %d, want 2", len(pr.Status.Runs))
var runNames []string
if embeddedStatusValue != config.MinimalEmbeddedStatus {
Copy link
Member

Choose a reason for hiding this comment

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

same thing on line 218 and in custom_task_test

@@ -44,6 +48,9 @@ func TestTaskRunRetry(t *testing.T) {
knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf)
defer tearDown(ctx, t, c, namespace)

// Skip if the "embedded-status" feature flag has any value but "full".
Copy link
Member

Choose a reason for hiding this comment

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

either way makes sense, but the comment here doesn't reflect the code.

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 93.2% 3.7
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 85.4% 1.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@abayer
Copy link
Contributor Author

abayer commented Apr 7, 2022

/retest

@abayer
Copy link
Contributor Author

abayer commented Apr 7, 2022

/hold

Since I'm not squashing as I go, I'm putting this on hold until I get the thumbs-up for the whole PR and then squashing.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 7, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 93.2% 3.7
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 86.5% 2.3
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@@ -122,6 +127,45 @@ func cancelPipelineTaskRuns(ctx context.Context, logger *zap.SugaredLogger, pr *
return errs
}

// getChildObjectsToCancel looks in the PipelineRunStatus for TaskRun and Run names to cancel. It looks in
Copy link
Member

Choose a reason for hiding this comment

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

nit: this function comment describes the implementation, and the name describes how the function will be used.
I'd prefer something like:
// getChildObjects returns taskruns and runs owned by the pipelineRun, based on the value of the embedded status flag.

Copy link
Contributor Author

@abayer abayer Apr 8, 2022

Choose a reason for hiding this comment

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

👍 I'm renaming it to filterChildObjectsFromPRStatus.

// Loop over the TaskRuns in the PipelineRun status.
// If a TaskRun is not in the status yet we should not cancel it anyways.
for taskRunName := range pr.Status.TaskRuns {
trNames, runNames, err := getChildObjectsToCancel(ctx, pr.Status)
Copy link
Member

Choose a reason for hiding this comment

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

this is looking much better! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hooray! =)

pipelineRun: &v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-cancelled"},
Spec: v1beta1.PipelineRunSpec{
Status: v1beta1.PipelineRunSpecStatusCancelledDeprecated,
},
},
}, {
name: "child-references",
embeddedStatus: config.BothEmbeddedStatus,
Copy link
Member

Choose a reason for hiding this comment

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

could you please add a test case for minimal embedded status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

return nil
updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, runs)

return validateChildObjectsInPipelineRunStatus(ctx, pr.Status)
Copy link
Member

Choose a reason for hiding this comment

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

I think this function call should be moved to updatePipelineRunStatusFromChildObjects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍


return nil
}

func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) {
func updatePipelineRunStatusFromSlices(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, runs []*v1alpha1.Run) {
taskNameByPipelineTask := make(map[string]string)
Copy link
Member

Choose a reason for hiding this comment

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

maybe a better pattern here could be one function for minimal embedded status, one function for full embedded status, and one function for both embedded status which calls both of the first two. I think this way none of them should need to return anything. thoughts?

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 93.2% 3.7
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 86.5% 2.3
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@abayer
Copy link
Contributor Author

abayer commented Apr 8, 2022

/retest

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_types.go 86.4% 80.9% -5.5
pkg/reconciler/pipelinerun/cancel.go 89.5% 93.2% 3.7
pkg/reconciler/pipelinerun/pipelinerun.go 84.2% 86.1% 1.9
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 93.4% 92.3% -1.2
pkg/reconciler/pipelinerun/resources/pipelinerunstate.go 96.7% 96.6% -0.0
test/featureflags.go Do not exist 0.0%

@abayer
Copy link
Contributor Author

abayer commented Apr 8, 2022

/retest

d := test.Data{
PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun},
TaskRuns: tc.taskRuns,
Runs: tc.runs,
}
ctx, _ := ttesting.SetupFakeContext(t)
cfg := config.NewStore(logtesting.TestLogger(t))
Copy link
Member

Choose a reason for hiding this comment

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

what's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, there's a line further down that needs to be removed. We need the context to be populated with the feature flags, hence this bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, no, the later line is fine. Yeah, so what I said above. =)

Copy link
Member

Choose a reason for hiding this comment

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

I think you can just do cfg := withCustomTasks(withEmbeddedStatus(newFeatureFlagsConfigMap(), tc.embeddedStatus))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That creates a ConfigMap, but not a *config.Store, which is what we need to call cfg.ToContext(ctx). I tried hand-crafting a context.Context so I could skip the *config.Store in between, but couldn't make it work right for config.FromContextOrDefaults(ctx) to pick it up properly.

}
if r.IsDone() {
t.Fatalf("Run unexpectedly done: %v", r.Status.GetCondition(apis.ConditionSucceeded))
for rn := range pr.Status.Runs {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused, what's going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need the run name later in the test.

Copy link
Member

Choose a reason for hiding this comment

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

oh I see, the slice has length 1-- in that case pr.Status.Runs[0] is more clear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right, I tried to do that, but pr.Status.Runs is a map, so pr.Status.Runs[0] isn't an option.

Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

/lgtm

}
if r.IsDone() {
t.Fatalf("Run unexpectedly done: %v", r.Status.GetCondition(apis.ConditionSucceeded))
for rn := range pr.Status.Runs {
Copy link
Member

Choose a reason for hiding this comment

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

oh I see, the slice has length 1-- in that case pr.Status.Runs[0] is more clear

d := test.Data{
PipelineRuns: []*v1beta1.PipelineRun{tc.pipelineRun},
TaskRuns: tc.taskRuns,
Runs: tc.runs,
}
ctx, _ := ttesting.SetupFakeContext(t)
cfg := config.NewStore(logtesting.TestLogger(t))
Copy link
Member

Choose a reason for hiding this comment

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

I think you can just do cfg := withCustomTasks(withEmbeddedStatus(newFeatureFlagsConfigMap(), tc.embeddedStatus))

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 8, 2022
@abayer abayer force-pushed the embedded-statuses-impl-mk2 branch from c934e21 to af6055a Compare April 8, 2022 20:26
@abayer abayer force-pushed the embedded-statuses-impl-mk2 branch from 7990ce4 to ce12e81 Compare April 14, 2022 17:12
@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

/hold cancel

Ok, hopefully this is the final form. =)

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 14, 2022
@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

/retest

1 similar comment
@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

/retest

Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 14, 2022
@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

/retest

1 similar comment
@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

/retest

@lbernick
Copy link
Member

If build tests are failing this seems unlikely to be a flake?

@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

the pull-tekton-pipeline-build-tests failure was pre-rebase, and it was a job that appears to not have properly started in the first place, getting marked as a failure for timing out. And literally while I was writing this, the current run passed. =)

@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

/retest

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/cancel.go 89.5% 93.2% 3.7
pkg/reconciler/pipelinerun/pipelinerun.go 85.5% 86.0% 0.6
test/featureflags.go Do not exist 0.0%

@abayer
Copy link
Contributor Author

abayer commented Apr 14, 2022

cc @tektoncd/core-maintainers - I'd be extremely grateful for a final review/approve (well, assuming it's approval-worthy!), so I can finally get TEP-0100 put to bed for once and for all. =)

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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

The pull request process is described here

Needs approval from an approver in each of these files:

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 15, 2022
@tekton-robot tekton-robot merged commit 940a7bb into tektoncd:main Apr 15, 2022
@JaneSoo
Copy link

JaneSoo commented Apr 19, 2022

Hello, thank you all so much for this feature. How do I enable this feature? Should I add the flag in my pipelinerun? Do you have an example?

@lbernick
Copy link
Member

Hi @JaneSoo, this will be available in the next release, and can be enabled via the feature-flags configmap as described here. Email announcement coming soon!

@JaneSoo
Copy link

JaneSoo commented Apr 19, 2022

Thanks a lot for the respond @lbernick

@JaneSoo
Copy link

JaneSoo commented Apr 20, 2022

@lbernick I don't think I am subscribed to an email. Could you tell me when is the release date?

@lbernick
Copy link
Member

Please make sure you are subscribed to https://groups.google.com/g/tekton-users; we just sent out an email update (thanks for the reminder!) This release is scheduled for the 25th.

abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request Apr 20, 2022
With tektoncd#4739 merged and the v0.35.0 release coming up, it's time to update the deprecations table.
The plan is to switch the default value for `embedded-status` to `minimal` 9 months after the
release of v0.35.0, and then remove the `full` and `both` values in the following release. I
opted to use the date for changing the default as the "earliest date of removal" here.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
@abayer abayer mentioned this pull request Apr 20, 2022
5 tasks
tekton-robot pushed a commit that referenced this pull request Apr 20, 2022
With #4739 merged and the v0.35.0 release coming up, it's time to update the deprecations table.
The plan is to switch the default value for `embedded-status` to `minimal` 9 months after the
release of v0.35.0, and then remove the `full` and `both` values in the following release. I
opted to use the date for changing the default as the "earliest date of removal" here.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Yongxuanzhang pushed a commit to Yongxuanzhang/pipeline that referenced this pull request Apr 22, 2022
With tektoncd#4739 merged and the v0.35.0 release coming up, it's time to update the deprecations table.
The plan is to switch the default value for `embedded-status` to `minimal` 9 months after the
release of v0.35.0, and then remove the `full` and `both` values in the following release. I
opted to use the date for changing the default as the "earliest date of removal" here.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
chitrangpatel pushed a commit to chitrangpatel/pipeline that referenced this pull request May 3, 2022
This comes out of discussions on tektoncd#4739 - with the new minimal embedded status
changes which will be introduced in that PR, we can see that we're currently
using the output of `pipelineRunFacts.State.GetTaskRunsStatus(pr)` and
`pipelineRunFacts.State.GetRunsStatus(pr)` for two separate purposes:

* To set `pr.Status.TaskRuns` and `pr.Status.Runs` with the full embedded status
* To pass to `resources.ApplyTaskResultsToPipelineResults` for populating results

It's understandable why `ApplyTaskResultsToPipelineResults` is using
the maps from `pr.Status.[TaskRuns|Runs]`, since those maps do contain everything
needed for propagating results up from the tasks to the pipeline run, but if you
look at the current implementation, you can see that it's shuffling the maps
around into a different form that's more suited for what it's doing than the
original form.

So this PR reworks `ApplyTaskResultsToPipelineResults` to instead take maps in
the form the current implementation uses internally, with new functions on
`PipelineRunState` to get these new maps without needing to use the `pr.Status.[TaskRuns|Runs]`
form as an intermediary. This makes the pre-minimal-embedded-status
implementation cleaner, and is particularly helpful in that regard once we do
have minimal embedded status in place.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
chitrangpatel pushed a commit to chitrangpatel/pipeline that referenced this pull request May 3, 2022
…d status

This builds on tektoncd#4694, tektoncd#4734, and tektoncd#4753. It will feed into a revamped tektoncd#4739, all as part
of https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
and tektoncd#3140.

Specifically, this adds functionality to `pkg/reconciler/pipelinerun/resources` in
`pipelinerunresolution.go` and `pipelinerunstate.go` which will be needed for the
full implementation. These changes won't have any effects in the current situation,
because `pr.Status.ChildReferences` is never populated, so can be made independently
of the rest of the implementation, thus also shrinking the size of the rest of the
implementation PR(s) for easier review.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
chitrangpatel pushed a commit to chitrangpatel/pipeline that referenced this pull request May 3, 2022
With tektoncd#4739 merged and the v0.35.0 release coming up, it's time to update the deprecations table.
The plan is to switch the default value for `embedded-status` to `minimal` 9 months after the
release of v0.35.0, and then remove the `full` and `both` values in the following release. I
opted to use the date for changing the default as the "earliest date of removal" here.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants