Bug #1889

onedb fsck removes users quotas for VMS/MEMORY/CPU

Added by Rolandas Naujikas about 8 years ago. Updated almost 8 years ago.

Status:ClosedStart date:04/09/2013
Priority:HighDue date:
Assignee:Carlos Martín% Done:

0%

Category:Core & System
Target version:Release 4.2
Resolution:fixed Pull request:
Affected Versions:OpenNebula 4.0

Description

I found that after running "onedb fsck" VMS/MEMORY/CPU quotas are reset to unlimited for users without running VMs.
Something wrong in fsck.rb at lines

...
    def calculate_quotas(doc, where_filter, resource)
...
        # VM quotas

        vm_elem = nil
        doc.root.each_element("VM_QUOTA/VM") { |e| vm_elem = e }

        if vm_elem.nil?
            doc.root.delete_element("VM_QUOTA")

            vm_quota  = doc.root.add_element("VM_QUOTA")
            vm_elem   = vm_quota.add_element("VM")

            vm_elem.add_element("CPU").text         = "0" 
            vm_elem.add_element("CPU_USED").text    = "0" 

            vm_elem.add_element("MEMORY").text      = "0" 
            vm_elem.add_element("MEMORY_USED").text = "0" 

            vm_elem.add_element("VMS").text         = "0" 
            vm_elem.add_element("VMS_USED").text    = "0" 
        end
...


but I cannot understand without good ruby language/opennebula data structures knowledge.

fsck.patch Magnifier (534 Bytes) Rolandas Naujikas, 04/09/2013 02:01 PM

Associated revisions

Revision c26b857d
Added by Carlos Martín about 8 years ago

Bug #1889: fix in fsck, thanks to Rolandas Naujikas

Revision 6380514c
Added by Carlos Martín about 8 years ago

Bug #1889: fix in fsck, thanks to Rolandas Naujikas
(cherry picked from commit c26b857d5423eb3eada83500dfc349ad899e1e80)

Revision 567ed57a
Added by Carlos Martín almost 8 years ago

Bug #1889: Fsck creates new quota entries with default -1

Revision 6f43cbff
Added by Carlos Martín almost 8 years ago

Bug #1889: Fsck creates new quota entries with default -1
(cherry picked from commit 28899ec37965e3d193358897fa4ab39c75ef183c)

History

#1 Updated by Rolandas Naujikas about 8 years ago

After some investigation I found in fsck.rb

...
    def calculate_quotas(doc, where_filter, resource)
...
        if ( cpu_used == 0.0 && mem_used == 0 && vms_used == 0 )
            doc.root.delete_element("VM_QUOTA")
            doc.root.add_element("VM_QUOTA")
        end
...

So those lines removes quota entry for user if it doesn't use any resources.

#2 Updated by Ruben S. Montero about 8 years ago

  • Assignee set to Carlos Martín
  • Target version set to Release 4.0

#3 Updated by Carlos Martín about 8 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

Good catch, thanks a lot Rolandas.

#4 Updated by Rolandas Naujikas about 8 years ago

This bug reappears in opennebula 4.0.0 and it looks like the original code quoted could be a problem.

When an user dosn't have any VM running its VM quotas are set to 0, what means unlimited instead of -1.
We should check this logic better to make it work with unlimited and default quotas.

#5 Updated by Ruben S. Montero about 8 years ago

  • Status changed from Closed to Pending
  • Target version deleted (Release 4.0)
  • Resolution deleted (fixed)

#6 Updated by Rolandas Naujikas about 8 years ago

fsck should solve problems, not create new one.
We had to solve it in 4.0.1.

#7 Updated by Carlos Martín about 8 years ago

  • Status changed from Pending to New
  • Priority changed from Normal to High
  • Affected Versions OpenNebula 4.0 added

#8 Updated by Carlos Martín almost 8 years ago

  • Target version set to Release 4.2

#9 Updated by Carlos Martín almost 8 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

Should be fixed now... again. Thanks!

#10 Updated by Rolandas Naujikas almost 8 years ago

It is not solved.
If I understand correctly all your changes, now if an user doesn't use any resources, then his custom quotas are replaced by default quotas, what is not right.
Probably it would be better to replace quota values by current quota values if they exists, then by default quotas.

#11 Updated by Carlos Martín almost 8 years ago

  • Status changed from Closed to New
  • Resolution deleted (fixed)

#12 Updated by Ruben S. Montero almost 8 years ago

  • Category set to Core & System

#13 Updated by Carlos Martín almost 8 years ago

Rolandas Naujikas wrote:

It is not solved.
If I understand correctly all your changes, now if an user doesn't use any resources, then his custom quotas are replaced by default quotas, what is not right.
Probably it would be better to replace quota values by current quota values if they exists, then by default quotas.

Can you point to the lines where this is happening?

Looking for example at the Image quotas section, if the user doesn't have any Image in use:

The first loop will go through the existing quotas. If a quota has a RVMS_USED different to 0, then it will be replaced with 0. The current quota limits (RVMS) are not replaced in any case.

        img_quota.each_element("IMAGE") { |img_elem|
            img_id = img_elem.get_text("ID").to_s

            rvms = img_usage.delete(img_id)

            rvms = 0 if rvms.nil?

            img_elem.each_element("RVMS_USED") { |e|
                if e.text != rvms.to_s
                    log_error("#{resource} #{oid} quotas: Image #{img_id}\tRVMS has #{e.text} \tis\t#{rvms}")
                    e.text = rvms.to_s
                end
            }
        }

The second loop will do nothing, since the user is not using any image. But if he were using images, this loop iterates over the images that are in use, but don't have a quota reflecting this usage currently. So the RVMS = "-1" is not replacing any existing quota limit here either.

        img_usage.each { |img_id, rvms|
            log_error("#{resource} #{oid} quotas: Image #{img_id}\tRVMS has 0 \tis\t#{rvms}")

            new_elem = img_quota.add_element("IMAGE")

            new_elem.add_element("ID").text = img_id
            new_elem.add_element("RVMS").text = "-1" 
            new_elem.add_element("RVMS_USED").text = rvms.to_s
        }

Regards

#14 Updated by Rolandas Naujikas almost 8 years ago

It's about original bug description lines, related to CPU, MEMORY, VMS quotas.
I didn't check about others, probably they are OK.

#15 Updated by Rolandas Naujikas almost 8 years ago

I just tested this version of fsck.rb against our testbed on 4.0.1 (with version changed to 4.0.1).
It looks much better and those accounts, with missing quotas (as in sunstone 4.0.1 when I try set to default) after "onedb fsck" it is changed to default quotas.
Sorry for my mistake. Before saying something, it is better to test it.

#16 Updated by Ruben S. Montero almost 8 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

#17 Updated by Carlos Martín almost 8 years ago

Rolandas Naujikas wrote:

I just tested this version of fsck.rb against our testbed on 4.0.1 (with version changed to 4.0.1).
It looks much better and those accounts, with missing quotas (as in sunstone 4.0.1 when I try set to default) after "onedb fsck" it is changed to default quotas.
Sorry for my mistake. Before saying something, it is better to test it.

Great! Thanks for keeping an eye on our commits.

Also available in: Atom PDF