Skip to content

Commit

Permalink
Fix PipelineRunStatus Reconciler Updates and Tests for Minimal Embedd…
Browse files Browse the repository at this point in the history
…edStatus Switch

This commit fixes the updates for reconciling PipelineRunStatus when switching
the DefaultEmbeddedStatus from `Full` to `Minimal`. The prior runs or taskruns
status would not have been reset before this change. The related emtpy runs and
taskruns are removed because these fields will be `nil`.
  • Loading branch information
JeromeJu committed Jan 12, 2023
1 parent c752a36 commit b0c227f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
5 changes: 5 additions & 0 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,11 @@ func updatePipelineRunStatusFromChildObjects(ctx context.Context, logger *zap.Su
fullEmbedded := cfg.FeatureFlags.EmbeddedStatus == config.FullEmbeddedStatus || cfg.FeatureFlags.EmbeddedStatus == config.BothEmbeddedStatus
minimalEmbedded := cfg.FeatureFlags.EmbeddedStatus == config.MinimalEmbeddedStatus || cfg.FeatureFlags.EmbeddedStatus == config.BothEmbeddedStatus

if cfg.FeatureFlags.EmbeddedStatus == config.MinimalEmbeddedStatus {
pr.Status.TaskRuns = nil
pr.Status.Runs = nil
}

if minimalEmbedded {
updatePipelineRunStatusFromChildRefs(logger, pr, taskRuns, runObjects)
}
Expand Down
24 changes: 0 additions & 24 deletions pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5101,7 +5101,6 @@ spec:
pipelineRef:
name: test-pipeline
status:
runs: {}
pipelineSpec:
results:
- description: pipeline result
Expand Down Expand Up @@ -5135,7 +5134,6 @@ status:
value: aResultValue
- name: custom-result
value: bResultValue
taskRuns: {}
childReferences:
- apiVersion: tekton.dev/v1beta1
kind: TaskRun
Expand Down Expand Up @@ -5432,7 +5430,6 @@ spec:
pipelineRef:
name: test-pipeline
status:
runs: {}
pipelineSpec:
results:
- description: pipeline result
Expand Down Expand Up @@ -5461,7 +5458,6 @@ status:
value: aResultValue
- name: custom-result
value: bResultValue
taskRuns: {}
childReferences:
- apiVersion: tekton.dev/v1alpha1
kind: Run
Expand Down Expand Up @@ -8742,8 +8738,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-8
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
}, {
name: "p-finally",
Expand Down Expand Up @@ -8899,8 +8893,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-8
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
}}
for _, tt := range tests {
Expand Down Expand Up @@ -9339,8 +9331,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-8
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
}, {
name: "p-finally",
Expand Down Expand Up @@ -9507,8 +9497,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-8
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
}}
for _, tt := range tests {
Expand Down Expand Up @@ -9688,8 +9676,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-1
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
},
expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, `
Expand Down Expand Up @@ -9734,8 +9720,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-1
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
expectedTaskRuns: []*v1beta1.TaskRun{
mustParseTaskRunWithObjectMeta(t,
Expand Down Expand Up @@ -9882,8 +9866,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-1
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
},
expectedPipelineRun: parse.MustParseV1beta1PipelineRun(t, `
Expand Down Expand Up @@ -9928,8 +9910,6 @@ status:
kind: TaskRun
name: pr-platforms-and-browsers-1
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
expectedTaskRuns: []*v1beta1.TaskRun{
mustParseTaskRunWithObjectMeta(t,
Expand Down Expand Up @@ -10343,8 +10323,6 @@ status:
kind: Run
name: pr-platforms-and-browsers-8
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
}, {
name: "p-finally",
Expand Down Expand Up @@ -10501,8 +10479,6 @@ status:
kind: Run
name: pr-platforms-and-browsers-8
pipelineTaskName: platforms-and-browsers
taskRuns: {}
runs: {}
`),
}}
for _, tt := range tests {
Expand Down

0 comments on commit b0c227f

Please sign in to comment.