Skip to content

fix(hermeticity): do not leak PATH to actions#28517

Merged
keith merged 2 commits into
envoyproxy:mainfrom
alexeagle:patch-1
Aug 10, 2023
Merged

fix(hermeticity): do not leak PATH to actions#28517
keith merged 2 commits into
envoyproxy:mainfrom
alexeagle:patch-1

Conversation

@alexeagle
Copy link
Copy Markdown

I have a client who vendored this file into their Bazel workspace, and it caused every new machine to have a non-incremental build with all cache misses, due to the CI system (CircleCI in that case) injecting an unstable value into the PATH (/tmp/circleci-launch-agent150557664/circleci-agent/1.0.193225-b3de599b/linux/amd64)

Commit Message: Above
Additional Description:
Risk Level: Unsure
Testing: Not familiar with this project, so whatever tests you normally run? The client says this change is green for them.
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

I have a client who vendored this file into their Bazel workspace, and it caused every new machine to have a non-incremental build with all cache misses, due to the CI system (CircleCI in that case) injecting an unstable value into the PATH (`/tmp/circleci-launch-agent150557664/circleci-agent/1.0.193225-b3de599b/linux/amd64`)

Signed-off-by: Alex Eagle <alex@aspect.dev>
@repokitteh-read-only
Copy link
Copy Markdown

Hi @alexeagle, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #28517 was opened by alexeagle.

see: more, trace.

phlax
phlax previously approved these changes Jul 20, 2023
Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

lgtm, thanks @alexeagle

cc @keith

@keith
Copy link
Copy Markdown
Member

keith commented Jul 20, 2023

pretty sure having this passthrough is required for most folks. maybe CI will show that. #24408 would be the long term solution if so

@phlax
Copy link
Copy Markdown
Member

phlax commented Jul 20, 2023

@keith
Copy link
Copy Markdown
Member

keith commented Jul 20, 2023

yea i don't think there's a standard path we can rely on today because the instructions have folks install clang somewhere random

@keith
Copy link
Copy Markdown
Member

keith commented Jul 20, 2023

as a short term workaround your folks could override this value and pass whatever hardcoded path would work for you

@phlax
Copy link
Copy Markdown
Member

phlax commented Jul 20, 2023

can we update the docs?

from a general pov it would be better not to set these as defaults - sort of against how you would expect bazel to work i think

but yep we will probably either need to update docs somewhere or handle support tickets

@phlax
Copy link
Copy Markdown
Member

phlax commented Jul 21, 2023

re win error - i think this PR has helpfully weeded out a non-hermetic build issue with luajit

the fail is in our patch here

+#!/usr/bin/env python3

which i think should be using a py_binary in some way to use the hermetic python bin and not depend on the system python

not sure why only windows fails, i guess its not failing elsewhere due to non-hermeticity - i think the path must be the same on the linux-side so no caches were blown

given that windows only runs a subset of build/tests we might want to run this without cache to weed out any other issues

@alexeagle
Copy link
Copy Markdown
Author

I've suggested the client just comment out this line in their copy of this file. I'd be okay resolving this with a documentation change instead, but then few people read docs, so I'd guess the problem will continue.

For your CI, of course you could use a platform-specific bazelrc setting so this only happens on Windows - but I think @keith is pointing out that a green CI run here may not be enough?

Signed-off-by: Alex Eagle <alex@aspect.dev>
@phlax
Copy link
Copy Markdown
Member

phlax commented Jul 21, 2023

I'd be okay resolving this with a documentation change instead, but then few people read docs, so I'd guess the problem will continue.

i more meant that if we remove this by default we should add to build docs that for host builds you may need to add this (or i guess improve the build somehow to look in expected places)

mho is that this is a welcome change, but im aware that not all agree on that so would prefer to find a consensus

re readding for windows - i think that is fine as a workaround in this case, if that is the only issue but would prefer medium term to make sure nothing is using non-hermetic system tools unless absolutely necessary

I think @keith is pointing out that a green CI run here may not be enough?

yeah, i came to the same conclusion - i think we can test this with --action_env=SOME=cache-busting-variable to force a non-cached run

@phlax
Copy link
Copy Markdown
Member

phlax commented Jul 21, 2023

i was wondering why this went through CI so quickly

i think it gets added again here:

echo "# Generated file, do not edit. If you want to disable clang, just delete this file.
build:clang --action_env='PATH=${PATH}' --host_action_env='PATH=${PATH}'
build:clang --action_env=CC=clang --host_action_env=CC=clang
build:clang --action_env=CXX=clang++ --host_action_env=CXX=clang++
build:clang --action_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config' --host_action_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config'
build:clang --repo_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config'
build:clang --linkopt='-L$(llvm-config --libdir)'
build:clang --linkopt='-Wl,-rpath,$(llvm-config --libdir)'

i guess this is not an issue for using bazel directly but for using the envoy code paths i think this would need to change also

@keith
Copy link
Copy Markdown
Member

keith commented Jul 24, 2023

hrm yea i guess ideally we could wrap this without having to generate config files with these contents at various paths. I still think the path of least resistance would be to make the vendored llvm toolchain work and then allow a --config=hosttools or something for folks who didn't want that

@htuch
Copy link
Copy Markdown
Member

htuch commented Aug 4, 2023

@phlax @keith friendly ping on next steps for this PR.

@phlax
Copy link
Copy Markdown
Member

phlax commented Aug 4, 2023

next steps for this PR.

i think testing properly without PATH in the action_env - ie removing from setup_clang.sh would give us a better idea of what breaks

I still think the path of least resistance would be to make the vendored llvm toolchain work

i would agree, but not sure what we need to make it happen - iirc there was gcc issue/s that needed to be ironed out, not sure what else

in terms of Envoy CI we are using the RBE toolchain/s for ~everything - i have a local container sans llvm etc and it mostly works (when using RBE)

@keith
Copy link
Copy Markdown
Member

keith commented Aug 4, 2023

i would agree, but not sure what we need to make it happen - iirc there was gcc issue/s that needed to be ironed out, not sure what else

Yea I think we'd need a way to disable that and use the default toolchain, but I think we could do that with a custom config

@KBaichoo
Copy link
Copy Markdown
Contributor

KBaichoo commented Aug 8, 2023

@phlax @keith friendly ping on this PR.

@keith
Copy link
Copy Markdown
Member

keith commented Aug 10, 2023

I think we could try to merge this as-is now, where PATH only applies to Windows, but given the instructions we provide for building it's possible this breaks folks who install clang to non-standard directories. But we can try and see how it goes

@keith
Copy link
Copy Markdown
Member

keith commented Aug 10, 2023

/retest

Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

lgtm, thanks @alexeagle

i will look after at potentially removing path from setup clang also - at least to see what effect it has

@keith keith merged commit 6787b85 into envoyproxy:main Aug 10, 2023
jbohanon pushed a commit to solo-io/envoy-fork that referenced this pull request Aug 11, 2023
I have a client who vendored this file into their Bazel workspace, and it caused every new machine to have a non-incremental build with all cache misses, due to the CI system (CircleCI in that case) injecting an unstable value into the PATH (`/tmp/circleci-launch-agent150557664/circleci-agent/1.0.193225-b3de599b/linux/amd64`)

Signed-off-by: Alex Eagle <alex@aspect.dev>
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.

5 participants