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

[Stacked] Schneems/download bundler struct layer #326

Closed
wants to merge 14 commits into from

Conversation

schneems
Copy link
Contributor

No description provided.

The `Changed` struct limits us to a single reason for a change. By using a vec we can list all changes. There will be some redundancy in the output if multiple layers are keyed to the same values (such as distro name or distro version). That might be okay, or we could try storing common information in its own layer up front, and printing that information once (the specific values) and then later we could say "distro version changed" rather than "distro verision changed (22.04 to 24.04)".
Changing the logging will be it's own commit.
The explicit check if the old and new metadata structs were equal isn't needed since I'm already comparing each individual element and have logic to return `None` if they're the same.
Prefer format!(path.display) over `to_string_lossy`.
@schneems schneems requested a review from a team as a code owner September 23, 2024 21:55
Copy link
Contributor

@runesoerensen runesoerensen left a comment

Choose a reason for hiding this comment

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

This PR looks good -- I've added a few comments/suggestions regarding the log output.

On that note: The cache layer reuse/clearing log output could benefit from a more consistent style (as there are currently 3+ different variations of this across the ruby, bundler and gems layers), e.g.:

- Ruby version `3.1.3` from `default`
  - Clearing cache due to change(s): CPU architecture (`amd64` to `arm64`)
  - Installing .... (1.6s)
- Bundler version `2.4.17` from `Gemfile.lock`
  - Clearing cache Bundler version (`2.4.5` to `2.4.17`)
  - Running `gem install bundler --version 2.4.17` ... (0.4s)
- Bundle install
  - Clearing cache (cpu architecture changed: amd64 to arm64)

I'm guessing this is already on your radar -- to be clear, I'm not asking you to change stuff related to anything except the bundler layer in this PR :)

It'd also be great if you could add some integration tests that verify the intended log output (that at least cover the output with a clear cache, and after rebuilding and reusing the case). E.g. something like this https://github.com/heroku/buildpacks-dotnet/blob/main/buildpacks/dotnet/tests/sdk_installation_test.rs#L47-L77 . Whenever log output is changed, I like to also see a change in an integration test (or a failed integration test) :)

} else {
State::BundlerVersionChanged(old.version, version)
Some(format!(
"Bundler version ({old} to {now})",
Copy link
Contributor

Choose a reason for hiding this comment

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

Use lower-case (like the "invalid metadata" cause) https://github.com/heroku/buildpacks-ruby/pull/326/files#diff-cd4ee747be3abfb0ab939cdf3087fa781357327a5eabb3d870f73cc4625b7160R38 and consistent with the output prior to this PR - unless this is intentional/desired ("Bundler" could work with the edit I made above, wrapping the cause in parenthesis). Also added "changed" for context.

Suggested change
"Bundler version ({old} to {now})",
"bundler version changed ({old} to {now})",

EmptyLayerCause::NewlyCreated => {}
EmptyLayerCause::InvalidMetadataAction { cause }
| EmptyLayerCause::RestoredLayerAction { cause } => {
bullet = bullet.sub_bullet(format!("Clearing cache {cause}"));
Copy link
Contributor

Choose a reason for hiding this comment

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

The log output was changed in this PR, to include more details when the bundler version changed, but that also made the log output a bit awkward:

Clearing cache Bundler version (`2.4.5` to `2.4.17`)

The cause also has differing casing (Bundler version vs invalid metadata).

Suggested change
bullet = bullet.sub_bullet(format!("Clearing cache {cause}"));
bullet = bullet.sub_bullet(format!("Clearing cache {}", style::details(cause)));

This (combined with the edit below, fixing the bundler version change cause) is one way this could be addressed. Might make sense to consider a different phrasing though as these changes result in:

Clearing cache (bundler version changed (`2.4.5` to `2.4.17`))

} else {
(
RestoredLayerAction::KeepLayer,
"using cached version".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make sense to update this to specifically mention "Bundler" here. This is not necessary as part of this PR (it could also be a separate PR if you like), but all the other layers specify what's being reused (e.g. metrics agent, Ruby version, gems:

- Metrics agent
  - Using cached metrics agent
- Ruby version `3.1.3` from `default`
  - Using cached Ruby version
- Bundler version `2.4.17` from `Gemfile.lock`
  - Using cached version
- Bundle install
  - Loading cached gems
Suggested change
"using cached version".to_string(),
"using cached Bundler version".to_string(),

Base automatically changed from schneems/update-ruby-install-layer-v3 to main September 24, 2024 23:36
@schneems
Copy link
Contributor Author

schneems commented Oct 2, 2024

Going to close this and start fresh after landing #327. I took a lot of this feedback and channeled it into that PR (re consistency and testing).

@schneems schneems closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants