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

Adjust argument slice size in builder #164

Conversation

TomSweeneyRedHat
Copy link
Contributor

@TomSweeneyRedHat TomSweeneyRedHat commented Jun 1, 2020

A recent update to the argument handling didn't increase
the argument slice size to take into account the values
from b.Args() that were now being added. This created
unpredictable results.

After addressing a comment from @nalind, I realized that
the value from b.Arguments should be used in the steps
as it keeps the ordering of when the ARGS and ENV were
defined in the Dockerfile. Changed makeUserArgs
in internals.go to take two variables rather than just
a builder.

Addresses the Buildah bug: containers/buildah#2345

Signed-off-by: TomSweeneyRedHat [email protected]

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2020
@@ -332,7 +332,7 @@ func ParseFile(path string) (*parser.Node, error) {

// Step creates a new step from the current state.
func (b *Builder) Step() *Step {
dst := make([]string, len(b.Env)+len(b.RunConfig.Env))
dst := make([]string, len(b.Env)+len(b.RunConfig.Env)+len(b.Arguments()))
copy(dst, makeUserArgs(b))
dst = append(dst, b.RunConfig.Env...)
Copy link
Member

Choose a reason for hiding this comment

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

Some of the values from b.Args won't be used if they conflict with environment values, so the size count being used here for allocating dst can be off, and if it is, it can leave a gap with empty strings in the final slice.

A recent update to the argument handling didn't increase
the argument slice to take into the account the values
from b.Args() that were now being added.  The created
unpredicatble results.

After addressing a comment from @nalind, I realized that
the value from b.Arguments should be used in the steps
as it keeps the ordering of when the ARGS and ENV were
defined in the Dockerfile.  Changed makeUserArgs
in internals.go to take two variables rather than just
a builder.

Adddresses the Buildah bug: containers/buildah#2345

Signed-off-by: TomSweeneyRedHat <[email protected]>
@TomSweeneyRedHat TomSweeneyRedHat force-pushed the dev/tsweeney/fixslicesize branch from 68ded6b to 3ccf1b9 Compare June 3, 2020 23:49
@rhatdan
Copy link
Contributor

rhatdan commented Jun 6, 2020

LGTM

@TomSweeneyRedHat
Copy link
Contributor Author

@nalind PTAL

@nalind
Copy link
Member

nalind commented Jun 10, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 10, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nalind, TomSweeneyRedHat

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 [TomSweeneyRedHat,nalind]

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

@openshift-merge-robot openshift-merge-robot merged commit 07ab54d into openshift:master Jun 10, 2020
@TomSweeneyRedHat TomSweeneyRedHat deleted the dev/tsweeney/fixslicesize branch June 11, 2020 17:34
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants