Skip to content

Round Remaining Namespace Storage in Notification Email to Match Banner

What does this MR do and why?

When the total namespace storage crosses a warning threshold, we display a banner and we also send an email.

Sometimes there is a slight discrepancy in consumed storage percentage reported in the banner vs the email.

We calculate the percent by two different functions. One of these functions rounds, the other uses floor to always round down. So sometimes the percentages are off by 1.

[64] pry(main)> number_to_percentage(0.6, precision: 0)
=> "1%"
[65] pry(main)> number_to_percentage(0.4, precision: 0)
=> "0%"
[66] pry(main)> 

This MR changes the email function to use round as well.

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/422103

Screenshots or screen recordings

Note that in the first screenshot, the banner reports 89% storage consumed, while the email reports 88%.

In the second screenshot, both the banner and the email match and report 89% consumed.

Before After
Before After

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jason Goodman

Merge request reports