Set UBC Limits via prlsdkapi

Discussion in 'Installation, Update and Configuration' started by KristianM, Jun 23, 2016.

  1. KristianM

    KristianM Product Expert

    Messages:
    469
    Hi,

    can somebody please point me into the right direction to create CTs via the prlsdkapi with old UBC Limits?

    I can't find this in the documentation anywhere.
    But as it is still possible to set UBC limits by vzctl and prlctl and both tools use the prlsdkapi afaik this should be possible also by using the prlsdkapi directly via Python or C.

    Regards
    Kristian

     
  2. Pavel

    Pavel A.I. Auto-Responder Odin Team

    Messages:
    433
    As far as I know there is no direct way to set some UBC value. Instead, you get a config, change value, and apply it back, as a "Apply Sample Config" or something like that.
    Try to do this with PrlVmCfg_ApplyConfigSample
    Let me know if you get stuck with it - I'll reach out to Odin engineers to find out how did they implement it in OACI (they've spent quite a while looking for a best solutions - thus I believe they will know the optimal way which will save time for us).

    If you just want to create - using samples is the way. However, I assume some day you'll need to know how to change them as well - that is why my answer was a bit broader
     
  3. KristianM

    KristianM Product Expert

    Messages:
    469
    Hi Pavel,

    thank you for your reply.
    Using a sampleConf is not really helpful, as every CT has an individual configuration.
    I would really appreciate it if you could contact the Odin guys to hand out further information.

    Thanks
    Kristian
     
  4. Pavel

    Pavel A.I. Auto-Responder Odin Team

    Messages:
    433
    Idea is not to apply the same sample. Idea is to fetch CT's config, modify it as you desire, and apply it back as a sample.
    I've reached out to Odin colleagues, will let you know asap.
     
  5. Pavel

    Pavel A.I. Auto-Responder Odin Team

    Messages:
    433
    Turned out PACI does not manage any UBC parameters - they only set RAM which is done via the same function as for the VMs.
    I'll do more research next week. For now - try to look into the "sample approach" I described above - that most likely would be the only option (except for invoking vzctl of course)
     
  6. KristianM

    KristianM Product Expert

    Messages:
    469
    Best Answer
    Hi Pavel,

    I got most of the information I require from support now.
    The function I was searching for was:

    def set_resource(self, nResourceId, nBarrirer, nLimit):
    call_sdk_function('PrlVmCfg_SetResource', self.handle, nResourceId, nBarrirer, nLimit)

    Most of the required resources can be set with the above function when using the following id's:


    typedef enum _PRL_CT_RESOURCE
    {
    PCR_KMEMSIZE = 1,
    PCR_LOCKEDPAGES = 2,
    PCR_PRIVVMPAGES = 3,
    PCR_SHMPAGES = 4,
    PCR_NUMPROC = 5,
    PCR_PHYSPAGES = 6,
    PCR_VMGUARPAGES = 7,
    PCR_OOMGUARPAGES= 8,
    PCR_NUMTCPSOCK = 9,
    PCR_NUMFLOCK = 10,
    PCR_NUMPTY = 11,
    PCR_NUMSIGINFO = 12,
    PCR_TCPSNDBUF = 13,
    PCR_TCPRCVBUF = 14,
    PCR_OTHERSOCKBUF= 15,
    PCR_DGRAMRCVBUF = 16,
    PCR_NUMOTHERSOCK= 17,
    PCR_DCACHESIZE = 18,
    PCR_NUMFILE = 19,
    PCR_NUMIPTENT = 20,
    PCR_SWAPPAGES = 21,

    PCR_QUOTAUGIDLIMIT = 22,

    PCR_LAST = PCR_QUOTAUGIDLIMIT,

    } PRL_CT_RESOURCE;


    Hope this helps someone else too :)
    Regards
    Kristian
     
  7. Pavel

    Pavel A.I. Auto-Responder Odin Team

    Messages:
    433
    Nice catch! too bad its not mentioned in the docs. I'll see what can we do about it.
    Thanks for sharing!
     
  8. KristianM

    KristianM Product Expert

    Messages:
    469
    Hi Pavel,

    just a short update.
    I was unable to proceed with this for quite a while.
    Today I tried and failed :(

    The reason:
    In the documentation (http://updates.virtuozzo.com/doc/pcs/en_us/virtuozzo/6/current/pdf/Virtuozzo_C_API_Reference.pdf) on page 784
    where I actually found this function, it says:
    "Only PCR_SWAPPAGES supported for now)."

    Now there are way more UBC Limits then only swappages.
    So I have reopened a ticket with support, requesting for further information as how to manage UBC Limits with the prlsdkapi.
    It must be possible, as PVA can actually set and manage limits and it's also possible via prlctl/vzctl and as far as I know,
    at least prlctl and vzctl both use the prlsdkapi in the backend.

    If you have any further information you can share, please do so.
    As soon as support actually shares anything, I'll also keep you posted.

    Thanks
    Kristian
     
  9. Pavel

    Pavel A.I. Auto-Responder Odin Team

    Messages:
    433
    Hello Kristian,

    I'll search for a way.
    One note - PVA uses vzctl in the background, not SDK API. Also vzctl uses libvzctl, not SDK API.
    There is a chance that managing other UBC resources was simply unimplemented considering the fact vSwap does not require setting all of the resources.

    Can you clarify your use-case? Why do you need to set any UBC limits besides the ram/swap?
     
  10. KristianM

    KristianM Product Expert

    Messages:
    469
    Hi Pavel,

    well we have been using VZ for ~ 10 years now.
    Obviously we still have customers with hosting plans that are not on vSwap. (UBC and SLM even)
    But if the customer reinstalls his/her VPS he should still be able to receive the booked resources.
    I'm actually trying to work around using privvmpages and physpages directly now, but as it is actually not even possible to set secondary ubc limits
    such as "numproc" via set_resource it's starting to get difficult.

    Normally I would also prefer vSwap. But even with vSwap there are ubc limits such as "numproc" which are still
    important to set to protect nodes against fork-bombs etc.

    I know that VM_OVERCOMMIT is also not supported via the SDK API, but could you please clarify what the alternative is with the SDK API?

    Why are we actually facing this issue?
    Previously we have use PVA Agent to manage all CTs. As PVA is actually not moving anywhere and we were told to actually best use SDK API
    we are preparing our CT/VM management daemon using the SDK API. But I have to consider PCS6 (currently still with PVA) and VZ7 (SDK only) nodes.
    The PCS6 nodes as mentioned above still have plain ubc Limits and others even slmlimits set.
    I could go a bit more into detail in a private chat :)

    Regards,
    Kristian
     
  11. Stone

    Stone Bit Poster

    Messages:
    1
    Previously we have use PVA Agent to manage all CTs. As PVA is actually not moving anywhere and we were told to actually best use SDK API
    we are preparing our CT/VM management daemon using the SDK API
    tHANK
     
  12. Pavel

    Pavel A.I. Auto-Responder Odin Team

    Messages:
    433
    Hello Kristian,

    I'm afraid that SDK does not support all legacy limits, just the swappages and ram (physpages). As an alternative I might suggest you to call "vzctl" directly from python to set the necessary limits. It's a straightforward solution, but it will work.

    Hello Stone,

    If you're going to use legacy UBC limits you might want to follow the same advice. Besides the UBC limits configuration functionality should be sufficient.
     

Share This Page