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: making mtcli's download to be platform and machine-aware and work for mac/darwin as well #64

Conversation

yashvardhan-kukreja
Copy link
Contributor

@yashvardhan-kukreja yashvardhan-kukreja commented Nov 18, 2021

Signed-off-by: Yashvardhan Kukreja [email protected]

Previously, sretoolbox used to Linux x86_64's mtcli binary irrespective of the underlying platform/architecture causing sretoolbox.binaries.mtcli to break when run on MacOS/Darwin.

The above PR fixes that by adding platform detection while cooking up the mtcli binary's download url ensuring that Darwin binary is downloaded when run on MacOS/Darwin and Linux binary is downloaded when run over Linux.

UPDATE regarding latest commit: raise an error instead of just returning None if there's any problem with download any child binary associated with sretoolbox. Will help catching potential binary-related execution's errors beforehand in runtime.

Unverified

This user has not yet uploaded their public signing key.
…well

Signed-off-by: Yashvardhan Kukreja <[email protected]>

Unverified

This user has not yet uploaded their public signing key.
Signed-off-by: Yashvardhan Kukreja <[email protected]>
@yashvardhan-kukreja yashvardhan-kukreja force-pushed the yashvardhan/fix-system-in-mtcli branch from 8a636b5 to 74e914b Compare November 18, 2021 07:27
@yashvardhan-kukreja yashvardhan-kukreja changed the title Fix: making mtcli download platform aware and work for mac/darwin as well Fix: making mtcli's download to be platform and machine-aware and work for mac/darwin as well Nov 18, 2021
@sugarraysam
Copy link

The problem is that the mtcli binary is not cross-compiled anymore. We added a library, which requires building with CGO_ENABLED=1, which prevents cross-compilation as it uses C bindings that are proper to each platform.

We would need to run the build on a Darwin VM, and Windows VM to cross-compile.

Reference PR: mt-sre/addon-metadata-operator#18

@sugarraysam sugarraysam added the hold Do not merge label Nov 18, 2021
@apahim
Copy link
Contributor

apahim commented Nov 18, 2021

we should probably just raise an exception if someone tries to get the binary in an unsupported platform. We don't even have to control the supported platforms here, just handle the HTTPError when reaching out to an download_url_template that doesn't exist.

@yashvardhan-kukreja
Copy link
Contributor Author

yashvardhan-kukreja commented Nov 19, 2021

The problem is that the mtcli binary is not cross-compiled anymore. We added a library, which requires building with CGO_ENABLED=1, which prevents cross-compilation as it uses C bindings that are proper to each platform.

We would need to run the build on a Darwin VM, and Windows VM to cross-compile.

Reference PR: mt-sre/addon-metadata-operator#18

Ahh, thanks for confirming this. I just took a look at the v0.1.0 and saw the binaries for Linux/Darwin amd64/arm64 compiled. But I guess from v0.2.0 onwards, only linux binaries are going to be compiled.

we should probably just raise an exception if someone tries to get the binary in an unsupported platform. We don't even have to control the supported platforms here, just handle the HTTPError when reaching out to an download_url_template that doesn't exist.

I guess, when asked for version 0.1.0, the sretoolbox.binaries.Mtcli library should download the mtcli binary w.r.t darwin/linux amd/arm, but for any other version, as you suggested, it can raise an HTTPError for any non-linux non-amd target.

How does that sound @sugarraysam @apahim :)

@yashvardhan-kukreja yashvardhan-kukreja force-pushed the yashvardhan/fix-system-in-mtcli branch 2 times, most recently from e82eade to 628dc95 Compare November 21, 2021 19:15

Unverified

This user has not yet uploaded their public signing key.
Signed-off-by: Yashvardhan Kukreja <[email protected]>
@yashvardhan-kukreja yashvardhan-kukreja force-pushed the yashvardhan/fix-system-in-mtcli branch from b0284a0 to d4127d8 Compare November 21, 2021 20:01
@sugarraysam sugarraysam merged commit b9a2708 into app-sre:master Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hold Do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants