Skip to content

Commit

Permalink
feat(pipelineloop): Upgrade Tekton to 0.27 for pipelineloop controlle…
Browse files Browse the repository at this point in the history
…r. (kubeflow#703) (kubeflow#706)

* Upgrade Tekton to 0.27 for pipelineloop controller. (kubeflow#703)

* Upgrade Tekton to 0.27 for pipelineloop controller. (kubeflow#703)

* Update pipelinelooprun.go
  • Loading branch information
ScrapCodes authored Aug 23, 2021
1 parent b5fe66c commit 3cb7187
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
3 changes: 1 addition & 2 deletions tekton-catalog/pipeline-loops/cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ func main() {
SecretName: secretName,
})

sharedmain.WebhookMainWithConfig(ctx, WebhookLogKey,
sharedmain.ParseAndGetConfigOrDie(),
sharedmain.MainWithContext(ctx, WebhookLogKey,
certificates.NewController,
newDefaultingAdmissionController,
newValidationAdmissionController,
Expand Down
26 changes: 12 additions & 14 deletions tekton-catalog/pipeline-loops/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ module github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops
go 1.13

require (
github.com/google/go-cmp v0.5.5
contrib.go.opencensus.io/exporter/stackdriver v0.13.5 // indirect
github.com/go-openapi/validate v0.19.5 // indirect
github.com/google/go-cmp v0.5.6
github.com/hashicorp/go-multierror v1.1.0
github.com/tektoncd/pipeline v0.25.0
go.uber.org/zap v1.16.0
gomodules.xyz/jsonpatch/v2 v2.1.0
k8s.io/api v0.19.7
k8s.io/apimachinery v0.19.7
k8s.io/client-go v0.19.7
knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0
)

// Knative deps (release-0.20)
replace (
contrib.go.opencensus.io/exporter/stackdriver => contrib.go.opencensus.io/exporter/stackdriver v0.13.4
github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v38.2.0+incompatible
github.com/tektoncd/pipeline v0.27.1
go.uber.org/zap v1.18.1
gomodules.xyz/jsonpatch/v2 v2.2.0
gopkg.in/evanphx/json-patch.v4 v4.9.0 // indirect
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
k8s.io/api v0.20.7
k8s.io/apimachinery v0.20.7
k8s.io/client-go v0.20.7
knative.dev/pkg v0.0.0-20210730172132-bb4aaf09c430
)
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"gomodules.xyz/jsonpatch/v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"knative.dev/pkg/apis"
"knative.dev/pkg/logging"
Expand Down Expand Up @@ -244,10 +245,19 @@ func (c *Reconciler) reconcile(ctx context.Context, run *v1alpha1.Run, status *p
// Run is cancelled, just cancel all the running instance and return
if run.IsCancelled() {
if len(failedPrs) > 0 {
run.Status.MarkRunFailed(pipelineloopv1alpha1.PipelineLoopRunReasonCancelled.String(),
run.Status.MarkRunFailed(pipelineloopv1alpha1.PipelineLoopRunReasonFailed.String(),
"Run %s/%s was failed",
run.Namespace, run.Name)
} else {
reason := pipelineloopv1alpha1.PipelineLoopRunReasonCancelled.String()
if run.HasTimedOut() { // This check is only possible if we are on tekton 0.27.0 +
reason = v1alpha1.RunReasonTimedOut
}
run.Status.MarkRunFailed(reason,
"Run %s/%s was cancelled",
run.Namespace, run.Name)
}

for _, currentRunningPr := range currentRunningPrs {
logger.Infof("Run %s/%s is cancelled. Cancelling PipelineRun %s.", run.Namespace, run.Name, currentRunningPr.Name)
if _, err := c.pipelineClientSet.TektonV1beta1().PipelineRuns(run.Namespace).Patch(ctx, currentRunningPr.Name, types.JSONPatchType, cancelPatchBytes, metav1.PatchOptions{}); err != nil {
Expand Down Expand Up @@ -378,14 +388,14 @@ func (c *Reconciler) createPipelineRun(ctx context.Context, logger *zap.SugaredL

// Create name for PipelineRun from Run name plus iteration number.
prName := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("%s-%s", run.Name, fmt.Sprintf("%05d", iteration)))

pr := &v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: prName,
Namespace: run.Namespace,
OwnerReferences: []metav1.OwnerReference{run.GetOwnerReference()},
Labels: getPipelineRunLabels(run, strconv.Itoa(iteration)),
Annotations: getPipelineRunAnnotations(run),
Name: prName,
Namespace: run.Namespace,
OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(run,
schema.GroupVersionKind{Group: "tekton.dev", Version: "v1alpha1", Kind: "Run"})},
Labels: getPipelineRunLabels(run, strconv.Itoa(iteration)),
Annotations: getPipelineRunAnnotations(run),
},
Spec: v1beta1.PipelineRunSpec{
Params: getParameters(run, tls, iteration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,6 @@ func loopRunning(run *v1alpha1.Run) *v1alpha1.Run {
return runWithStatus
}

func requestCancel(run *v1alpha1.Run) *v1alpha1.Run {
runWithCancelStatus := run.DeepCopy()
runWithCancelStatus.Spec.Status = v1alpha1.RunSpecStatusCancelled
return runWithCancelStatus
}

func running(tr *v1beta1.PipelineRun) *v1beta1.PipelineRun {
trWithStatus := tr.DeepCopy()
trWithStatus.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
Reason: v1beta1.PipelineRunReasonRunning.String(),
})
return trWithStatus
}

func successful(pr *v1beta1.PipelineRun) *v1beta1.PipelineRun {
prWithStatus := pr.DeepCopy()
prWithStatus.Status.SetCondition(&apis.Condition{
Expand Down

0 comments on commit 3cb7187

Please sign in to comment.