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

Store and validate TaskRun/Run UIDs in pipeline task embedded status #7833

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,17 @@ string
<p>WhenExpressions is the list of checks guarding the execution of the PipelineTask</p>
</td>
</tr>
<tr>
<td>
<code>uid</code><br/>
<em>
k8s.io/apimachinery/pkg/types.UID
</em>
</td>
<td>
<p>UID is the TaskRun or Run&rsquo;s UID</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.Combination">Combination
Expand Down Expand Up @@ -2266,6 +2277,17 @@ CustomRunStatus
<p>WhenExpressions is the list of checks guarding the execution of the PipelineTask</p>
</td>
</tr>
<tr>
<td>
<code>uid</code><br/>
<em>
k8s.io/apimachinery/pkg/types.UID
</em>
</td>
<td>
<p>UID is the Run&rsquo;s UID</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.PipelineRunSpec">PipelineRunSpec
Expand Down Expand Up @@ -2648,6 +2670,17 @@ TaskRunStatus
<p>WhenExpressions is the list of checks guarding the execution of the PipelineTask</p>
</td>
</tr>
<tr>
<td>
<code>uid</code><br/>
<em>
k8s.io/apimachinery/pkg/types.UID
</em>
</td>
<td>
<p>UID is the TaskRun&rsquo;s UID</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.PipelineSpec">PipelineSpec
Expand Down Expand Up @@ -9782,6 +9815,17 @@ string
<p>WhenExpressions is the list of checks guarding the execution of the PipelineTask</p>
</td>
</tr>
<tr>
<td>
<code>uid</code><br/>
<em>
k8s.io/apimachinery/pkg/types.UID
</em>
</td>
<td>
<p>UID is the TaskRun or Run&rsquo;s UID</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.CloudEventCondition">CloudEventCondition
Expand Down Expand Up @@ -11073,6 +11117,17 @@ CustomRunStatus
<p>WhenExpressions is the list of checks guarding the execution of the PipelineTask</p>
</td>
</tr>
<tr>
<td>
<code>uid</code><br/>
<em>
k8s.io/apimachinery/pkg/types.UID
</em>
</td>
<td>
<p>UID is the Run&rsquo;s UID</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.PipelineRunSpec">PipelineRunSpec
Expand Down Expand Up @@ -11535,6 +11590,17 @@ TaskRunStatus
<p>WhenExpressions is the list of checks guarding the execution of the PipelineTask</p>
</td>
</tr>
<tr>
<td>
<code>uid</code><br/>
<em>
k8s.io/apimachinery/pkg/types.UID
</em>
</td>
<td>
<p>UID is the TaskRun&rsquo;s UID</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.PipelineSpec">PipelineSpec
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/pipeline/v1/openapi_generated.go

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

7 changes: 7 additions & 0 deletions pkg/apis/pipeline/v1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ type ChildStatusReference struct {
// +optional
// +listType=atomic
WhenExpressions []WhenExpression `json:"whenExpressions,omitempty"`

// UID is the TaskRun or Run's UID
UID types.UID `json:"uid,omitempty"`
}

// PipelineRunStatusFields holds the fields of PipelineRunStatus' status.
Expand Down Expand Up @@ -598,6 +601,8 @@ type PipelineRunTaskRunStatus struct {
// +optional
// +listType=atomic
WhenExpressions []WhenExpression `json:"whenExpressions,omitempty"`
// UID is the TaskRun's UID
UID types.UID `json:"uid,omitempty"`
}

// PipelineRunRunStatus contains the name of the PipelineTask for this Run and the Run's Status
Expand All @@ -611,6 +616,8 @@ type PipelineRunRunStatus struct {
// +optional
// +listType=atomic
WhenExpressions []WhenExpression `json:"whenExpressions,omitempty"`
// UID is the Run's UID
UID types.UID `json:"uid,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/pipeline/v1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
"description": "PipelineTaskName is the name of the PipelineTask this is referencing.",
"type": "string"
},
"uid": {
"description": "UID is the TaskRun or Run's UID",
"type": "string"
},
"whenExpressions": {
"description": "WhenExpressions is the list of checks guarding the execution of the PipelineTask",
"type": "array",
Expand Down Expand Up @@ -621,6 +625,10 @@
"description": "Status is the RunStatus for the corresponding Run",
"$ref": "#/definitions/github.com.tektoncd.pipeline.pkg.apis.run.v1beta1.CustomRunStatus"
},
"uid": {
"description": "UID is the Run's UID",
"type": "string"
},
"whenExpressions": {
"description": "WhenExpressions is the list of checks guarding the execution of the PipelineTask",
"type": "array",
Expand Down Expand Up @@ -841,6 +849,10 @@
"description": "Status is the TaskRunStatus for the corresponding TaskRun",
"$ref": "#/definitions/v1.TaskRunStatus"
},
"uid": {
"description": "UID is the TaskRun's UID",
"type": "string"
},
"whenExpressions": {
"description": "WhenExpressions is the list of checks guarding the execution of the PipelineTask",
"type": "array",
Expand Down
21 changes: 21 additions & 0 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.

2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipelinerun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ func (st *SkippedTask) convertFrom(ctx context.Context, source v1.SkippedTask) {
func (csr ChildStatusReference) convertTo(ctx context.Context, sink *v1.ChildStatusReference) {
sink.TypeMeta = csr.TypeMeta
sink.Name = csr.Name
sink.UID = csr.UID
sink.DisplayName = csr.DisplayName
sink.PipelineTaskName = csr.PipelineTaskName
sink.WhenExpressions = nil
Expand All @@ -345,6 +346,7 @@ func (csr ChildStatusReference) convertTo(ctx context.Context, sink *v1.ChildSta
func (csr *ChildStatusReference) convertFrom(ctx context.Context, source v1.ChildStatusReference) {
csr.TypeMeta = source.TypeMeta
csr.Name = source.Name
csr.UID = source.UID
csr.DisplayName = source.DisplayName
csr.PipelineTaskName = source.PipelineTaskName
csr.WhenExpressions = nil
Expand Down
47 changes: 30 additions & 17 deletions pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/types"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
)
Expand All @@ -43,19 +44,22 @@ var (
childRefTaskRuns = []v1beta1.ChildStatusReference{{
TypeMeta: runtime.TypeMeta{Kind: "TaskRun", APIVersion: "tekton.dev/v1beta1"},
Name: "tr-0",
UID: types.UID("22222222-2222-2222-2222-222222222222"),
DisplayName: "TR 0",
PipelineTaskName: "ptn",
WhenExpressions: []v1beta1.WhenExpression{{Input: "default-value", Operator: "in", Values: []string{"val"}}},
}}
childRefRuns = []v1beta1.ChildStatusReference{{
TypeMeta: runtime.TypeMeta{Kind: "Run", APIVersion: "tekton.dev/v1alpha1"},
Name: "r-0",
UID: types.UID("22222222-2222-2222-2222-222222222222"),
DisplayName: "R 0",
PipelineTaskName: "ptn-0",
WhenExpressions: []v1beta1.WhenExpression{{Input: "default-value-0", Operator: "in", Values: []string{"val-0", "val-1"}}},
}}
trs = &v1beta1.PipelineRunTaskRunStatus{
PipelineTaskName: "ptn",
UID: types.UID("22222222-2222-2222-2222-222222222222"),
Status: &v1beta1.TaskRunStatus{
TaskRunStatusFields: v1beta1.TaskRunStatusFields{
PodName: "pod-name",
Expand Down Expand Up @@ -88,13 +92,14 @@ var (
},
},
},
Sidecars: []v1beta1.SidecarState{{ContainerState: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 1,
Reason: "Error",
Message: "Error",
Sidecars: []v1beta1.SidecarState{{
ContainerState: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 1,
Reason: "Error",
Message: "Error",
},
},
},
Name: "error",
ImageID: "image-id",
ContainerName: "sidecar-error",
Expand All @@ -109,6 +114,7 @@ var (
}
rrs = &v1beta1.PipelineRunRunStatus{
PipelineTaskName: "ptn-0",
UID: types.UID("22222222-2222-2222-2222-222222222222"),
Status: &runv1beta1.CustomRunStatus{
CustomRunStatusFields: runv1beta1.CustomRunStatusFields{
Results: []runv1beta1.CustomRunResult{{
Expand Down Expand Up @@ -268,17 +274,21 @@ func TestPipelineRunConversion(t *testing.T) {
},
HostNetwork: false,
},
StepOverrides: []v1beta1.TaskRunStepOverride{{
Name: "test-so",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: corev1resources.MustParse("1Gi")},
}},
StepOverrides: []v1beta1.TaskRunStepOverride{
{
Name: "test-so",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: corev1resources.MustParse("1Gi")},
},
},
},
SidecarOverrides: []v1beta1.TaskRunSidecarOverride{{
Name: "test-so",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: corev1resources.MustParse("1Gi")},
}},
SidecarOverrides: []v1beta1.TaskRunSidecarOverride{
{
Name: "test-so",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: corev1resources.MustParse("1Gi")},
},
},
},
Metadata: &v1beta1.PipelineTaskMetadata{
Labels: map[string]string{
Expand Down Expand Up @@ -315,7 +325,8 @@ func TestPipelineRunConversion(t *testing.T) {
Value: *v1beta1.NewObject(map[string]string{
"pkey1": "val1",
"pkey2": "rae",
})}, {
}),
}, {
Name: "pipeline-result-2",
Value: *v1beta1.NewObject(map[string]string{
"pkey1": "val2",
Expand Down Expand Up @@ -349,6 +360,7 @@ func TestPipelineRunConversion(t *testing.T) {
TypeMeta: runtime.TypeMeta{Kind: "TaskRun"},
Name: "t1",
PipelineTaskName: "task-1",
UID: types.UID("22222222-2222-2222-2222-222222222222"),
WhenExpressions: []v1beta1.WhenExpression{{
Input: "foo",
Operator: "notin",
Expand All @@ -358,6 +370,7 @@ func TestPipelineRunConversion(t *testing.T) {
{
TypeMeta: runtime.TypeMeta{Kind: "Run"},
Name: "t2",
UID: types.UID("22222222-2222-2222-2222-222222222222"),
PipelineTaskName: "task-2",
},
},
Expand Down
Loading