-
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
Update the logging interface #198
Conversation
45190ce
to
2b56182
Compare
34ea214
to
02758b4
Compare
dda57de
to
64c7e62
Compare
Do you want a thorough review on this or when you port this over to libherokubuildpack? Is that still the plan? |
I think maybe give this a rough pass with an eye towards eventual integration, but I think we plan on a fairly exhaustive review on future |
1e866f6
to
a97dec6
Compare
@schneems in this case, I'd say we rubber stamp this one and do a proper review on the libherokubuildpack one only. This is a huge PR and will take a lot of time to review and any change we make will break @colincasey. |
Sounds good. Let's move forward with that strategy. |
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 very quick skim review of mainly the non-Rust parts, since at +3,403 −1,507
this PR is too large to properly review - particularly since it mixes new APIs, error message content changes (as in the copy), CI changes etc.
0ebcbe9
to
7c85b5e
Compare
@schneems Is this ready for merge? |
I ran into some move issues and I'm not incredibly comfortable with multithreading and the memory rules. I leaned on this post https://users.rust-lang.org/t/take-ownership-of-arc-mutex-t-inner-value/38097/2 which helped me get values back out of the mutex. There's a very high number of expect/unwraps in this code. Also the addition of NullWriter to get it to compile feels wrong (as it puts our program in an invalid state (cannot print if we try, but it doesn't error). For ergonomics all these expectations make the end API better. IDK if it's good enough to have this code tested and keep them in or if this really needs to return a Result. If we did return a result I don't know that there's a case where the buildpack author could safely continue as they will have lost access to their writer struct (since any errors here effectively mean we cannot get our destination again).
Due to the implementation of the announce logging (warning, important) needing whitespace above and below their blocks, calling `announce.warn_later` accidentally introduce whitespace` into the build output. This test fails: ``` thread 'output::build_log::test::warn_later_doesnt_output_newline' panicked at 'assertion failed: `(left == right)` Diff < left / right > : # Walkin' on the Sun - So don't delay, act now, supplies are running out - Allow if you're still alive, six to eight years to arrive - And if you follow, there may be a tomorrow > - But if the offer's shunned - You might as well be walking on the Sun - Done (finished in < 0.1s) ! And all that glitters is gold ! Only shooting stars break the mold ', commons/src/output/build_log.rs:646:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` I previously noted that this can also be triggered via calling `.announce().end_announce()` which seemed trivial enough (and unlikely) to avoid. However I'm re-thinking that I want to insert a preliminary guard state between calling `.announce()` and `end_announce()` but it gets gnarly because that intermediate state would carry duplicate associated functions. An alternative could be to move `warn_later` to individual states (instead of needing to create an Announcement logger).
The biggest change here is going from `ps` to `ps aux`. I am also standardizing on the fun run command extension instead of libherokubuildpack's.
Previously when entering an "announce" state we would preemptively print a newline. Instead I'm storing a leader character and printing it once and only once while calling one of: - error - important - warning Notably `warn_later` does not emit this character. This also fixes the previously described case where someone enters and exits an announce state without calling error, important, or warning.
Previously I had duplication in my interface definitions with SectionAnnounceLogger and StartedAnnounceLogger. I'm using a different technique (associated types) to consolidate those into one trait. At the same time I moved the logic in `build_log.rs` to a shared location (to prevent accidental divergence). I also renamed the struct AnnounceLogger there as it would otherwise conflict with the trait name. The pattern of using an associated type to return to an arbitrary state works well, but I came up with it myself, so it might be gnarly (or there might be a better way to compose this logic). Either way, I think this is better that what we had before. I'm exploring additional ways to clean up the stateful implementation within `build_log.rs` via a thread in our internal slack https://salesforce-internal.slack.com/archives/CFF88C0HM/p1694015747944619
The default display for fun_run didn't wrap the command. Example: Before: ``` - Debug info - Could not run command gem install bundler --version 2.3.26 --install-dir /layers/heroku_ruby/bundler --bindir /layers/heroku_ruby/bundler/bin --force --no-document --env-shebang. No such file or directory (os error 2) ``` I want to separate fun_run from the build output work, so this approximates the style (without the color coding). It's more readable After: ``` - Debug info - Could not run command `gem install bundler --version 2.3.26 --install-dir /layers/heroku_ruby/bundler --bindir /layers/heroku_ruby/bundler/bin --force --no-document --env-shebang`. No such file or directory (os error 2) ```
These outputs are meant to be machine readable only, it should be timed and not streamed. I.e. we want the output to be ``` - Rake assets install - Rake detected (`rake` gem found, `Rakefile` found ad `/workspace/Rakefile`) - Running `bundle exec rake -P --trace` .... (2.1s) - Compiling assets with cache (detected `rake assets:precompile` and `rake assets:clean` via `bundle exec rake -P`) ``` And not ``` - Rake assets install - Rake detected (`rake` gem found, `Rakefile` found ad `/workspace/Rakefile`) - Running `bundle exec rake -P --trace` rake about environment rake action_mailbox:ingress:environment rake action_mailbox:ingress:exim action_mailbox:ingress:environment rake action_mailbox:ingress:postfix action_mailbox:ingress:environment rake action_mailbox:ingress:qmail action_mailbox:ingress:environment rake action_mailbox:install rake action_mailbox:install:migrations rake action_text:install rake action_text:install:migrations rake active_storage:install environment rake active_storage:install:migrations rake active_storage:update [...] - Done (2.111s) - Compiling assets with cache (detected `rake assets:precompile` and `rake assets:clean` via `bundle exec rake -P`) ```
The output of gem install bundler is an implementation detail and is not needed. Use the more compact timer format instead.
Co-authored-by: Ed Morley <[email protected]>
Co-authored-by: Ed Morley <[email protected]>
bf253a1
to
d645702
Compare
d645702
to
b3ccd76
Compare
## heroku/ruby ### Fixed - Update build logging style (#198) Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com>
Supercedes #175