-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support heroku-24 #280
Support heroku-24 #280
Conversation
beb461e
to
02f111a
Compare
02f111a
to
5408657
Compare
5408657
to
46fc05c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to support dynamically pulling based on currently running architecture (instead of only supporting amd64). I left a comment below. Thanks for the PR!
url.path_segments_mut() | ||
.map_err(|()| RubyInstallError::InvalidBaseUrl(String::from(base)))? | ||
.push(stack) | ||
.push("amd64") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great starting point. The only thing I would change is to use the architecture of the current machine. We're doing this in classic via shelling out https://github.com/heroku/heroku-buildpack-ruby/blob/fd6585411cbf86d363ad0824f53d8edba1d7afed/lib/language_pack/base.rb#L45-L57.
I'm hoping on a plane in a few hours and then out tomorrow, if you're available to take a stab at adding that extra logic that would be amazing 🙏🏻. If not, I can take this commit and add that on top.
I was working towards upgrading libcnb first, but seeing how compact this PR is, I think I like the idea of merging this in now and cutting a builder so people can play with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@runesoerensen @schneems The multi-arch CNB release automation relies upon the buildpack having declared [[targets]]
in order to know to create the OCI images and .cnb
files (attached to the GitHub release) as multi-arch. As such, adding support for Heroku-24 via [[stacks]]
will mean the releases will continue to be single arch and so cannot be added to the heroku/builder:24
builder, since CNBs in there need to support ARM64 too. As such, the priority is to upgrade to newer libcnb.rs and [[targets]]
.
The only thing I would change is to use the architecture of the current machine. We're doing this in classic via shelling out
We shouldn't shell out for this in our CNBs. We should either:
- Use
context.target.arch
(once the CNB has upgraded libcnb and switched to targets) - Or, use a Rust compile time conditional (https://doc.rust-lang.org/reference/conditional-compilation.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep shelling out is definitely not the best approach here.. This is somewhat related to heroku/buildpacks-nodejs#814 (comment) -- e.g. whether to use the CNB targets, or the compile-time conditional (or std::env::consts::ARCH
as in the node.js sample).
I alluded to a conversation I had with @Malax on this (re env provided target arch vs compile-time conditionals) in the other PR. What do you think about this @Malax (and did I remember the conversation correctly :-))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Python I used context.target.arch
during the build since I have to use other fields from content.target
anyway, such as the distro name/version, so it seemed to make sense to use all metadata from the same place:
https://github.com/heroku/buildpacks-python/blob/de378063c83e1eec6302e79f93f189162b5bbbbf/src/python_version.rs#L39-L47
(Though for the tests, I have to use conditional compilation: https://github.com/heroku/buildpacks-python/blob/de378063c83e1eec6302e79f93f189162b5bbbbf/tests/mod.rs#L29-L35)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, seems like it'd make a lot of sense to also use context.target
in this buildpack when the buildpack is updated to newer libcnb.rs
and targets
.
I've updated this implementation to also factor in the current arch -- should be fairly straightforward to adapt this to use the Target
instead.
@@ -174,6 +194,9 @@ pub(crate) enum RubyInstallError { | |||
#[error("Invalid base url {0}")] | |||
InvalidBaseUrl(String), | |||
|
|||
#[error("Unsupported architecture: {0}")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to go a little above and beyond and list out the supported architectures.
In general, any time we're failing because a value was unexpected based on a list of currently known/supported values, I want to output both what was actually output (the current architecture) but also what was expected (either arm64 or amd64 etc.)
This can help the future development errors/issues for example if someone accidentally adds a space like " arm64"
. Even if we think such an issue would be rare, I don't see a downside in adding that information to the error message (other than that requirement will influence the implementation, such as needing to move the information to a const, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating on this. I can take it over from here. I left one comment on an error message improvement as an FYI, but I don't need you to do anything. I'll grab you code to a new branch and iterate on some of Ed's comments.
It made more sense to move over to a new branch than to try to replay main on top of this. I am doing the work over at #284. I want to be mindful to not delete this branch until |
The buildpack can't be used directly from a branch since it would need compiling. The only other scenario is where someone might be using a shared crate, but this PR doesn't touch shared code. |
I've merged #284. I've queued up a major release GHA (since there's something marked as CHANGED due to the lifecycle requirement changing). |
Resolved by #284. |
This PR adds support for heroku-24 including downloading arch specific Ruby binaries depending on the current host architecture.
The cache isn't currently invalidated if the host architecture changes.