Monday, April 24, 2017

A quick look at using Quota on the Oracle Cloud Machine

Introduction

On OCM racks prior to version 17.1.6 they have the option to place a quota limitation on their tenancies.  Without a quota the tenant is able to use compute resources up to the physical limits of the rack that has been subscribed to.  It may be appropriate to limit the resource that one tenancy can utilise, this can be achieved using the quota object which is assigned to each tenancy.

There are a number of resources that can be limited on a per-tenant basis, these are.

  • Compute
    • Instances
    • Memory
    • CPUs
    • Instance Restrictions
  • Storage
  • Machine Image
    • Number
    • Megabytes
  • Network
    • IP reservations
Figure 1 shows an example listing of a quota that has been applied to a tenancy.   It shows both the quota limits set and what the current usage is so it becomes a fairly simple task to work out how close to the current quota the tenancy is getting.

# oc list quota -u /quota-test/administrator /quota-test -f json
{
 "list": [
  {
   "usage": {
    "machineimage": {
     "number": 1,
     "megabytes": 2466
    },
    "vnet": {
     "vnetreservations": 0
    },
    "compute": {
     "instances": 7,
     "ram": 24576,
     "instance_restrictions": {},
     "cpus": 6.0
    },
    "nds": {
     "megabytes": 0
    }
   },
   "uri": "https://api/quota/quota-test",
   "description": "Default quota for \"quota-test\"",
   "name": "/quota-test",
   "allowance": {
    "machineimage": {
     "number": 2,
     "megabytes": 4096
    },
    "vnet": {
     "vnetreservations": 2
    },
    "compute": {
     "instances": 8,
     "ram": 41000,
     "instance_restrictions": {},
     "cpus": 6.0
    },
    "nds": {
     "megabytes": 4096
    }
   }
  }
 ]
}
Figure 1 - Example quota output

In general these are fairly self explanatory as to what each restriction will do but there are some subtlties.

Compute

The restrictions for compute are split into Instances, Memory, CPU and "Instance Restrictions."   The instances number in a quota directly relates to the number of  VM instances that have been created within the tenancy.  This quota is checked as soon as an orchestration attempts to start and if the quota is exceeded it will cause the orchestration to fail to startup until other instances (orchestrations) are stopped.  Note - Stopped rather than simply shutdown as a shutdown instance remains in existence.

Memory and CPU quota are very similar to instance restrictions.  The main difference is that a VM has to be actually running to consume the quota so if this limit is reached then existing VMs have to be shutdown to allow the new instance to startup but they do not have to be "stopped".

Figure 2 below shows the errors reported when the quota is exceeded in a couple of examples.

Error starting orchestration that exceeds the allowed number of instances
     "status": "error",
     "info": {
      "errors": {
       "0": "don05 is in error: {'/quota-test': u'Reservation exceeded quotas: instances exceeded by 1.0'}"
      }


Error starting orchestration that exceeds the allowed Memory
     "status": "error",
     "info": {
      "errors": {
       "0": "don06 is in error: {'/quota-test': u'Reservation exceeded quotas: ram exceeded by 3576.0'}"
}
Figure 2 - Error message when exceeding quota for instance or memory

Instance Restrictions is a special tagging mechanism that would allow a machine image (template) to be tagged and it is then possible to restrict the number of instances created from that specific machine image.  This is currently not supported on the OCM so the instance_restrictions quota value should be left blank.

Storage

The storage figure given applies to additional storage volumes and not to the root disks.  i.e. If you need to restrict storage space used by the root disks then you need to apply a quota to the instances in the compute section.  If you hit the limit then it is necessary to actively stop any storage volumes to delete the storage and free up resource.

Machine Image

The machine image quota can be specified either in terms of the numbers of machine images held within the quota or by the storage volume space taken up.  Typically this would be used to limit the number of snapshots that a tenancy can use.  (Taking a snapshot of a VM will take a copy of the root disks at the time of snapshotting and create a new machine image.)

Network

When networks are defined for a tenancy there are several choices on their configuration which can be used as a limit in themselves.  For example if a tenant has a public or EoIB network assigned to them then the number of IP addresses the tenancy can use will be determined by the subnet and within the subnet further limited by the IP Range defined.  Private networks can also be created but again these have a defined size which cannot be exceeded.

However, in OCM releases prior to 17.1.6 the concept of a service network was available where a tenancy would be given access to a network and the same network could be handed out to other tenancies as well.  If a "vnetreservation" quota is setup then the system will prevent a tenancy using more than the quota value of IP addresses from these service networks.

An example failure to create a VM is shown in figure 3 when the tenancy has run out of IP addresses on a network.

     "info": {
      "errors": {
       "0": "{u'/cloud/public/EoIB-OMS': u'1 IP(s) requested, but only 0 IP(s) available in the vnet.'}"
      },
Figure 3 - No IP addresses available


Conclusion

If a customer has divided their rack into multiple tenancies to run different environments then the quota system is a powerful and useful mechanism to ensure that no users of the system hog the available compute resource.


Friday, January 27, 2017

Serve static web content from Oracle Traffic Director


A colleague of mine, Mark Mundy, recently got a query about using Traffic Director to server static content.  Following on from that he put together this example of how it can be achieved.
Oracle Traffic Director version 12c (12.2.1) does support the serving of static content alongside the existing capability to cache content. More details on how this is achieved can be found here: http://docs.oracle.com/middleware/1221/otd/admin/vs.htm#OTADG3389
With this confirmed, I then utilised the current version of Java Cloud Service on an Oracle Cloud Machine to try out this capability. I created a simple WLS Service based upon 12.2.1 Enterprise Edition and selected to utilise a load balancer for my 2 manged server cluster.  This ensured as part of the service I had provisioned a single instance of OTD 12.2.1 that I could then use to serve static content. 
For this very simple test I created very basic html file that referenced an image file and my plan was to copy these two assets to the local storage of the OTD virtual machine hosting OTD. Below is the html file I used and you can see the referenced image that was stored alongside it. I created a basic index.html to ensure the file was servers when the default uri was accessed.
<HTML>
<HEAD>
<TITLE>OTD is great!</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<CENTER><IMG SRC="stormtrooper.jpg" ALIGN="BOTTOM"> </CENTER>
<HR>
<H1>This is being served by Oracle Traffic Director</H1>
<a href="http://docs.oracle.com/middleware/1221/otd/admin/vs.htm#OTADG24099">OTD Admin Guide : 7.11 Content Serving</a>
is where you will find details on how to do this!
<HR>
</BODY>
</HTML>>

OTD executes under the oracle user and so I created a sub directory under the oracle home to store the html and the image

-bash-4.1$ pwd
/u01/app/oracle/tools/paas/state/homes/oracle/myscontent
-bash-4.1$ ls
index.html stormtrooper.jpg
With the static content in place I now needed to make configuration changes to OTD in order to enable it to be able to served.  Logging into the Fusion Middleware Control UI (OTD 12.2.1’s administration home) from within the JCS UI, I navigated to the OTD configuration already provisioned. I selected the single virtual server associated with the configuration and selected the ‘Content Serving’ section

Content Serving tab in Fusion Middleware Control UI

Here I selected to ‘Create …’ a new content rule
In the dialogue presented I added the following:
Rule to specify location of static content

Once created there is the opportunity to go back into the rule and edit it further should you need to. You can for example allow directory listing if desired.
The rule is immediately activated in the running instance and so it is now possible to use a browser to request OTD to serve the html page.
https://<my_public_ip>/opcm/
This resulted in OTD responding with the default index.html from the directory associated with the rule created. The resulting page looking a little like this below.

Web content delivered from OTD