Skip to content

Commit ecb11fc

Browse files
chitrangpateltekton-robot
authored andcommitted
Migrate Propagated Workspaces to Stable
[Issue 6107](#6107) Migrate Propagated Workspaces to Stable Prior to this, propagated workspaces was hidden behind the beta feature gate. This feature is now a stable feature.
1 parent 80b80c6 commit ecb11fc

File tree

12 files changed

+63
-137
lines changed

12 files changed

+63
-137
lines changed

docs/additional-configs.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ Features currently in "beta" are:
307307

308308
| Feature | Proposal | Alpha Release | Beta Release | Individual Flag |
309309
|:-------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|:---------------------------------------------------------------------|:----------------|
310-
| [Propagated `Workspaces`](./pipelineruns.md#propagated-workspaces) | [TEP-0111](https://github.com/tektoncd/community/blob/main/teps/0111-propagating-workspaces.md) | [v0.40.0](https://github.com/tektoncd/pipeline/releases/tag/v0.40.0) | [v0.45.0](https://github.com/tektoncd/pipeline/releases/tag/v0.45.0) | |
311310
| [Array Results](pipelineruns.md#specifying-parameters) | [TEP-0076](https://github.com/tektoncd/community/blob/main/teps/0076-array-result-types.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | [v0.45.0](https://github.com/tektoncd/pipeline/releases/tag/v0.45.0) | |
312311

313312
## Enabling larger results using sidecar logs

docs/pipelineruns.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,6 @@ Consult the documentation of the custom task that you are using to determine whe
855855

856856
#### Propagated Workspaces
857857

858-
**[beta](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#beta-features))**
859-
860858
When using an embedded spec, workspaces from the parent `PipelineRun` will be
861859
propagated to any inlined specs without needing to be explicitly defined. This
862860
allows authors to simplify specs by automatically propagating top-level

docs/taskruns.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,6 @@ For more information, see the following topics:
453453

454454
#### Propagated Workspaces
455455

456-
**[beta](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#beta-features))**
457-
458456
When using an embedded spec, workspaces from the parent `TaskRun` will be
459457
propagated to any inlined specs without needing to be explicitly defined. This
460458
allows authors to simplify specs by automatically propagating top-level

pkg/reconciler/pipelinerun/pipelinerun.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,14 +1033,12 @@ func getTaskrunWorkspaces(ctx context.Context, pr *v1beta1.PipelineRun, rpt *res
10331033
pipelineRunWorkspaces[binding.Name] = binding
10341034
}
10351035

1036-
if config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != config.StableAPIFields {
1037-
// Propagate required workspaces from pipelineRun to the pipelineTasks
1038-
if rpt.PipelineTask.TaskSpec != nil {
1039-
rpt, err = propagateWorkspaces(rpt)
1040-
if err != nil {
1041-
// This error cannot be recovered without modifying the TaskSpec
1042-
return nil, "", controller.NewPermanentError(err)
1043-
}
1036+
// Propagate required workspaces from pipelineRun to the pipelineTasks
1037+
if rpt.PipelineTask.TaskSpec != nil {
1038+
rpt, err = propagateWorkspaces(rpt)
1039+
if err != nil {
1040+
// This error cannot be recovered without modifying the TaskSpec
1041+
return nil, "", controller.NewPermanentError(err)
10441042
}
10451043
}
10461044

pkg/reconciler/pipelinerun/pipelinerun_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7362,10 +7362,9 @@ spec:
73627362
},
73637363
},
73647364
}
7365-
ctx := config.EnableBetaAPIFields(context.Background())
73667365
for _, tt := range tests {
73677366
t.Run(tt.name, func(t *testing.T) {
7368-
_, _, err := getTaskrunWorkspaces(ctx, tt.pr, tt.rprt)
7367+
_, _, err := getTaskrunWorkspaces(context.Background(), tt.pr, tt.rprt)
73697368

73707369
if err != nil {
73717370
t.Errorf("Pipeline.getTaskrunWorkspaces() returned error for valid pipeline: %v", err)

pkg/reconciler/taskrun/taskrun.go

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,8 @@ func (c *Reconciler) prepare(ctx context.Context, tr *v1beta1.TaskRun) (*v1beta1
385385
var workspaceDeclarations []v1beta1.WorkspaceDeclaration
386386
// Propagating workspaces allows users to skip declarations
387387
// In order to validate the workspace bindings we create declarations based on
388-
// the workspaces provided in the task run spec. This logic is hidden behind the
389-
// alpha/beta feature gate since propagating workspaces is behind the beta feature gate.
390-
// In addition, we only allow this feature for embedded taskSpec.
391-
if config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != config.StableAPIFields && tr.Spec.TaskSpec != nil {
388+
// the workspaces provided in the task run spec. We only allow this feature for embedded taskSpec.
389+
if tr.Spec.TaskSpec != nil {
392390
for _, ws := range tr.Spec.Workspaces {
393391
wspaceDeclaration := v1beta1.WorkspaceDeclaration{Name: ws.Name}
394392
workspaceDeclarations = append(workspaceDeclarations, wspaceDeclaration)
@@ -767,25 +765,23 @@ func applyParamsContextsResultsAndWorkspaces(ctx context.Context, tr *v1beta1.Ta
767765
ts = resources.ApplyStepExitCodePath(ts)
768766

769767
// Apply workspace resource substitution
770-
if config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != config.StableAPIFields {
771-
// propagate workspaces from taskrun to task.
772-
twn := []string{}
773-
for _, tw := range ts.Workspaces {
774-
twn = append(twn, tw.Name)
775-
}
776-
777-
for _, trw := range tr.Spec.Workspaces {
778-
skip := false
779-
for _, tw := range twn {
780-
if tw == trw.Name {
781-
skip = true
782-
break
783-
}
784-
}
785-
if !skip {
786-
ts.Workspaces = append(ts.Workspaces, v1beta1.WorkspaceDeclaration{Name: trw.Name})
768+
// propagate workspaces from taskrun to task.
769+
twn := []string{}
770+
for _, tw := range ts.Workspaces {
771+
twn = append(twn, tw.Name)
772+
}
773+
774+
for _, trw := range tr.Spec.Workspaces {
775+
skip := false
776+
for _, tw := range twn {
777+
if tw == trw.Name {
778+
skip = true
779+
break
787780
}
788781
}
782+
if !skip {
783+
ts.Workspaces = append(ts.Workspaces, v1beta1.WorkspaceDeclaration{Name: trw.Name})
784+
}
789785
}
790786
ts = resources.ApplyWorkspaces(ctx, ts, ts.Workspaces, tr.Spec.Workspaces, workspaceVolumes)
791787

pkg/reconciler/taskrun/taskrun_test.go

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,31 +2532,23 @@ spec:
25322532
- emptyDir: {}
25332533
name: tr-workspace
25342534
`)
2535-
for _, apiField := range []string{config.BetaAPIFields, config.AlphaAPIFields} {
2536-
d := test.Data{
2537-
TaskRuns: []*v1beta1.TaskRun{taskRun},
2538-
}
2539-
d.ConfigMaps = []*corev1.ConfigMap{{
2540-
ObjectMeta: metav1.ObjectMeta{Namespace: system.Namespace(), Name: config.GetFeatureFlagsConfigName()},
2541-
Data: map[string]string{
2542-
"enable-api-fields": apiField,
2543-
},
2544-
}}
2545-
testAssets, cancel := getTaskRunController(t, d)
2546-
defer cancel()
2547-
createServiceAccount(t, testAssets, "default", taskRun.Namespace)
2548-
c := testAssets.Controller
2549-
if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err == nil {
2550-
t.Fatalf("Could not reconcile the taskrun: %v", err)
2551-
}
2552-
getTaskRun, _ := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{})
2535+
d := test.Data{
2536+
TaskRuns: []*v1beta1.TaskRun{taskRun},
2537+
}
2538+
testAssets, cancel := getTaskRunController(t, d)
2539+
defer cancel()
2540+
createServiceAccount(t, testAssets, "default", taskRun.Namespace)
2541+
c := testAssets.Controller
2542+
if err := c.Reconciler.Reconcile(testAssets.Ctx, getRunName(taskRun)); err == nil {
2543+
t.Fatalf("Could not reconcile the taskrun: %v", err)
2544+
}
2545+
getTaskRun, _ := testAssets.Clients.Pipeline.TektonV1beta1().TaskRuns(taskRun.Namespace).Get(testAssets.Ctx, taskRun.Name, metav1.GetOptions{})
25532546

2554-
want := []v1beta1.WorkspaceDeclaration{{
2555-
Name: "tr-workspace",
2556-
}}
2557-
if c := cmp.Diff(want, getTaskRun.Status.TaskSpec.Workspaces); c != "" {
2558-
t.Errorf("TestPropagatedWorkspaces errored with: %s", diff.PrintWantGot(c))
2559-
}
2547+
want := []v1beta1.WorkspaceDeclaration{{
2548+
Name: "tr-workspace",
2549+
}}
2550+
if c := cmp.Diff(want, getTaskRun.Status.TaskSpec.Workspaces); c != "" {
2551+
t.Errorf("TestPropagatedWorkspaces errored with: %s", diff.PrintWantGot(c))
25602552
}
25612553
}
25622554

0 commit comments

Comments
 (0)