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

Simplify and split apart MakePod #1605

Open
imjasonh opened this issue Nov 22, 2019 · 9 comments · Fixed by #1655
Open

Simplify and split apart MakePod #1605

imjasonh opened this issue Nov 22, 2019 · 9 comments · Fixed by #1655
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@imjasonh
Copy link
Member

imjasonh commented Nov 22, 2019

Related to #1519

Today, the conversion between TaskRun to a Pod jumbled together (mostly) inside MakePod, which is responsible for lots of different things. This makes it hard to understand, hard to test in isolation, and hard to make fixes and improvements.

What MakePod does

(roughly in the ideal order)

Applies stepTemplate

  • FIX: This should ignore stepTemplate.command and .args if the step specifies .script
  • FIX: stepTemplate shouldn't apply to sidecars, only steps.

Convert Steps with script to Containers with command

Resolve image ENTRYPOINT from remote registry if the step doesnt' specify a command

Rewrite step command + args to inject our entrypoint binary

Initialize credentials

  • Adds an init container, creds-init, if annotated creds are found in the service account's secrets
  • Adds /var/secrets/... for each secret
  • Requires /builder/home volume and (I think) HOME env var
  • Split out in Move creds-init to pkg/pod #1599

mkdir working dirs under /workspace

Apply resource requests/limits

  • Find the maximum request per resource per step
  • Apply that request to step 0
  • Set all other steps' requests to 0, and limits to the max request.

Other minor operations

  • Set workingDir to /workspace if the user didn't specify
  • Set the container name to step-%s (step name), or to step-unnamed-%d (step index) if not specified

After these changes

@vdemeester
Copy link
Member

@imjasonh I wasn't sure if what is listed is what MakePod does currently (and that should change somehow) or what it should do ?

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 25, 2019
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
- 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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
- 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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
- 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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
- 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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
- 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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
- 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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 25, 2019
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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 26, 2019
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.
imjasonh added a commit to imjasonh/pipeline that referenced this issue Nov 26, 2019
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 pushed a commit that referenced this issue Nov 26, 2019
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.
@imjasonh
Copy link
Member Author

This lists what MakePod does, in the ~ideal order. Before these changes things happened in jumbled order because it mostly happened in one huge wall of text. Afterwards I'd like to have one MakePod method that just calls N smaller isolated methods with clear goals and tests.

@afrittoli
Copy link
Member

Today the stepTemplate is also applied to injected steps like those from PipelineResources.
I think that may be ok, but we should probably document it.

@imjasonh
Copy link
Member Author

imjasonh commented Dec 2, 2019

Yeah I think that's expected behavior -- at least, I think that was the behavior before I started reorganizing MakePod -- but I agree it should be better documented.

@imjasonh
Copy link
Member Author

imjasonh commented Dec 2, 2019

After #1655 I think I'm comfortable declaring victory on this.

We might want to move PipelineResource interactions into MakePod as well (prepending/appending steps for resources, applying parameter replacements), but at least those are already fairly well isolated into their own methods with clear tests.

@lbernick
Copy link
Member

lbernick commented Mar 8, 2022

/reopen

There are still a few TODOs associated with this issue-- this came up during review of #4598.

It's not clear where mergeSteps should live; the TODO here would result in a circular import as this functionality is used in API validation which is a bit weird. @wlynch suggested moving into an internal package.

@tekton-robot tekton-robot reopened this Mar 8, 2022
@tekton-robot
Copy link
Collaborator

@lbernick: Reopened this issue.

In response to this:

/reopen

There are still a few TODOs associated with this issue-- this came up during review of #4598.

It's not clear where mergeSteps should live; the TODO here would result in a circular import as this functionality is used in API validation which is a bit weird. @wlynch suggested moving into an internal package.

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
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 6, 2022
@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 6, 2022
@lbernick lbernick added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jul 26, 2022
@afrittoli afrittoli added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

5 participants