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

ci: force install/link bazelisk package in macos dependency setup #10357

Merged
merged 10 commits into from
Mar 13, 2020
Merged

ci: force install/link bazelisk package in macos dependency setup #10357

merged 10 commits into from
Mar 13, 2020

Conversation

sunjayBhatia
Copy link
Member

@sunjayBhatia sunjayBhatia commented Mar 12, 2020

Description: Latest mac os images have bazel pre-installed so force install bazelisk and link with overwrite to allow install to succeed
Risk Level: Low
Testing: N/A
Docs Changes: N/A
Release Notes: N/A

sunjayBhatia and others added 2 commits March 12, 2020 10:45
Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
@sunjayBhatia
Copy link
Member Author

sunjayBhatia commented Mar 12, 2020

According to this PR that is pending merge, this is the set of tools installed in the latest image we are using: actions/runner-images#538 (notice bazel, bazelisk, and cmake are already installed, the former two likely not via the same homebrew tap we are)

@sunjayBhatia
Copy link
Member Author

sunjayBhatia commented Mar 12, 2020

Another solution is to just take whatever bazelisk comes with the image, thoughts? (though it is not linked to bazel on the PATH I believe so this might be more complicated)

sunjayBhatia and others added 2 commits March 12, 2020 11:15
Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
then
echo "Failed to install $1"
brew install "$1"
if ! brew link --overwrite "$1"; then
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary if we are unlinking below?

Copy link
Member Author

Choose a reason for hiding this comment

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

this overwrite was added in order to overwrite existing bazelisk symlinks that homebrew complained about (see the output here before the forceful link: https://dev.azure.com/cncf/envoy/_build/results?buildId=33967&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=7d499b5d-1d92-5096-7919-3c7f8065da78&l=619), this change could potentially actually supercede the unlink of bazel so this could be the only change needed (will try it out)

Copy link
Member Author

Choose a reason for hiding this comment

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

So, both are required, see this build: https://dev.azure.com/cncf/envoy/_build/results?buildId=33982&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=7d499b5d-1d92-5096-7919-3c7f8065da78&l=619

We could do a brew install --force on all installs to maybe not have to unlink bazel, though that may have unintended consequences?

Copy link
Member Author

Choose a reason for hiding this comment

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

it should work, i'll leave it with the --force unless theres any objections

Copy link
Member

Choose a reason for hiding this comment

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

@sunjayBhatia sorry I didn't catch that bazelisk was already installed. Per your comment above, why can't we just drop all the bazel related installs in this file?

Copy link
Member Author

@sunjayBhatia sunjayBhatia Mar 12, 2020

Choose a reason for hiding this comment

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

@junr03 We totally could, but I believe brew install bazelisk downloads something from somewhere different than brew install bazelbuild/tap/bazelisk (which is possibly why our script tries to install bazelbuild/tap/bazelisk in the first place, since there is a check if the packages we want are already installed). If we're cool with staying with what is in the CI image by default that works. However, I don't think if we do that the symlink for bazel will actually be the bazelisk executable, so we would need to do some manual overriding of symlinks in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could also ask the maintainers of the image to install bazelisk (and bazel) via the expected upstream tap so this isn't an issue for us as well, seems like at least bazelisk is not installed in the image via bazelbuild/tap/bazelisk

Copy link
Member

Choose a reason for hiding this comment

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

However, I don't think if we do that the symlink for bazel will actually be the bazelisk executable.

I see, and we would end up using the version of bazel installed in the image instead of the one we would like via bazelisk and .bazelversion.

My overall opinion for this PR is to take bazelisk install out of the normal flow and do what we need to do for bazel/bazelisk separately from the other dep installs. I just don't think we should change how we install all the deps. Now whether this means making sure that bazel is correctly symlinked to bazelisk, or using brew, up to you.

wrowe and others added 2 commits March 12, 2020 13:56
Hopefully the bazelisk link --overwrite should take care of it

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
So bazelisk can overwrite pre-installed bazel

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
@sunjayBhatia sunjayBhatia changed the title ci: Unlink bazel so we can install bazelisk ci: force install/link homebrew packages so we can install bazelisk Mar 12, 2020
sunjayBhatia and others added 2 commits March 12, 2020 16:13
- use the bazelisk basic package that is installed already, the check to see if
  it is installed should always be true so this is like an assertion that bazel
  is present
- unlink bazel
- make a link ourselves linking bazelisk to bazel

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
just get the path and assert it exists

Signed-off-by: Sunjay Bhatia <[email protected]>
@lizan
Copy link
Member

lizan commented Mar 12, 2020

/azp run envoy-macos

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@lizan
Copy link
Member

lizan commented Mar 12, 2020

/azp run envoy-macos

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sunjayBhatia sunjayBhatia changed the title ci: force install/link homebrew packages so we can install bazelisk ci: force install/link bazelisk package in macos dependency setup Mar 13, 2020
@danzh2010
Copy link
Contributor

@sunjayBhatia
Copy link
Member Author

sunjayBhatia commented Mar 13, 2020

Is this PR causing the MacOS failure here: https://dev.azure.com/cncf/envoy/_build/results?buildId=34096&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=7d499b5d-1d92-5096-7919-3c7f8065da78&l=707

There was no code change that is causing that issue to happen in CI, the bump to a new version of the macOS image with new installed software seems to be the cause, see: #10357 (comment)

This PR is to address that change

@junr03
Copy link
Member

junr03 commented Mar 13, 2020

Ok so it looks from the progression of your commits that:

  1. bazelisk is installed but not in the Path.
  2. So we need to force install
  3. But do we need to overwrite the link if it wasn't on the path?
  4. Now we are not deleting the bazel symlink, and re-symlinking after installing bazelisk. Are we sure that calls to bazel in our script are invoking bazelisk and not bazel?

cc @lizan for a second pair of eyes. I know this is a small change, but I want to make sure that we are using the version of bazel we advertise via bazelisk.

@sunjayBhatia
Copy link
Member Author

sunjayBhatia commented Mar 13, 2020

bazelisk is installed but not in the Path.

true, however there are some other files symlinked (or otherwise) on the path that conflict with our new bazelisk install, which is why the brew link --overwrite is needed

So we need to force install

we could do a check for bazel already being installed and a brew unlink bazelisk/tap/bazel instead, doing a force install made it one less check/step

But do we need to overwrite the link if it wasn't on the path?

See the above and this example: https://dev.azure.com/cncf/envoy/_build/results?buildId=34087&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=7d499b5d-1d92-5096-7919-3c7f8065da78&l=735 (bazelisk is linked to bazelisk.js, the install must be via some node modules method?)

Now we are not deleting the bazel symlink, and re-symlinking after installing bazelisk. Are we sure that calls to bazel in our script are invoking bazelisk and not bazel?

Yep, see: https://dev.azure.com/cncf/envoy/_build/results?buildId=34087&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=5852bf5a-5a02-52f3-bee8-4fdc90cda9d0&l=22 (I believe invoking bazel causing a download of bazel means we're actually running bazelisk)

@sunjayBhatia
Copy link
Member Author

bazelisk might be installed on the new image via npm, just found: https://github.com/bazelbuild/bazelisk#releases

Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Alright, I think you have crossed all the Ts and dotted all the Is. Thank you so much!

Copy link
Member

@zuercher zuercher 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 fine. It installs bazelisk and then forces it to be linked as bazel.

@zuercher zuercher merged commit 660891e into envoyproxy:master Mar 13, 2020
@sunjayBhatia sunjayBhatia deleted the fix-macos-bazelisk-dependency-install branch March 13, 2020 17:43
junr03 added a commit to envoyproxy/envoy-mobile that referenced this pull request Mar 13, 2020
Description: move mac ci setup to use envoy's script. I don't see much of a point in keeping a separate script here. For instance, envoyproxy/envoy#10357 updated to fix bazel after CI images broke. Instead of keeping up-to-date we can piggy back on efforts in upstream Envoy. Obviously, if diverging needs evolve we might need a second script in Envoy Mobile that calls the Envoy script, and does additional work.
Risk Level: low, CI will let us know if I screwed up.
Testing: CI

Signed-off-by: Jose Nino <[email protected]>
lizan pushed a commit that referenced this pull request May 5, 2020
…0357)

Latest mac os images have bazel pre-installed so force install bazelisk and link with overwrite to allow install to succeed

Risk Level: Low
Testing: N/A
Docs Changes: N/A
Release Notes: N/A

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>

Signed-off-by: Lizan Zhou <[email protected]>
lizan pushed a commit to lizan/envoy that referenced this pull request May 5, 2020
…voyproxy#10357)

Latest mac os images have bazel pre-installed so force install bazelisk and link with overwrite to allow install to succeed

Risk Level: Low
Testing: N/A
Docs Changes: N/A
Release Notes: N/A

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>

Signed-off-by: Lizan Zhou <[email protected]>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: move mac ci setup to use envoy's script. I don't see much of a point in keeping a separate script here. For instance, #10357 updated to fix bazel after CI images broke. Instead of keeping up-to-date we can piggy back on efforts in upstream Envoy. Obviously, if diverging needs evolve we might need a second script in Envoy Mobile that calls the Envoy script, and does additional work.
Risk Level: low, CI will let us know if I screwed up.
Testing: CI

Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: JP Simard <[email protected]>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: move mac ci setup to use envoy's script. I don't see much of a point in keeping a separate script here. For instance, #10357 updated to fix bazel after CI images broke. Instead of keeping up-to-date we can piggy back on efforts in upstream Envoy. Obviously, if diverging needs evolve we might need a second script in Envoy Mobile that calls the Envoy script, and does additional work.
Risk Level: low, CI will let us know if I screwed up.
Testing: CI

Signed-off-by: Jose Nino <[email protected]>
Signed-off-by: JP Simard <[email protected]>
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.

6 participants