Skip to content

Commit 90b4048

Browse files
committed
Reflect tektoncd/pipeline release version as an annotation on pod
As a followup to tektoncd#1650 , the `tekton.dev/release` annotation is set on the pod to reflect the value of version.PipelineVersion Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
1 parent 0f20c35 commit 90b4048

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/pod/entrypoint.go

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package pod
1919
import (
2020
"errors"
2121
"fmt"
22+
"github.com/tektoncd/pipeline/pkg/version"
2223
"path/filepath"
2324
"strings"
2425

@@ -43,6 +44,8 @@ const (
4344
)
4445

4546
var (
47+
releaseAnnotation = "tekon.dev/release"
48+
releaseAnnotationValue = version.PipelineVersion
4649
// TODO(#1605): Generate volumeMount names, to avoid collisions.
4750
toolsMount = corev1.VolumeMount{
4851
Name: toolsVolumeName,
@@ -148,6 +151,7 @@ func UpdateReady(kubeclient kubernetes.Interface, pod corev1.Pod) error {
148151
// start.
149152
if newPod.ObjectMeta.Annotations == nil {
150153
newPod.ObjectMeta.Annotations = map[string]string{}
154+
newPod.ObjectMeta.Annotations[releaseAnnotation] = releaseAnnotationValue
151155
}
152156
if newPod.ObjectMeta.Annotations[readyAnnotation] != readyAnnotationValue {
153157
newPod.ObjectMeta.Annotations[readyAnnotation] = readyAnnotationValue

pkg/pod/pod.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package pod
1818

1919
import (
2020
"fmt"
21+
"github.com/tektoncd/pipeline/pkg/version"
2122
"path/filepath"
2223

2324
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
@@ -42,6 +43,9 @@ const (
4243

4344
// These are effectively const, but Go doesn't have such an annotation.
4445
var (
46+
releaseAnnotation = "tekon.dev/release"
47+
releaseAnnotationValue = version.PipelineVersion
48+
4549
groupVersionKind = schema.GroupVersionKind{
4650
Group: v1alpha1.SchemeGroupVersion.Group,
4751
Version: v1alpha1.SchemeGroupVersion.Version,
@@ -179,6 +183,9 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha
179183
mergedPodContainers = append(mergedPodContainers, sc)
180184
}
181185

186+
podAnnotations := taskRun.Annotations
187+
podAnnotations[releaseAnnotation] = releaseAnnotationValue
188+
182189
return &corev1.Pod{
183190
ObjectMeta: metav1.ObjectMeta{
184191
// We execute the build's pod in the same namespace as where the build was
@@ -193,7 +200,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha
193200
OwnerReferences: []metav1.OwnerReference{
194201
*metav1.NewControllerRef(taskRun, groupVersionKind),
195202
},
196-
Annotations: taskRun.Annotations,
203+
Annotations: podAnnotations,
197204
Labels: makeLabels(taskRun),
198205
},
199206
Spec: corev1.PodSpec{

0 commit comments

Comments
 (0)