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

Remove runtime dependency on Build controller #326

Merged
merged 14 commits into from
Dec 12, 2018

Conversation

imjasonh
Copy link
Member

With this change, TaskRuns are translated to Builds in the TaskRun controller (as today), then translated from Builds to Pods using the same vendored code from the knative/build repo that the Build controller uses.

The TaskRun controller then watches Pods for updates, instead of Builds, and when it sees a Pod update, it translates that PodStatus to a BuildStatus (as the Build controller does today), then translates the BuildStatus to a TaskRunStatus (as the Pod controller does today).

As a result, there is no runtime dependency on the Build controller, and no Build CRD resources are created at any point.

This is Phase 1 below:
taskrun -_ build phases 2

As a next step, we can remove the code dependency on the Build type, and the duplicate type translation, by simply translating TaskRuns directly to Pods, and PodStatus directly to TaskRunStatus.

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 11, 2018
Copy link
Contributor

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

Great set of changes 👍

Heads up about changes in output design PR. Taskrun invokes input_resouces and output_resources functions to add steps before and after build steps like a wrapper. If that PR gets merged then portion of code in taskrun will have conflicts

hack/release.sh Outdated
run_validation_tests ./test/presubmit-tests.sh

# Build the release

banner "Building the release"

# Location of the base image for creds-init and git images
readonly BUILD_BASE_GCR="${KO_DOCKER_REPO}/github.com/knative/build-pipeline/build-base"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we renameBUILD_BASE_GCR to PIPELINE_BASE_GCR ?

@@ -175,10 +175,10 @@ type TaskRunList struct {
}

// GetBuildRef for task
func (tr *TaskRun) GetBuildRef() corev1.ObjectReference {
func (tr *TaskRun) GetBuildPodRef() corev1.ObjectReference {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: comment for the function is referring to old function name

// Rewrite the pod's OwnerRef to point the TaskRun, instead of a
// non-existent build.
pod.OwnerReferences = []metav1.OwnerReference{
*metav1.NewControllerRef(tr, schema.GroupVersionKind{
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a variable called groupVersionKind which hold this value so this might become simple one liner

*metav1.NewControllerRef(tr, groupVersionKind)

@imjasonh imjasonh changed the title [WIP] Remove runtime dependency on Build controller Remove runtime dependency on Build controller Dec 12, 2018
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 12, 2018
@imjasonh
Copy link
Member Author

/test pull-knative-build-pipeline-go-coverage

Copy link
Contributor

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

Looks good to me. I will wait if somebody else wants to review.

import "fmt"

func main() {
fmt.Println("Build successful")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
In output PR, I am introducing shell based image. We could consider using that image and pass arguments echo Build Successful instead of maintaining nop image

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe. Having this image based on distroless/base means that the image doesn't have a shell at all, which reduces its size and attack surface. I'm not opposed if this becomes difficult to maintain for some reason, but we should bias toward minimal images where possible.

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ImJasonH, shashwathi

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:
  • OWNERS [ImJasonH,shashwathi]

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

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-build-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/credentials/dockercreds/creds.go Do not exist 89.1%
pkg/credentials/gitcreds/basic.go Do not exist 88.2%
pkg/credentials/gitcreds/creds.go Do not exist 88.9%
pkg/credentials/gitcreds/ssh.go Do not exist 86.4%
pkg/reconciler/v1alpha1/taskrun/resources/pod.go Do not exist 88.4%

@nader-ziada
Copy link
Member

Great PR, this will be a huge step for moving the pipeline crd project forward 👍🚀

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 12, 2018
@imjasonh imjasonh merged commit 9c46c8c into tektoncd:master Dec 12, 2018
chmouel pushed a commit to chmouel/tektoncd-pipeline that referenced this pull request Mar 26, 2020
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. 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.

6 participants