Skip to content

Commit

Permalink
Fix pipeline version to v0.42.0 in e2e
Browse files Browse the repository at this point in the history
This will fix pipeline version to v0.42.0 in e2e
as 0.43.0 version have v1 support and it makes e2e fails

Fixing version in e2e till we add support for pipeline v1 CRDs
  • Loading branch information
piyush-garg authored and tekton-robot committed Dec 26, 2022
1 parent b5f225e commit 8196435
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 60 deletions.
61 changes: 2 additions & 59 deletions pkg/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import (
"github.com/tektoncd/cli/pkg/formatted"
prsort "github.com/tektoncd/cli/pkg/pipelinerun/sort"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
"k8s.io/apimachinery/pkg/api/errors"
"github.com/tektoncd/pipeline/pkg/status"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -174,7 +173,7 @@ func Create(c *cli.Clients, pr *v1beta1.PipelineRun, opts metav1.CreateOptions,
}

func populatePipelineRunTaskStatuses(c *cli.Clients, ns string, pr v1beta1.PipelineRun) (*v1beta1.PipelineRun, error) {
taskRunMap, runMap, err := getFullPipelineTaskStatuses(context.Background(), c.Tekton, ns, &pr)
taskRunMap, runMap, err := status.GetFullPipelineTaskStatuses(context.Background(), c.Tekton, ns, &pr)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get TaskRun and Run statuses for PipelineRun %s from namespace %s\n", pr.Name, ns)
return nil, err
Expand All @@ -184,59 +183,3 @@ func populatePipelineRunTaskStatuses(c *cli.Clients, ns string, pr v1beta1.Pipel

return &pr, nil
}

// getFullPipelineTaskStatuses returns populated TaskRun and Run status maps for a PipelineRun from its ChildReferences.
// If the PipelineRun has no ChildReferences, its .Status.TaskRuns and .Status.Runs will be returned instead.
// TODO(abayer): Remove in favor of github.com/tektoncd/pipeline/pkg/status.GetFullPipelineTaskStatuses when CLI can move to Pipeline v0.36.0 or later.
func getFullPipelineTaskStatuses(ctx context.Context, client versioned.Interface, ns string, pr *v1beta1.PipelineRun) (map[string]*v1beta1.PipelineRunTaskRunStatus,
map[string]*v1beta1.PipelineRunRunStatus, error) {
// If the PipelineRun is nil, just return
if pr == nil {
return nil, nil, nil
}

// If there are no child references or either TaskRuns or Runs is non-zero, return the existing TaskRuns and Runs maps
if len(pr.Status.ChildReferences) == 0 || len(pr.Status.TaskRuns) > 0 || len(pr.Status.Runs) > 0 {
return pr.Status.TaskRuns, pr.Status.Runs, nil
}

trStatuses := make(map[string]*v1beta1.PipelineRunTaskRunStatus)
runStatuses := make(map[string]*v1beta1.PipelineRunRunStatus)

for _, cr := range pr.Status.ChildReferences {
switch cr.Kind {
case "TaskRun":
tr, err := client.TektonV1beta1().TaskRuns(ns).Get(ctx, cr.Name, metav1.GetOptions{})
if err != nil && !errors.IsNotFound(err) {
return nil, nil, err
}

trStatuses[cr.Name] = &v1beta1.PipelineRunTaskRunStatus{
PipelineTaskName: cr.PipelineTaskName,
WhenExpressions: cr.WhenExpressions,
}

if tr != nil {
trStatuses[cr.Name].Status = &tr.Status
}
case "Run":
r, err := client.TektonV1alpha1().Runs(ns).Get(ctx, cr.Name, metav1.GetOptions{})
if err != nil && !errors.IsNotFound(err) {
return nil, nil, err
}

runStatuses[cr.Name] = &v1beta1.PipelineRunRunStatus{
PipelineTaskName: cr.PipelineTaskName,
WhenExpressions: cr.WhenExpressions,
}

if r != nil {
runStatuses[cr.Name].Status = &r.Status
}
default:
// Don't do anything for unknown types.
}
}

return trStatuses, runStatuses, nil
}
3 changes: 2 additions & 1 deletion pkg/pipelinerun/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
informers "github.com/tektoncd/pipeline/pkg/client/informers/externalversions"
"github.com/tektoncd/pipeline/pkg/status"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -83,7 +84,7 @@ func (t *Tracker) Monitor(allowed []string) <-chan []trh.Run {
return
}

trMap, runMap, err := getFullPipelineTaskStatuses(context.Background(), t.Tekton, t.Ns, pr)
trMap, runMap, err := status.GetFullPipelineTaskStatuses(context.Background(), t.Tekton, t.Ns, pr)
if err != nil {
return
}
Expand Down
2 changes: 2 additions & 0 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function install_pipeline_crd() {
# If for whatever reason the nightly release wasnt there (nightly ci failure?), try the released version
[[ -n ${latestreleaseyaml} ]] || latestreleaseyaml=https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
fi
# TODO: to remove this pinning of pipeline version after v1 support of Pipeline CRDs in cli, as this is done to make CI green till then
latestreleaseyaml="https://github.com/tektoncd/pipeline/releases/download/v0.42.0/release.yaml"
[[ -z ${latestreleaseyaml} ]] && fail_test "Could not get latest released release.yaml"
kubectl apply -f ${latestreleaseyaml} ||
fail_test "Build pipeline installation failed"
Expand Down
119 changes: 119 additions & 0 deletions vendor/github.com/tektoncd/pipeline/pkg/status/status.go

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

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,7 @@ github.com/tektoncd/pipeline/pkg/remote
github.com/tektoncd/pipeline/pkg/remote/oci
github.com/tektoncd/pipeline/pkg/resolution/common
github.com/tektoncd/pipeline/pkg/resolution/resource
github.com/tektoncd/pipeline/pkg/status
github.com/tektoncd/pipeline/pkg/substitution
github.com/tektoncd/pipeline/test
github.com/tektoncd/pipeline/test/diff
Expand Down

0 comments on commit 8196435

Please sign in to comment.