node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Sign darwin builds with rcodesign to prevent SIGKILL issues

Open gitperr opened this issue 1 year ago • 7 comments

We currently don't sign the darwin builds, this causes node exporter to not boot properly. This PR attempts to fix that.

Fix: https://github.com/prometheus/node_exporter/issues/2539, https://github.com/prometheus/node_exporter/issues/2217

gitperr avatar Feb 07 '24 16:02 gitperr

@SuperQ I am trying to produce darwin-arm64 binary, but the pipeline does not produce it.

ls -la results after build stage commands are run: https://app.circleci.com/pipelines/github/prometheus/node_exporter/3954/workflows/ee5cbe9d-15d8-478f-a2c3-c0083b1c8368/jobs/20614/parallel-runs/0/steps/0-106

I tried to look at promu code, as well as the config files that are being passed to it, everything seems to be good... But, these commands don't produce the binary:

promu crossbuild -v --parallelism $CIRCLE_NODE_TOTAL --parallelism-thread $CIRCLE_NODE_INDEX
promu --config .promu-cgo.yml crossbuild -v --parallelism $CIRCLE_NODE_TOTAL --parallelism-thread $CIRCLE_NODE_INDEX

It did not work locally either (built everything else but darwin-arm64). I ended up trying:

promu crossbuild --config=.promu-cgo.yml -p darwin

which does produce the darwin-arm64 build. But it should have worked earlier already and this should not be necessary.

What should we do?

gitperr avatar Feb 07 '24 19:02 gitperr

Did some more reading of pipeline as well as promu, seems like the binaries get built based on which index they are on in the platforms. Since darwin-arm64 is on index 1, we'd need the CIRCLE_NODE_INDEX to be set to 1 while CIRCLE_NODE_TOTAL is 3 because of this calculations that happen on the here on buildThread method.

CircleCI actually did successfully build and sign the darwin-arm64 binary on node number 1.

But the end pipeline still fails because we attempt to sign on all 3 nodes, but some of them don't have the arm build as per the config. Will need to move signing elsewhere.

gitperr avatar Feb 08 '24 18:02 gitperr

Finally managed to build a signed darwin-arm64.

One other problem popped up:

  • If the binary is downloaded using Safari, it will not run, warning the user with this popup Screenshot 2024-02-08 at 21 17 23

this can be bypassed by allowing it through macOS security settings. Probably the better way is to actually feed a code signing key, which is maintained by the project, to our code signing process.

I tried to download the binary using curl, which completely bypassed the above security warning and ran as intended.

If it sounds good so far, I can look into adding the key as well, but that would require a maintainer to put it to repo secrets probably.

gitperr avatar Feb 08 '24 19:02 gitperr

We usually stick the binaries in a tar.gz, would that be enough to avoid Safari warnings?

SuperQ avatar Feb 08 '24 21:02 SuperQ

I downloaded the binary on my linux machine and tarred it to .tar.gz. Then hosted it myself (python3 -m http.server), pulled with curl on the mac and untarred it, works as intended.

If I click and download it with Safari, it even downloads the .tar.gz file as .tar, and untarred version still gives that popup. Quite weird.

gitperr avatar Feb 08 '24 23:02 gitperr

I did some more research and if we want to sign it with a key that's maintained by the project, we will have to pay Apple a yearly fee of $99 (that fixes the safari warnings completely). If we do not want to go that path, this can be merged anyway, because it improves the current SIGKILL situation if the user pulls with curl (or likely wget as well) but safari click downloads will require extra step to "allow it to run".

Ansibles etc., will end up using these tools, so it should not be a problem in that regard.

gitperr avatar Feb 10 '24 13:02 gitperr

Waiting for https://github.com/prometheus/promu/pull/284 to be finalized and merged, this should come after that. We should re-trigger the pipeline to see if everything passes as intended.

gitperr avatar Feb 18 '24 14:02 gitperr

@gitperr JFYI https://github.com/prometheus/node_exporter/pull/2916#issue-2123466892 needs a "Fixes" in place of "Fix" to close the relevant PRs once this is in.

rexagod avatar Mar 19 '24 04:03 rexagod

Edited the message: fix -> fixes

gitperr avatar Mar 19 '24 07:03 gitperr

Looks like the promu version isnt updated

discordianfish avatar Mar 21 '24 14:03 discordianfish

Yep, it is still waiting for Julien's review. But if someone else wants to take a second look and give it approval, that might work too.

Otherwise I do not know how to move it forward. Help is welcome.

gitperr avatar Mar 21 '24 17:03 gitperr

Bump, I'd still like to get this forward and can make changes if needed.

gitperr avatar Apr 14 '24 14:04 gitperr