Project

General

Profile

« Previous | Next » 

Revision 6d90fb6e

Added by Daniel Lobato Garcia almost 6 years ago

Fixes #24093 - Notification is sent only when disk > 90%

Here’s what happens for a proxy where the disk 12% full:

When the code runs, percentage 12% is < 90%.
The notification does not exist, therefore:

```ruby
percentage[0..2].to_i < 90 && notification_already_exists?(proxy)
true && false
false # so it does not skip the loop
```

The next line tries to update old notifications. Since
there are no notifications at this point,
update_notifications(proxy).empty? is true.

Finally it creates the notification (at this point we
have a notification for proxy ‘foreman.example.com’ full at 12%).

After that, the job is scheduled, and when it runs (12h later):

The percentage is less than 90, 12%, and the notification
already exists. At this point Foreman is happy and proceeds
to remove the notification.

```ruby
percentage[0..2].to_i < 90 && notification_already_exists?(proxy) # evaluates to
true && true
```

For the next 12h, we don’t have the notification.
Now, 12h later… GOTO beginning of the post :wink:
Basically right before creating the notification I added a check
for > 90% full. The rest of the logic should be fine.

  • added
  • modified
  • copied
  • renamed
  • deleted