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

fix(ci): convert ci is failing due to perms #439

Merged
merged 3 commits into from
Mar 16, 2023

Conversation

rchincha
Copy link
Contributor

@rchincha rchincha commented Mar 8, 2023

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rchincha rchincha requested review from smoser and hallyn as code owners March 8, 2023 07:07
@rchincha
Copy link
Contributor Author

rchincha commented Mar 8, 2023

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #439 (dc05c16) into main (8e267fc) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

❗ Current head dc05c16 differs from pull request most recent head 69f6e16. Consider uploading reports for the commit 69f6e16 to get more accurate results

@@            Coverage Diff             @@
##             main     #439      +/-   ##
==========================================
- Coverage   11.87%   11.86%   -0.01%     
==========================================
  Files          45       45              
  Lines        5551     5554       +3     
==========================================
  Hits          659      659              
- Misses       4775     4778       +3     
  Partials      117      117              
Impacted Files Coverage Δ
pkg/stacker/convert.go 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@smoser
Copy link
Contributor

smoser commented Mar 8, 2023

If I understand this correctly this comes from tests/convert.bats which has VOLUME /out and then 'mkdir -p /out'.
Would it be an option to just change that to go to a different directory?

    cat > Dockerfile <<EOF
FROM alpine:3.16
VOLUME $HOME/out
...

It just seems odd to attempt that as an unprivileged user is not likely to be able to create and use a directory in /

@rchincha
Copy link
Contributor Author

If I understand this correctly this comes from tests/convert.bats which has VOLUME /out and then 'mkdir -p /out'. Would it be an option to just change that to go to a different directory?

    cat > Dockerfile <<EOF
FROM alpine:3.16
VOLUME $HOME/out
...

It just seems odd to attempt that as an unprivileged user is not likely to be able to create and use a directory in /

We could, but stacker convert would have no way to know what docker -v <outside-container-volume>:<inside-mount> the outside-container-volume would be. This is just so that we show we can be fully automated. But one is of course welcome to mangle the output of stacker convert and then mangle.

@smoser
Copy link
Contributor

smoser commented Mar 10, 2023

If I understand this correctly this comes from tests/convert.bats which has VOLUME /out and then 'mkdir -p /out'. Would it be an option to just change that to go to a different directory?

    cat > Dockerfile <<EOF
FROM alpine:3.16
VOLUME $HOME/out
...

It just seems odd to attempt that as an unprivileged user is not likely to be able to create and use a directory in /

We could, but stacker convert would have no way to know what docker -v <outside-container-volume>:<inside-mount> the outside-container-volume would be. This is just so that we show we can be fully automated. But one is of course welcome to mangle the output of stacker convert and then mangle.

just give an error:

Docker file 'Dockerfile'  not supported.  The provided Dockerfile contains a VOLUME entry for '/out'.
/out is not writable by the current user.  Please modify the Dockerfile to contain a writable path for
the given VOLUME.

Currently, docker vols are mapped 1:1 between host and container, which
is probably not we want. Now, they will be exposed as substituted vars.

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
Args substitution can happen via "--substitute" and "--substitute-file",
so behavior can become unpredictable.

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
Copy link
Contributor

@smoser smoser left a comment

Choose a reason for hiding this comment

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

I think this is really good. Thanks.

The only comment i have is that I would suggest processing command line arguments in order rather than always giving precedence to '--substitute' over contents of '--substitute-file'.

That allows the caller to get whatever behavior they want (perhaps they just want to append a '--substitute-file' onto an existing command line with --substitute and have it override).

its not a big thing, due to the "static" nature of the substitute-file, so i'll approve but you're welcome to change that too.

@rchincha rchincha merged commit 3baba64 into project-stacker:main Mar 16, 2023
hallyn added a commit to hallyn/stacker-1 that referenced this pull request Jan 5, 2024
The following:

  stacker build --substitute a=b,c

used to work, until commit 3baba64:

  fix(ci): convert ci is failing due to perms (project-stacker#439)

This squashed PR included 'chore(go.mod): update cli to
github.com/urfave/cli/v2'.  Switching from urfave/cli/v1 to v2 changes
string slice flag behavior to automatically split on commas.

Luckily there is an app.DisableSliceFlagSeparator flag we can set to
tell it not to do that.  Set that flag.  And add a test for this.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
hallyn added a commit to hallyn/stacker-1 that referenced this pull request Jan 6, 2024
The following:

  stacker build --substitute a=b,c

used to work, until commit 3baba64:

  fix(ci): convert ci is failing due to perms (project-stacker#439)

This squashed PR included 'chore(go.mod): update cli to
github.com/urfave/cli/v2'.  Switching from urfave/cli/v1 to v2 changes
string slice flag behavior to automatically split on commas.

Luckily there is an app.DisableSliceFlagSeparator flag we can set to
tell it not to do that.  Set that flag.  And add a test for this.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
hallyn added a commit that referenced this pull request Jan 8, 2024
The following:

  stacker build --substitute a=b,c

used to work, until commit 3baba64:

  fix(ci): convert ci is failing due to perms (#439)

This squashed PR included 'chore(go.mod): update cli to
github.com/urfave/cli/v2'.  Switching from urfave/cli/v1 to v2 changes
string slice flag behavior to automatically split on commas.

Luckily there is an app.DisableSliceFlagSeparator flag we can set to
tell it not to do that.  Set that flag.  And add a test for this.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants