5.8.4 onedb fsck bug: added additional quotas on not exist resources

… Please, describe the problem here and provide additional information below (if applicable) …

For many users after run the script “onedb fsck” were added unexist quotas on Networks
for example:
before run an user had quotas:

NETWORK USAGE & QUOTAS                                                          

          ID               LEASES
           6         0 /        -
           8        18 /        -
          90         1 /        -
           9         2 /        -
         112         1 /        -

After:

NETWORK USAGE & QUOTAS                                                                                                                                                                                               
                                                                                                                                                                                                                     
          ID               LEASES                                                                                                                                                                                    
           6         0 /        -                                                                                                                                                                                    
           8        17 /        -                                                                                                                                                                                    
          90         1 /        -                                                                                                                                                                                    
           9         2 /        -                                                                                                                                                                                    
         112         1 /        -                                                                                                                                                                                    
         000         6 /        -                                                                                                                                                                                    
           0         1 /        -                                                                                                                                                                                    
           2         1 /        -

The networks with ID:000, 0, 2 don’t exist

oneadmin@fn1:~$ onevnet show 2
[one.vn.info] Error getting virtual network [2].
oneadmin@fn1:~$ onevnet show 0
[one.vn.info] Error getting virtual network [0].
oneadmin@fn1:~$ onevnet show 00
[one.vn.info] Error getting virtual network [0].

Versions of the related components and OS (frontend, hypervisors, VMs):

$ cat /etc/*release
CentOS Linux release 7.6.1810 (Core)
$ ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

Steps to reproduce:

Current results:

Expected results:

What was the output the FSCK script?

onedb-fsck.log (18.0 KB)

What is the output of onevm list -x | grep -i nic_id?

output.txt (10.9 KB)

Hello @ahuertas

It’s seems additional quotas on not exist resourses is working from this condition:

fsck/quotas.rb

    475                 parent_id = ar.xpath('AR/PARENT_NETWORK_AR_ID')
    476                 parent_id = parent_id.text unless parent_id.nil?
    477 
    478                 next if parent_id.nil? || parent_id.empty?
    479 
    480                 vnet_usage[parent_id] = 0 if vnet_usage[parent_id].nil?
    481 
    482                 ar.xpath('AR/SIZE').each do |size|
    483                     vnet_usage[parent_id] += size.text.to_i

In this key if “PARENT_NETWORK_AR_ID” not exist we will be add VALUE to empty KEY, i.e. instead PARENT_NETWORK_AR_ID = [SIZE] we have __ = [SIZE].
May be will more logical if this will so:

 478                 next if !parent_id.nil? || !parent_id.empty?

If we meet empty or nil KEY PARENT_NETWORK_AR_ID, will missed it and won’t added additional quotas on not exist resources.

What is your opinion?

Hello @telecast

It’s a great solution! Make a PR to our main repository so we will review it more deeply and merge in master. Thank you so much for your contribution!

@ahuertas

It’s seems I can’t to create branch to main repository. I probably need to get rights for my account?

Hello @telecast

You don’t need to create a branch in the main repo, you make a pull request from your own branch to master branch in our repo.

@ahuertas
Thank you for the clarification. I made pull request

Thanks! I will review it and we will merge it!