Skip to content

Commit

Permalink
Remove TaskRuns and Runs Fields of PipelineRunStatus
Browse files Browse the repository at this point in the history
This commit removes `status.taskruns` and `status.runs` and their
corresponding test cases.
  • Loading branch information
JeromeJu committed Feb 3, 2023
1 parent d2f075a commit 7a410ca
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 963 deletions.
36 changes: 0 additions & 36 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9612,9 +9612,6 @@ ParamValue
</table>
<h3 id="tekton.dev/v1beta1.PipelineRunRunStatus">PipelineRunRunStatus
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.PipelineRunStatusFields">PipelineRunStatusFields</a>)
</p>
<div>
<p>PipelineRunRunStatus contains the name of the PipelineTask for this CustomRun or Run and the CustomRun or Run&rsquo;s Status</p>
</div>
Expand Down Expand Up @@ -9942,36 +9939,6 @@ Kubernetes meta/v1.Time
</tr>
<tr>
<td>
<code>taskRuns</code><br/>
<em>
<a href="#tekton.dev/v1beta1.PipelineRunTaskRunStatus">
map[string]*github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunTaskRunStatus
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Deprecated - use ChildReferences instead.
map of PipelineRunTaskRunStatus with the taskRun name as the key</p>
</td>
</tr>
<tr>
<td>
<code>runs</code><br/>
<em>
<a href="#tekton.dev/v1beta1.PipelineRunRunStatus">
map[string]*github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.PipelineRunRunStatus
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Deprecated - use ChildReferences instead.
map of PipelineRunRunStatus with the run name as the key</p>
</td>
</tr>
<tr>
<td>
<code>pipelineResults</code><br/>
<em>
<a href="#tekton.dev/v1beta1.PipelineRunResult">
Expand Down Expand Up @@ -10068,9 +10035,6 @@ map[string]string
</table>
<h3 id="tekton.dev/v1beta1.PipelineRunTaskRunStatus">PipelineRunTaskRunStatus
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.PipelineRunStatusFields">PipelineRunStatusFields</a>)
</p>
<div>
<p>PipelineRunTaskRunStatus contains the name of the PipelineTask for this TaskRun and the TaskRun&rsquo;s Status</p>
</div>
Expand Down
60 changes: 2 additions & 58 deletions pkg/apis/pipeline/v1beta1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions pkg/apis/pipeline/v1beta1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,6 @@ func (pr *PipelineRunStatus) GetCondition(t apis.ConditionType) *apis.Condition
// and set the started time to the current time
func (pr *PipelineRunStatus) InitializeConditions(c clock.PassiveClock) {
started := false
if pr.TaskRuns == nil {
pr.TaskRuns = make(map[string]*PipelineRunTaskRunStatus)
}
if pr.Runs == nil {
pr.Runs = make(map[string]*PipelineRunRunStatus)
}
if pr.StartTime.IsZero() {
pr.StartTime = &metav1.Time{Time: c.Now()}
started = true
Expand Down Expand Up @@ -422,16 +416,6 @@ type PipelineRunStatusFields struct {
// CompletionTime is the time the PipelineRun completed.
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// Deprecated - use ChildReferences instead.
// map of PipelineRunTaskRunStatus with the taskRun name as the key
// +optional
TaskRuns map[string]*PipelineRunTaskRunStatus `json:"taskRuns,omitempty"`

// Deprecated - use ChildReferences instead.
// map of PipelineRunRunStatus with the run name as the key
// +optional
Runs map[string]*PipelineRunRunStatus `json:"runs,omitempty"`

// PipelineResults are the list of results written out by the pipeline task's containers
// +optional
// +listType=atomic
Expand Down
16 changes: 0 additions & 16 deletions pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ func TestInitializePipelineRunConditions(t *testing.T) {
}
p.Status.InitializeConditions(testClock)

if p.Status.TaskRuns == nil {
t.Fatalf("PipelineRun TaskRun status not initialized correctly")
}

if p.Status.Runs == nil {
t.Fatalf("PipelineRun Run status not initialized correctly")
}

if p.Status.StartTime.IsZero() {
t.Fatalf("PipelineRun StartTime not initialized correctly")
}
Expand All @@ -92,8 +84,6 @@ func TestInitializePipelineRunConditions(t *testing.T) {
if condition.Reason != v1beta1.PipelineRunReasonStarted.String() {
t.Fatalf("PipelineRun initialize reason should be %s, got %s instead", v1beta1.PipelineRunReasonStarted.String(), condition.Reason)
}
p.Status.TaskRuns["fooTask"] = &v1beta1.PipelineRunTaskRunStatus{}
p.Status.Runs["bahTask"] = &v1beta1.PipelineRunRunStatus{}

// Change the reason before we initialize again
p.Status.SetCondition(&apis.Condition{
Expand All @@ -104,12 +94,6 @@ func TestInitializePipelineRunConditions(t *testing.T) {
})

p.Status.InitializeConditions(testClock)
if len(p.Status.TaskRuns) != 1 {
t.Fatalf("PipelineRun TaskRun status getting reset")
}
if len(p.Status.Runs) != 1 {
t.Fatalf("PipelineRun Run status getting reset")
}

newCondition := p.Status.GetCondition(apis.ConditionSucceeded)
if newCondition.Reason != "not just started" {
Expand Down
28 changes: 0 additions & 28 deletions pkg/apis/pipeline/v1beta1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1215,13 +1215,6 @@
"description": "Provenance contains some key authenticated metadata about how a software artifact was built (what sources, what inputs/outputs, etc.).",
"$ref": "#/definitions/v1beta1.Provenance"
},
"runs": {
"description": "Deprecated - use ChildReferences instead. map of PipelineRunRunStatus with the run name as the key",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/v1beta1.PipelineRunRunStatus"
}
},
"skippedTasks": {
"description": "list of tasks that were skipped due to when expressions evaluating to false",
"type": "array",
Expand All @@ -1242,13 +1235,6 @@
"startTime": {
"description": "StartTime is the time the PipelineRun is actually started.",
"$ref": "#/definitions/v1.Time"
},
"taskRuns": {
"description": "Deprecated - use ChildReferences instead. map of PipelineRunTaskRunStatus with the taskRun name as the key",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/v1beta1.PipelineRunTaskRunStatus"
}
}
}
},
Expand Down Expand Up @@ -1290,13 +1276,6 @@
"description": "Provenance contains some key authenticated metadata about how a software artifact was built (what sources, what inputs/outputs, etc.).",
"$ref": "#/definitions/v1beta1.Provenance"
},
"runs": {
"description": "Deprecated - use ChildReferences instead. map of PipelineRunRunStatus with the run name as the key",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/v1beta1.PipelineRunRunStatus"
}
},
"skippedTasks": {
"description": "list of tasks that were skipped due to when expressions evaluating to false",
"type": "array",
Expand All @@ -1317,13 +1296,6 @@
"startTime": {
"description": "StartTime is the time the PipelineRun is actually started.",
"$ref": "#/definitions/v1.Time"
},
"taskRuns": {
"description": "Deprecated - use ChildReferences instead. map of PipelineRunTaskRunStatus with the taskRun name as the key",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/v1beta1.PipelineRunTaskRunStatus"
}
}
}
},
Expand Down
30 changes: 0 additions & 30 deletions pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 1 addition & 65 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Reconciler) resolvePipelineState(
for _, task := range tasks {
// We need the TaskRun name to ensure that we don't perform an additional remote resolution request for a PipelineTask
// in the TaskRun reconciler.
trName := resources.GetTaskRunName(pr.Status.TaskRuns, pr.Status.ChildReferences, task.Name, pr.Name)
trName := resources.GetTaskRunName(pr.Status.ChildReferences, task.Name, pr.Name)

vp, err := getVerificationPolicies(ctx, c.verificationPolicyLister, pr.Namespace)
if err != nil {
Expand Down Expand Up @@ -1317,12 +1317,6 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr
}

func updatePipelineRunStatusFromChildObjects(ctx context.Context, logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, taskRuns []*v1beta1.TaskRun, runObjects []v1beta1.RunObject) error {
// Clear any TaskRuns and Runs present in the status.
// This can occur if the value of "embedded-status" flag was modified during PipelineRun execution prior to its removal.
// TODO: https://github.com/tektoncd/pipeline/issues/6090 cleanup the checks for `status.taskruns` and
// `status.runs` and refactor the helper functions to be combined
pr.Status.Runs = nil
pr.Status.TaskRuns = nil
updatePipelineRunStatusFromChildRefs(logger, pr, taskRuns, runObjects)

return validateChildObjectsInPipelineRunStatus(ctx, pr.Status)
Expand Down Expand Up @@ -1395,64 +1389,6 @@ func filterRunsForPipelineRunStatus(logger *zap.SugaredLogger, pr *v1beta1.Pipel
return names, taskLabels, gvks, statuses
}

// updatePipelineRunStatusFromTaskRuns takes a PipelineRun and a list of TaskRuns within that PipelineRun, and updates
// the PipelineRun's .Status.TaskRuns.
func updatePipelineRunStatusFromTaskRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun) {
// If no TaskRun was found, nothing to be done. We never remove taskruns from the status
if len(trs) == 0 {
return
}

if pr.Status.TaskRuns == nil {
pr.Status.TaskRuns = make(map[string]*v1beta1.PipelineRunTaskRunStatus)
}

taskRuns := filterTaskRunsForPipelineRunStatus(logger, pr, trs)

// Loop over all the TaskRuns associated to Tasks
for _, taskrun := range taskRuns {
lbls := taskrun.GetLabels()
pipelineTaskName := lbls[pipeline.PipelineTaskLabelKey]

if _, ok := pr.Status.TaskRuns[taskrun.Name]; !ok {
// This taskrun was missing from the status.
// Add it without conditions, which are handled in the next loop
logger.Infof("Found a TaskRun %s that was missing from the PipelineRun status", taskrun.Name)
pr.Status.TaskRuns[taskrun.Name] = &v1beta1.PipelineRunTaskRunStatus{
PipelineTaskName: pipelineTaskName,
Status: &taskrun.Status,
}
}
}
}

func updatePipelineRunStatusFromCustomRunsOrRuns(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, runObjects []v1beta1.RunObject) {
// If no RunObject was found, nothing to be done. We never remove runs from the status
if len(runObjects) == 0 {
return
}
if pr.Status.Runs == nil {
pr.Status.Runs = make(map[string]*v1beta1.PipelineRunRunStatus)
}

// Get the names, their task label values, and their status objects for all CustomRuns or Runs associated with the PipelineRun
names, taskLabels, _, statuses := filterRunsForPipelineRunStatus(logger, pr, runObjects)

// Loop over all the elements and populate the status map
for idx := range names {
name := names[idx]
taskLabel := taskLabels[idx]
crStatus := statuses[idx]
if _, ok := pr.Status.Runs[name]; !ok {
// This run was missing from the status.
pr.Status.Runs[name] = &v1beta1.PipelineRunRunStatus{
PipelineTaskName: taskLabel,
Status: crStatus,
}
}
}
}

func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1beta1.PipelineRun, trs []*v1beta1.TaskRun, runObjects []v1beta1.RunObject) {
// If no TaskRun or RunObject was found, nothing to be done. We never remove child references from the status.
// We do still return an empty map of TaskRun/Run names keyed by PipelineTask name for later functions.
Expand Down
Loading

0 comments on commit 7a410ca

Please sign in to comment.