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

Split out entrypoint resolution and injection, and script conversion #1616

Merged
merged 1 commit into from
Nov 26, 2019

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Nov 25, 2019

Split out entrypoint resolution and injection, and script conversion

This is the next and largest step of the effort to simplify and separate
MakePod out into digestible chunks (#1605)

Behavioral changes

  • Script->Command conversion now happens before entrypoint rewriting,
    rather than converting the rewritten entrypoint args.
  • Image name->digest lookups are cached locally while resolving a single
    TaskRun's steps (with test!)
  • Entrypoint lookups also update the step's digest. This was a race
    before: if an image was pushed between resolution and pod start, the
    resolved command might be out-of-date.

Some redundant test cases have been removed from taskrun_test.go -- this
file should test only behavior of taskrun.go, which is now smaller.

Unit tests for individual transformation behavior has been moved into
individual test files in pkg/pod, with some integration tests in
pod_test.go -- some of these could likely be removed as well, if we feel
like it.

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.

/assign @sbwsg

@tekton-robot tekton-robot assigned ghost Nov 25, 2019
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Nov 25, 2019
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 25, 2019
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 93.8% 6.5
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 93.8% 6.5
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

pkg/pod/entrypoint.go Outdated Show resolved Hide resolved
pkg/pod/entrypoint.go Outdated Show resolved Hide resolved
pkg/reconciler/taskrun/controller.go Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Nov 25, 2019

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 25, 2019
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 25, 2019
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.7% 5.4
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

In general I very much ❤️ this!!! +10000

I'm a bit confused by all these "defensive copies" but mostly b/c I don't know what they are 😅

Might I also add: beautiful commit message!!

Lastly: to tell you the truth I looked in a lot of detail in the first 1/2 of the code and a lot less at the 2nd half so that is what it is 😅

/approve

pkg/pod/entrypoint.go Show resolved Hide resolved
pkg/pod/entrypoint.go Outdated Show resolved Hide resolved
pkg/pod/entrypoint_lookup.go Outdated Show resolved Hide resolved
pkg/pod/entrypoint.go Show resolved Hide resolved
pkg/pod/entrypoint_test.go Show resolved Hide resolved
pkg/pod/entrypoint.go Show resolved Hide resolved
pkg/pod/entrypoint.go Outdated Show resolved Hide resolved
pkg/pod/entrypoint_lookup.go Show resolved Hide resolved
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish

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 Nov 25, 2019
@imjasonh imjasonh force-pushed the entrypoint-big-one branch 2 times, most recently from d9522af to c0545fe Compare November 25, 2019 21:24
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.7% 5.4
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.7% 5.4
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.8% 5.5
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.8% 5.5
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

This is the next and largest step of the effort to simplify and separate
MakePod out into digestible chunks (tektoncd#1605)

Behavioral changes:
- Script->Command conversion now happens before entrypoint rewriting,
  rather than converting the rewritten entrypoint args.
- Image name->digest lookups are cached locally while resolving a single
  TaskRun's steps (with test!)
- Entrypoint lookups also update the step's digest. This was a race
  before: if an image was pushed between resolution and pod start, the
  resolved command might be out-of-date.

Some redundant test cases have been removed from taskrun_test.go -- this
file should test only behavior of taskrun.go, which is now smaller.

Unit tests for individual transformation behavior has been moved into
individual test files in pkg/pod, with some integration tests in
pod_test.go -- some of these could likely be removed as well, if we feel
like it.
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.9% 5.6
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/taskrun/controller.go 100.0% 96.2% -3.8
pkg/reconciler/taskrun/resources/pod.go 87.3% 92.9% 5.6
pkg/reconciler/taskrun/taskrun.go 73.1% 74.9% 1.8
test/builder/pod.go 79.2% 77.1% -2.1

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

This looks gooooood 😻
/lgtm

return nil
}

func IsContainerStep(name string) bool { return strings.HasPrefix(name, StepPrefix) }
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we have docstring here too (just for godoc.org 😛 🤗 )

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 good point. I'll make sure to have doc strings everywhere before calling this done.

}
e.lru.Add(digest.String(), ep) // Populate the cache.

d, err = name.NewDigest(imageName+"@"+digest.String(), name.WeakValidation)
Copy link
Member

Choose a reason for hiding this comment

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

nit: I wonder if we could use name:tag@digest notation here (thinking outloud, ignore me 👼)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not really sure what it would buy us, this string is never surfaced directly to users.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't it surfaced in the final pod spec ? (anyway it's really not that big of a deal)

Copy link
Member Author

Choose a reason for hiding this comment

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

It is, but that pod spec is intended to be an implementation detail, and we shouldn't expect users to see it. The user's specified tag will be shown in the TaskRun's .spec, and the resolved digest will be shown in the TaskRun's .status, that's all that really matters.

Args: []string{"-c", ""},
VolumeMounts: []corev1.VolumeMount{scriptsVolumeMount},
// Zero out non-max resource requests.
// TODO(jasonhall): Split this out so it's more easily testable.
Copy link
Member

Choose a reason for hiding this comment

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

nit: TODO(#1605) 😝

@@ -23,7 +23,7 @@ import (

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources"
podconvert "github.com/tektoncd/pipeline/pkg/pod"
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for naming it podconvert instead of pod ?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a variable called pod below that causes problems. When this is all done I hope to avoid this named import.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 26, 2019
@tekton-robot tekton-robot merged commit e228f11 into tektoncd:master Nov 26, 2019
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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit 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.

5 participants