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

Merge place-tools and step-init together #4826

Merged

Conversation

vdemeester
Copy link
Member

Changes

This is part of an effort to reduce the number of init container to
the minimum. Both place-tools and step-init are using the same image
and can be easily and safely merged together.

This has few benefits, but the main one is that it reduces the number
of container to run, and thus doesn't reduce the max size of a Result.

Signed-off-by: Andrew Bayer andrew.bayer@gmail.com
Signed-off-by: Vincent Demeester vdemeest@redhat.com

/kind bug

/cc @imjasonh @dibyom @lbernick @abayer

This is the first part of a bigger refactoring aiming to tackle #4808

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

place-tools and step-init init containers are merged together to reduce the number of container in each `Task`'s Pod.

@vdemeester vdemeester added this to the Pipelines v0.36 milestone May 3, 2022
@tekton-robot tekton-robot requested a review from abayer May 3, 2022 16:11
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 3, 2022
@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 3, 2022
@vdemeester
Copy link
Member Author

Note: This is not removing the cp subcommand, nor the step-init subcommands, as they might be used independently of the init containers by users. If we feel we should remove then, we will need to go through a deprecation notice, …

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/subcommands/init.go Do not exist 66.7%
cmd/entrypoint/subcommands/subcommands.go 73.7% 56.0% -17.7

Copy link
Member

@imjasonh imjasonh 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 good so far, thanks for doing this!

case InitCommand:
// If invoked in "init mode" (`entrypoint init <src> <dst> [<step-name>]`),
// it will copy the src path to the dst path (like CopyCommand), and initialize
// the /tekton/steps forder (like StepInitCommand)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// the /tekton/steps forder (like StepInitCommand)
// the /tekton/steps folder (like StepInitCommand)

@abayer
Copy link
Contributor

abayer commented May 4, 2022

/retest

@vdemeester vdemeester force-pushed the reduce-initcontainer-numbers branch from 13f0400 to 6c34216 Compare May 4, 2022 09:09
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/subcommands/init.go Do not exist 66.7%
cmd/entrypoint/subcommands/subcommands.go 73.7% 56.0% -17.7

@vdemeester vdemeester force-pushed the reduce-initcontainer-numbers branch from 6c34216 to 6db845e Compare May 4, 2022 13:12
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/subcommands/init.go Do not exist 66.7%
cmd/entrypoint/subcommands/subcommands.go 73.7% 56.0% -17.7

@vdemeester vdemeester force-pushed the reduce-initcontainer-numbers branch from 6db845e to 2b67426 Compare May 4, 2022 13:15
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/subcommands/init.go Do not exist 66.7%
cmd/entrypoint/subcommands/subcommands.go 73.7% 56.0% -17.7

@abayer
Copy link
Contributor

abayer commented May 4, 2022

/retest

@vdemeester vdemeester force-pushed the reduce-initcontainer-numbers branch from 2b67426 to 62f1338 Compare May 4, 2022 14:30
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/subcommands/init.go Do not exist 66.7%
cmd/entrypoint/subcommands/subcommands.go 73.7% 56.0% -17.7

pkg/pod/pod.go Outdated
// Initialize any workingDirs under /workspace.
if workingDirInit := workingDirInit(b.Images.WorkingDirInitImage, stepContainers); workingDirInit != nil {
initContainers = append(initContainers, *workingDirInit)
}

// place the entrypoint first in case other init containers rely on its
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we always want the entrypoint first, why not just do this before we add anything else to initContainers?

pkg/pod/pod.go Outdated
func tektonDirInit(image string, steps []v1beta1.Step) corev1.Container {
cmd := make([]string, 0, len(steps)+2)
cmd = append(cmd, "/ko-app/entrypoint", "step-init")
// prepareInitContainers generate a few init containers based of a set of command (in images) and volumes to run
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be prepareInitContainer generates an init container... rather than the plural containers there now. =)

// Rewrite steps with entrypoint binary. Append the entrypoint init
// container to place the entrypoint binary. Also add timeout flags
// to entrypoint binary.
prepareInitContainer := corev1.Container{
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rename this to just initContainer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed to entrypointInitContainer 🙃

This is part of an effort to reduce the number of init container to
the minimum. Both place-tools and step-init are using the same image
and can be easily and safely merged together.

This has few benefits, but the main one is that it reduces the number
of container to run, and thus doesn't reduce the max size of a Result.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the reduce-initcontainer-numbers branch from 62f1338 to f5a7fdf Compare May 4, 2022 15:38
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/subcommands/init.go Do not exist 66.7%
cmd/entrypoint/subcommands/subcommands.go 73.7% 56.0% -17.7

@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-build-tests

@abayer
Copy link
Contributor

abayer commented May 4, 2022

/retest

@abayer
Copy link
Contributor

abayer commented May 4, 2022

/lgtm

Cutting down on the number of init containers is great - looking forward to seeing more of them get folded in!

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 4, 2022
Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Really nice! Ideally we will have a single init container eventually?
/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli

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 May 4, 2022
@abayer
Copy link
Contributor

abayer commented May 4, 2022

@afrittoli That's the goal. =) @vdemeester and I chatted about this and merging them together one by one seemed the best approach!

@lbernick
Copy link
Member

lbernick commented May 4, 2022

#4519 is relevant

@tekton-robot tekton-robot merged commit 7059cfd into tektoncd:main May 4, 2022
@vdemeester
Copy link
Member Author

Really nice! Ideally we will have a single init container eventually?
/approve

Yes the goal is to reduce it to one 😇

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. kind/bug Categorizes issue or PR as related to a bug. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants