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

Add API and Reconciler for Tekton Result #322

Merged
merged 2 commits into from
Jul 5, 2021

Conversation

sm43
Copy link
Member

@sm43 sm43 commented Jun 8, 2021

Closes #163

Signed-off-by: Shivam Mukhade smukhade@redhat.com

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

User can now install Tekton Results by creating a new CR TektonResult. The installation process is documented at  https://github.com/tektoncd/operator/blob/main/docs/tekton_results.md. This is enabled only for Kubernetes Platform.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 8, 2021
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 8, 2021
@sm43
Copy link
Member Author

sm43 commented Jun 8, 2021

/cc @nikhil-thomas

@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 53.4% -11.1

@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 53.4% -11.1

@nikhil-thomas nikhil-thomas added the release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. label Jun 9, 2021
@nikhil-thomas
Copy link
Member

/approve

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nikhil-thomas

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 9, 2021
@nikhil-thomas
Copy link
Member

Looks great 👍

A few things needs to be added:

  • release not in pr description
  • a doc in docs/ mentioning that TektonResults will not be auton installed like other components, as the TektonResults needs 2 secrets which end user should provide.

@nikhil-thomas
Copy link
Member

nikhil-thomas commented Jun 9, 2021

@wlynch could you take a look. 🧑‍💻

short recap:

  • this pr adds a new clusterScoped CRD TektonResults
  • user will have to create an instance of this CRD with name result and operator will install latest available (present in operator repo) release.yaml of TektonReults
    • operator reconciler will only 1 instance (name: result) of the clusterwide CRD
  • reconciler logic in short: read TektonResults reelase.yaml, change namespace to spec.targetNamespace, create resources on cluster
  • at present, unlike other tekton components operator will not auto-install TektonResults, as TektonResults need 2 secrets to be created before install.

cc @sm43

@sm43
Copy link
Member Author

sm43 commented Jun 9, 2021

/hold
to add unit tests for transformers

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 9, 2021
@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.2% 2.7

@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.2% 2.7

@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.6% 3.2

@tekton-robot tekton-robot removed the release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. label Jun 9, 2021
@sm43
Copy link
Member Author

sm43 commented Jun 9, 2021

Looks great +1

A few things needs to be added:

* release not in pr description

* a doc in `docs/` mentioning that TektonResults `will not be` auton installed like other components, as the TektonResults needs 2 secrets which end user should provide.

@nikhil-thomas addressed the comments.
also added a condition to check if Target Namespace in TektonResult CR is same as TektonPipeline CR, if different then installation would fail.

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 9, 2021
@sm43 sm43 requested a review from savitaashture June 9, 2021 12:04
@nikhil-thomas
Copy link
Member

@sm43 let us keep TektonResults CRD and contrller available only for Kubernetes now.
For OpenShift we use payload (release.yaml) created in `github.com/openshift/tektoncd-. eg: (https://github.com/openshift/tektoncd-pipeline/blob/release-v0.22.0/openshift/release/tektoncd-pipeline-v0.22.0.yaml)

As there is no midstream project for TektonResult, lets avoid adding it to openshift builds.

/hold make this patch kubernetes build specific

@nikhil-thomas
Copy link
Member

/hold

@savitaashture
Copy link
Contributor

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 10, 2021
@sm43
Copy link
Member Author

sm43 commented Jun 10, 2021

/retest

1 similar comment
@sm43
Copy link
Member Author

sm43 commented Jun 14, 2021

/retest

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 14, 2021
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 16, 2021
@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.6% 3.2

@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.6% 3.2

app: tekton-results-api
app.kubernetes.io/name: tekton-results
app.kubernetes.io/component: api
results.tekton.dev/release: "v0.1.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a release version mismatch? (filepath says 0.2.0).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. i downloaded both but copied wrong one I guess 😅

// is done, returns an error or timeout.
func WaitForTektonResultState(clients resultv1alpha1.TektonResultInterface, name string,
inState func(s *v1alpha1.TektonResult, err error) (bool, error)) (*v1alpha1.TektonResult, error) {
span := logging.GetEmitableSpan(context.Background(), fmt.Sprintf("WaitForTektonResultState/%s/%s", name, "TektonResultIsReady"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using context.Background/TODO, let's just have the func take in a context as a param.

}

// TektonResultCRDelete deletes tha TektonResult to see if all resources will be deleted
func TektonResultCRDelete(t *testing.T, clients *utils.Clients, crNames utils.ResourceNames) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: TektonResultCRDDelete?

@@ -0,0 +1,119 @@
// +build e2e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: tektonresultdeployment_test.go

Comment on lines +11 to +44
- namespace: `tekton-pipelin es`
- name: `tekton-results-mysql`
- contains the fields:
- `user=root`
- `password=<your password>`

If you are not using a particular password management strategy, the following
command will generate a random password for you:
Update namespace value in the command if Tekton Pipelines is installed in a different namespace..

```sh
$ kubectl create secret generic tekton-results-mysql --namespace=tekton-pipelines --from-literal=user=root --from-literal=password=$(openssl rand -base64 20)
```
- Generate cert/key pair.
Note: Feel free to use any cert management software to do this!

Tekton Results expects the cert/key pair to be stored in a [TLS Kubernetes Secret](https://kubernetes.io/docs/concepts/configuration/secret/#tls-secrets).
Update the namespace value in below export command if Tekton Pipelines is installed in a different namespace.
```sh
# Generate new self-signed cert.
$ export NAMESPACE="tekton-pipelines"
$ openssl req -x509 \
-newkey rsa:4096 \
-keyout key.pem \
-out cert.pem \
-days 365 \
-nodes \
-subj "/CN=tekton-results-api-service.${NAMESPACE}.svc.cluster.local" \
-addext "subjectAltName = DNS:tekton-results-api-service.${NAMESPACE}.svc.cluster.local"
# Create new TLS Secret from cert.
$ kubectl create secret tls -n ${NAMESPACE} tekton-results-tls \
--cert=cert.pem \
--key=key.pem
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with operator best practices, but would it be possible to automate these steps for the user if we find that they are not present at reconcile time?

For the TLS cert, are there existing examples for how we can hook into cert-manager or something similar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's the plan to automate this also, To start with we kept the creation of secrets a manual steps. so, user will create secrets and then TektonResult CR.
cc @nikhil-thomas

Copy link
Member

@nikhil-thomas nikhil-thomas Jun 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to automate these steps for the user if we find that they are not present at reconcile time?

that is definitely the ideal ux the operator should deliver.
we will definitely handle in in upcoming iterations. 🧑‍💻 👍

i have created an issue to track this: Automate creation prerequisites for TektonResult install #331

}

// AssertTektonResultCRReadyStatus verifies if the TektonResult reaches the READY status.
func AssertTektonResultCRReadyStatus(t *testing.T, clients *utils.Clients, names utils.ResourceNames) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit odd to me to have an exported func in a library that requires a testing.T. Can we unexport these and move them to the test file where they are used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah make sense. It seems the for all components it is similar way. I will address this in a separate pr

@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.6% 3.2

@sm43
Copy link
Member Author

sm43 commented Jun 17, 2021

@wlynch the release.yaml for v0.2.0 of Results seems to have results.tekton.dev/release: devel and version seems to be missing. Could you please check once?
https://github.com/tektoncd/results/releases/tag/v0.2.0

@sm43
Copy link
Member Author

sm43 commented Jun 18, 2021

/retest

@wlynch
Copy link
Member

wlynch commented Jun 30, 2021

@wlynch the release.yaml for v0.2.0 of Results seems to have results.tekton.dev/release: devel and version seems to be missing. Could you please check once?
https://github.com/tektoncd/results/releases/tag/v0.2.0

tektoncd/results#115 to track.

Beyond the recently opened issues, nothing else is jumping out at me, so LGTM.

/lgtm

@tekton-robot
Copy link
Contributor

@wlynch: changing LGTM is restricted to collaborators

In response to this:

@wlynch the release.yaml for v0.2.0 of Results seems to have results.tekton.dev/release: devel and version seems to be missing. Could you please check once?
https://github.com/tektoncd/results/releases/tag/v0.2.0

tektoncd/results#115 to track.

Beyond the recently opened issues, nothing else is jumping out at me, so LGTM.

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2021
SM43 added 2 commits July 5, 2021 09:49
This adds a new CRD TektonResult to install and manage
Tekton Results component only for Kubernetes Platform.

Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 5, 2021
@tekton-robot
Copy link
Contributor

The following is the coverage report on the affected files.
Say /test pull-tekton-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/operator/v1alpha1/tektonresult_lifecycle.go Do not exist 76.5%
pkg/apis/operator/v1alpha1/tektonresult_types.go Do not exist 0.0%
pkg/reconciler/common/install.go 65.5% 62.5% -3.0
pkg/reconciler/common/releases.go 64.6% 63.6% -1.0
pkg/reconciler/common/transformers.go 64.5% 67.6% 3.2

@vdemeester
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 5, 2021
@tekton-robot tekton-robot merged commit 63c988b into tektoncd:main Jul 5, 2021
@sm43 sm43 deleted the add-tekton-results branch July 7, 2021 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add "Tekton Results API" Addon
6 participants