Skip to content

Commit

Permalink
Remove redundant label added to Pods
Browse files Browse the repository at this point in the history
Previously, we added a label with key "build.knative.dev/buildName"
to Pods. That label was redundant with a different label whose key
is "pipeline.knative.dev/taskRun" as of beda1f8. Since we are no
longer depending on Knative Build at runtime, it seems best to
remove the redundant label.

Follow-up to #488.
  • Loading branch information
dwnusbaum authored and knative-prow-robot committed Feb 12, 2019
1 parent 6ac1ceb commit b52f7a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
10 changes: 1 addition & 9 deletions pkg/reconciler/v1alpha1/taskrun/resources/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,6 @@ func MakePod(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po
}
annotations["sidecar.istio.io/inject"] = "false"

labels := map[string]string{}
for key, val := range build.ObjectMeta.Labels {
labels[key] = val
}
// TODO: Redundant with TaskRun label set in `taskrun.makeLabels`. Should
// probably be removed once we translate from TaskRun to Pod directly.
labels[buildNameLabelKey] = build.Name

cred, secrets, err := makeCredentialInitializer(build, kubeclient)
if err != nil {
return nil, err
Expand Down Expand Up @@ -308,7 +300,7 @@ func MakePod(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po
// If our parent TaskRun is deleted, then we should be as well.
OwnerReferences: build.OwnerReferences,
Annotations: annotations,
Labels: labels,
Labels: build.ObjectMeta.Labels,
},
Spec: corev1.PodSpec{
// If the build fails, don't restart it.
Expand Down
13 changes: 2 additions & 11 deletions pkg/reconciler/v1alpha1/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/knative/build-pipeline/pkg/apis/pipeline"
"github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/knative/build-pipeline/pkg/reconciler"
"github.com/knative/build-pipeline/pkg/reconciler/v1alpha1/taskrun/config"
Expand All @@ -45,8 +46,7 @@ import (
const (
entrypointLocation = "/tools/entrypoint"
toolsMountName = "tools"
buildNameLabelKey = "build.knative.dev/buildName"
taskRunNameLabelKey = "pipeline.knative.dev/taskRun"
taskRunNameLabelKey = pipeline.GroupName + pipeline.TaskRunLabelKey
)

var (
Expand Down Expand Up @@ -236,7 +236,6 @@ func TestReconcile(t *testing.T) {

taskRunWithLabels := tb.TaskRun("test-taskrun-with-labels", "foo",
tb.TaskRunLabel("TaskRunLabel", "TaskRunValue"),
tb.TaskRunLabel(buildNameLabelKey, "WillNotBeUsed"),
tb.TaskRunLabel(taskRunNameLabelKey, "WillNotBeUsed"),
tb.TaskRunSpec(
tb.TaskRunTaskRef(simpleTask.Name),
Expand Down Expand Up @@ -264,7 +263,6 @@ func TestReconcile(t *testing.T) {
name: "success",
taskRun: taskRunSuccess,
wantBuild: tb.Build("test-taskrun-run-success", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-run-success"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-run-success"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-run-success",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand All @@ -280,7 +278,6 @@ func TestReconcile(t *testing.T) {
name: "serviceaccount",
taskRun: taskRunWithSaSuccess,
wantBuild: tb.Build("test-taskrun-with-sa-run-success", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-with-sa-run-success"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-with-sa-run-success"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-with-sa-run-success",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand All @@ -297,7 +294,6 @@ func TestReconcile(t *testing.T) {
name: "params",
taskRun: taskRunTemplating,
wantBuild: tb.Build("test-taskrun-templating", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-templating"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-templating"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-templating",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand Down Expand Up @@ -326,7 +322,6 @@ func TestReconcile(t *testing.T) {
name: "wrap-steps",
taskRun: taskRunInputOutput,
wantBuild: tb.Build("test-taskrun-input-output", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-input-output"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-input-output"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-input-output",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand Down Expand Up @@ -365,7 +360,6 @@ func TestReconcile(t *testing.T) {
name: "taskrun-with-taskspec",
taskRun: taskRunWithTaskSpec,
wantBuild: tb.Build("test-taskrun-with-taskspec", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-with-taskspec"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-with-taskspec"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-with-taskspec",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand All @@ -390,7 +384,6 @@ func TestReconcile(t *testing.T) {
name: "success-with-cluster-task",
taskRun: taskRunWithClusterTask,
wantBuild: tb.Build("test-taskrun-with-cluster-task", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-with-cluster-task"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-with-cluster-task"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-with-cluster-task",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand All @@ -405,7 +398,6 @@ func TestReconcile(t *testing.T) {
name: "taskrun-with-resource-spec-task-spec",
taskRun: taskRunWithResourceSpecAndTaskSpec,
wantBuild: tb.Build("test-taskrun-with-resource-spec", "foo",
tb.BuildLabel(buildNameLabelKey, "test-taskrun-with-resource-spec"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-with-resource-spec"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-with-resource-spec",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand All @@ -431,7 +423,6 @@ func TestReconcile(t *testing.T) {
taskRun: taskRunWithLabels,
wantBuild: tb.Build("test-taskrun-with-labels", "foo",
tb.BuildLabel("TaskRunLabel", "TaskRunValue"),
tb.BuildLabel(buildNameLabelKey, "test-taskrun-with-labels"),
tb.BuildLabel(taskRunNameLabelKey, "test-taskrun-with-labels"),
tb.BuildOwnerReference("TaskRun", "test-taskrun-with-labels",
tb.OwnerReferenceAPIVersion("pipeline.knative.dev/v1alpha1")),
Expand Down

0 comments on commit b52f7a9

Please sign in to comment.