Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RELEASE-971): add timeouts field to InternalRequests #106

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1alpha1/internalrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/konflux-ci/operator-toolkit/conditions"

"github.com/konflux-ci/internal-services/metrics"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -37,6 +38,10 @@ type InternalRequestSpec struct {
// kubebuilder:pruning:PreserveUnknownFields
// +optional
Params map[string]string `json:"params,omitempty"`

// Timeouts defines the different Timeouts to use in the InternalRequest PipelineRun execution
// +optional
Timeouts tektonv1beta1.TimeoutFields `json:"timeouts,omitempty"`
}

// InternalRequestStatus defines the observed state of InternalRequest.
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

18 changes: 18 additions & 0 deletions config/crd/bases/appstudio.redhat.com_internalrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ spec:
will be translated into a Tekton pipeline
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
timeouts:
description: Timeouts defines the different Timeouts to use in the
InternalRequest PipelineRun execution
properties:
finally:
description: Finally sets the maximum allowed duration of this
pipeline's finally
type: string
pipeline:
description: Pipeline sets the maximum allowed duration for execution
of the entire pipeline. The sum of individual timeouts for tasks
and finally must not exceed this value.
type: string
tasks:
description: Tasks sets the maximum allowed duration of this pipeline's
tasks
type: string
type: object
required:
- request
type: object
Expand Down
4 changes: 4 additions & 0 deletions tekton/pipeline_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (i *InternalRequestPipelineRun) WithInternalRequest(internalRequest *v1alph
metadata.PipelinesTypeLabel: PipelineTypeRelease,
}

if internalRequest.Spec.Timeouts != (tektonv1beta1.TimeoutFields{}) {
i.Spec.Timeouts = &internalRequest.Spec.Timeouts
}

return i
}

Expand Down
20 changes: 20 additions & 0 deletions tekton/pipeline_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"strings"

"github.com/konflux-ci/internal-services/api/v1alpha1"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/operator-framework/operator-lib/handler"
Expand Down Expand Up @@ -91,6 +93,19 @@ var _ = Describe("PipelineRun", Ordered, func() {
Expect(newInternalRequestPipelineRun.Labels[InternalRequestNameLabel]).To(Equal(internalRequest.Name))
Expect(newInternalRequestPipelineRun.Labels[InternalRequestNamespaceLabel]).To(Equal(internalRequest.Namespace))
})

It("should contain the timeout values", func() {

newInternalRequestPipelineRun := NewInternalRequestPipelineRun(internalServicesConfig)
newInternalRequestPipelineRun.WithInternalRequest(internalRequest)
timeouts := &tektonv1beta1.TimeoutFields{
Pipeline: &metav1.Duration{Duration: 1 * time.Hour},
Tasks: &metav1.Duration{Duration: 1 * time.Hour},
Finally: &metav1.Duration{Duration: 1 * time.Hour},
}

Expect(newInternalRequestPipelineRun.Spec.Timeouts).To(Equal(timeouts))
})
})

Context("When calling WithOwner", func() {
Expand Down Expand Up @@ -175,6 +190,11 @@ var _ = Describe("PipelineRun", Ordered, func() {
"foo": "bar",
"baz": "qux",
},
Timeouts: tektonv1beta1.TimeoutFields{
Pipeline: &metav1.Duration{Duration: 1 * time.Hour},
Tasks: &metav1.Duration{Duration: 1 * time.Hour},
Finally: &metav1.Duration{Duration: 1 * time.Hour},
},
},
}
internalRequest.Kind = "InternalRequest"
Expand Down
Loading