Come see our lovechild

Our lovechild aptly named LightlyCloudy, was as you know - spawned by Quick and Dirty, and YOU are hereby invite to the baby shower. As the proud Godfather I'm back as promised, I have been doing some node.js programming and completed first production release of lightlycloudy. This is what users are met with after they login, quite soothing on the eys.

list_screen_capture

 

 

 

 

 

I have been heavily critized for that it's looks too much like the IBM or BSOD color scheme, I have carefully listend to the cirtisizm, and subsequently chosen to ignore it completely. I have shown the source code to some collegues and asked them to help me sexify the GUI. One guy willingly said "no, problem, I will do that before breakfast, what frameworks do you use?" and I replied "none...." and then he said "...oh, so it's really old skool", and then I didn't hear from him again, typical.

To summarize the lessens learned during this process were;

Asynchronus programming i.e. debugging is quite interesting, just like this blog entry suggests, it's like learning to program all over again.

The SmartOS commands vmadm, imgadam and nictagadm, does not strictly adhere to standard UNIX conventions regarding stdout stderr exitcode, which makes debugging a hassle combined with the asynchronus nature of node.js.

Sometimes it's just easier and faster to make a shell script than mess around with asyncronus node.js code. For this reason we made the nictagvms script which resides in the /usr/local/bin directory in the lightlycloudy zone, but is actually executed from the global zone. This way all code can be contained within the lightlycloudy zone.

Dependencies are still not good. I started using off by using the SSH2 framework, but due to a buffer error in the framework, I decided to drop it and use the built in function for executing shell commands.So there are no frameworks whatsoever, it's pure uncut node.js straight from the source.

Speaking of source, you can download it from Github There is a README included file which contains the very simple installation procedure.

Now we just need a project mascot, I was thinking something soft, cuddely and nice smelling like Ashley, click on the picture to see the full picture. 

Ashley-LightlyCloudy

So now I'm working on version 2 of the application. I will try to incorporate support for multiple hypervisors and prerequisite check for creating and updating virtual machines.

I'm still looking for contributers, so don't be reluctant, it's my party and YOU are invited.  

Quick and Dirty spawned LightlyCloudy!

Yes, yes, FiFo is still down and customers are crying their eyes out, and I have listed the various alternatives to FiFo in my last blog, now - which one of these options would satisfy all our needs?

None.... so my solution is; write a new GUI ourselves, I mean how difficult can it be? My argument is that since we only need basic functionality to start with, then all we have to do is write some kind of webified wrapper for imgadm and vmadm which seems easy peasy.

As soon as I had finished my thought, the young office punk started to argue that it was a complete waste of time. It is much better to contribute to the existing FiFo project in unison with all the other contributors and reap all the inherent benefits of a real open source project he argued. But I was not entirely convinced, the FiFo project has already grown out of proportion and I was confident that no one else would subscribe to my minimalistic approach.

foto_5

 

 

 

 

 

 

In the above picture the resident office punk is in the process of convincing me (it's me on the floor) about all the happy joys and benefits of Open Source and that sharing is caring. After being overwhelmed by loving arguments, I agreed to publish the source code on Github if ever I got around to program the darn thing.

In an effort to keep things simple and not fall in the same pitfalls as FiFo it is nessecery to keep ambitions to an absolute minimum, or even better, don't have any ambitions at all. In any case the ambitions or lack of same amount to:

Main features

Simple Graphical User Interface written in node.js running in a single SmartOS Zone. Management is done via SSH into Global Zone. All machine and User infoirmation are stored in JSON files.User sessions are tracked with a single cookie.

User Access Control

  • Logon
  • Logoff

Virtual Machine administration

  • List
  • Create
  • Delete
  • Start/Stop/Reboot
  • Update
  • Snapshot create delete rollback
  • Get VNC info
  • Automatic IP delegation

As you can probably see from above, it is very lightweight; hence the name LightlyCloudy for this project was born. There is only one external dependency which is SSH2 and it's used for the purpose of SSH'ing into the Global Zone and execute the imgadm and vmadm commands. And you will also notice the complete lack of a backend database, there are simply no justification for using a database and add unnecessary complexity with the amount of users we plan to support.

Since we have no immediate plans to save the entire world within the next weeks, there are some features that will have to wait for version 2.0 of LightlyCloudy. They are, just to list a few; support for multiple hypervisors, virtual network administration, prerequisite checks, and performance considerations.

Now with a clear plan in mind I started to write the all the code by myself, I'm still looking for voluntary contributors, but haven't found anyone yet, I'm considering to adopt the convincing methods I've learned earlier.

Anyway, stay tuned for next episode, where I will share the code and experiences gained with anyone interested.

Disaster strikes in Private Cloud country

In my last blog we saw how to manage the private cloud, and now the unthinkable happend, suddently our management system called FiFo stopped working all by it self...When clickking on the tabs it does not display any content, and below is a screenshot of what the js console reports:

Capture_FIFO_ERROR

 

 

Fortunately the underlying SmartOS and all the Virtual Machines keept on working as if nothing happend at all.. But now our users are unhappy because they can't manage their Virtual Machines through a GUI, I think the below picture tells more than a thousand words :-(

unhappy-fifo-user

 

 

 

 

 

That's me on the right, trying to comfort one of our dearest customers...

Obviously we sought help in the FiFo googlegroups, and the guys there are pretty fast to respond and offer suggestions. We started to debug as per their suggestions and this checklist, but as we soon discovered, it was an insurmountable task due to the complexity of FiFo, even the log files did not give any hints as to the root cause of the problem.

So we abandoned the attempts to recover FiFo and decided to go for a new install, but unfortunately the FiFo database would also be overwritten by a new install, so this was not a viable option as we have a lot of user information in the database. Subsequently the new install attempt was also abandoned.

As a last resort we followed the upgrade guide from a-z, the upgrade was successful - but FiFo refused to restart after the upgrade, and our customers remains unhappy, what to do? Obviously FiFo is time being not the ideal way for us to pursue, we have to look into alternatives.

So what are the alternatives? well, if we look in the market there are OpenNebula, OpenStack, CloudStack and obviously SmartDataCenter. SmartDataCenter is not really an option, since it costs a lot of money, and we can't justify such expenses at the moment. What concerns the first three alternatives there are no support for the SmartOS hypervisor and there are no current plans to support SmartOS.

We could contribute to the efforts by Hendrik Volkmer to port openStack to SmartOS, but completion is no where to be seen as people also have dayjobs to care for and the task is complex, and then there are all of the subsequent maintenance to secure continued compatibility.

OpenNebula, OpenStack, CloudStack all support the AWS EC2 API, which means that we could write our own web service that runs on SmartOS and is EC2 compatible. Again the task is complex, and then there are all of the subsequent maintenance to secure continued compatibility.

We could also contribute to the FiFo project - but again, it's complex and FiFo tries to be omnipotent just like the other four alternatives, and we don't have time to wait for a workable product when our customers demand it now and not tomorrow!

Stay tuned for the next exiting part in this series, to see how we solved the problem.

Orchestrating your Private Cloud

In my last post I covered the process of seting up a private cloud. Ok, so now we have the darn thing up and running, and the big question remains, how do we sell it to our internal and external customers?

As with all things you must give the people what they want and they will come, and only thereafter you can sell them what they yet don't know they need. So, in Anno Domini 2014 the customers crave virtualisation because then they can continue using their familiar legacy environmets.

Fortunately SmartOS have KVM feature that supports virtualisation of most types of OS'es, which is all fine, but how can you provide that all important self-service to your customers? most of our end users are command line impared, so what we really need is a fancy GUI that will enable customers to easily create and manage their virtual machines on a wholesale basis.

There are currently only two such cloud orchestration products available, the first is Joyents propritary solution the SmartDataCenter, which is a complete enterprise solution, and then Project FiFo which also is enterprise (like) and at that also open-source.

showcase-4-fifo

 

 

 

 

The choise was fairly simple for us, since we time being can't justify the purchase of a copy of Joyents SmartDataCenter, we are left with only Project FiFo. We downloaded version 0.4.1 - "Hopping Husky" and the installation was simple and straight forward, and we had a usable GUI up and running in absolutely no time.

FiFo want's to do everything you would ever need when you have a private cloud to manage.... except serving virtual machine images. What FiFo does instead, is to connect to e.g. datasets.at and datasets.joyent.com but none of those servers offer Windows images for obvious license reasons, since our marketing stategy is to proliferate our private cloud among Windows developers too, we need to create our own image server.

If you wan't to make your own image server there are two alternatives. The first solution is suggested by Joyent Creating a Poor Man's Image Server, but FiFo is only compatible with the new API so this solution is not workable. The second alternative is Setting up a local Dataset API repository for SmartOS (dsapi) the setup is fairly simple and straight forward.

The only minor complaint about this image server is that it is using memory ad libitum, you need to allocate memory that is twice the size of your image file. In our case we have a 8Gb Windows Server 2012 image, so we need to permanently allocate 16 Gb of RAM, which is kind of a waste of memory.

happy-fifo-user

Now we have our private cloud completely up and running, and everyone is happy. Above is a picture of me (left) with one of our numerous happy users.. to be continued.

The birth of a Private Cloud

After some discussions with my collegues we decided to make a Private Cloud, it is obviously the future of the datacenter, and it's better to lead than follow, easier said than done...

Our private cloud is intended to serve the following purposes:

  • Testing and developing cloud technologies
  • Deliver wholesale virtual machines to our various development departments
  • Showcase for potential clients

SmartOS seems to be the logical choice if you don’t want to go down the path trodden by Oracle, Microsoft, Citrix, VMware and their rather bloated cloud solutions. There are other good reasons why to choose SmartOS, but is better if you read some of the many other blogs covering this issue. So, SmartOS it is!

 

 

 

Since I have access to our own friendly datacenter, I thought it would be quickest to boot SmartOS on some of their Cisco UCS B200 M2 servers. But here we encountered the first problem, apparently the available network drivers are not SmartOS compatible, and the attempt to make SmartOS run was aborted by the hosting techies. Here is the error they showed me:


Instead of wasting more time I decided to procure some hardware that is verified to work with SmartOS from the "Works for Me" Hardware Configurations page.  The decision fell on the following configuration X9DR7-LN4F from Supermicro, 2 x Intel E5-2620 2GHz 6-core, 256MB DDR3 1600MHz, 6 x 1TB SAS2 discs.

Here is a picture of my first server in an old chieftec chassis, stuffed like a Christmas turkey. Note the USB stick in the bottom, I followed the instructions on Creating a SmartOS Bootable USB Key and then SmartOS booted without problems from the USB key.

 


The stuffing is now in the process of being moved to a SuperChassis 826BE16-R920LPB chassis so that we are able hot-swap the disks.

Being happy with the chosen configuration I ordered a second server with the same configuration, fully assembled and burn-in tested. The costs amount to about €4,300 for this fine server (Anno Domini 2013). So now we have two similar servers enabling us to test in a real private cloud environment.

The next step is to rack mount both servers in our top-secure-redundant datacenter.

install_odbc.exe fails on prerequisite check

To install Oracle ODBC drivers you first download and unpack the zips into a common directory

instantclient-basic-win-x86-64-xx.x.x.x.x.zip
instantclient-odbc-win-x86-64-xx.x.x.x.x.zip

When trying to install the Oracle ODBC drivers with install_odbc.exe, you might sometimes experience the dreadded error message

Could't find Oracle Instant Client in present directory

The reason for this is a buggy prerequisite check.

All you need to do to install the ODBC drivers without install_odbc.exe is to add these registry entries on the client computer, here shown in PowerShell format, and Bob's your uncle

$ver = '11_2'
$regpath = "HKLM:\SOFTWARE\ODBC\ODBCINST.INI\Oracle in instantclient$ver"

New-ItemProperty -Path 'HKLM:\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers' -Name "Oracle in instantclient$ver" -PropertyType String -Value Installed
New-Item -Path $regpath New-ItemProperty -Path $regpath -Name APILevel -PropertyType String -Value 1
New-ItemProperty -Path $regpath -Name ConnectionFunctions -PropertyType String -Value YYY
New-ItemProperty -Path $regpath -Name CPTimeout -PropertyType String -Value 60
New-ItemProperty -Path $regpath -Name Driver -PropertyType String -Value "C:\Oracle\instantclient_$ver\SQORA32.dll"
New-ItemProperty -Path $regpath -Name DriverODBCVer -PropertyType String -Value 03.51
New-ItemProperty -Path $regpath -Name FileUsage -PropertyType String -Value 0
New-ItemProperty -Path $regpath -Name Setup -PropertyType String -Value "C:\Oracle\instantclient_$ver\SQORAS32.DLL"
New-ItemProperty -Path $regpath -Name SQLLevel -PropertyType String -Value 1

Messing around with ZFS pool on SmartOS

I recently started experimenting with smartOS from Joyent, you know, the Solaris based virtualisation OS. Being a long time Windows user I'm easily impressed by the various features offered by other *UX like OS'es, and this time it is the hotplug disks and the zpool command that have my interest. In windows it is always a pain to expand disk capacity on a live installation, so behold my amazement when I discovered how simple it is done under ZFS  ....

So lets start by taking inventory

[root@00-0c-29-92-3b-ab ~]# zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ    CAP  DEDUP  HEALTH  ALTROOT
zones  15.9G   842M  15.1G     15.6E     5%  1.00x  ONLINE  -

As you can see, we have a 15.9G ZFS pool named 'zones'

[root@00-0c-29-92-3b-ab ~]# zpool status
  pool: zones
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        zones       ONLINE       0     0     0
          c0d1      ONLINE       0     0     0

And the ZFS pool 'zones' consists of only one disk 'c0d1'. The next thing to do is to plug in a few more disks, however until my new Blade serveres have been provisioned I'm unfortunately stuck with my VMware, so it is not possible to simulate hotplug without restarting the VM. Anyway I created a 5G (c0d0) disk on the PCI bus and a 7G (c2t1d0) disk on SCSI bus, and rebooted the entire thing in order to run the format command.

[root@00-0c-29-92-3b-ab ~]# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c0d0 <Unknown-Unknown-0001 cyl 2557 alt 2 hd 128 sec 32>
          /pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0
       1. c1d1 <VMware V-0000000000000000-0001-16.00GB>
          /pci@0,0/pci-ide@7,1/ide@1/cmdk@1,0
       2. c2t1d0 <VMware,-VMwareVirtualS-1.0 cyl 3582 alt 2 hd 128 sec 32>
          /pci@0,0/pci15ad,1976@10/sd@1,0

As you can see from above we now have three disks on the system, so lets add c0d0 to the pool

[root@00-0c-29-92-3b-ab ~]# zpool add zones c0d0
[root@00-0c-29-92-3b-ab ~]# zpool status

  pool: zones
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        zones       ONLINE       0     0     0
          c1d1      ONLINE       0     0     0
          c0d0      ONLINE       0     0     0

[root@00-0c-29-92-3b-ab ~]# zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ    CAP  DEDUP  HEALTH  ALTROOT
zones  20.8G   842M  20.0G     11.6E     3%  1.00x  ONLINE  -

We now have 20.8G in the pool, success! what if we try to add a partition? using the format command I created three partitions on c2t1d0

Total disk size is 3584 cylinders
             Cylinder size is 4096 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 Solaris2          1   716     716     20
          2                 Ext Win95       717  1432     716     20
          3                 Solaris2       1433  2865    1433     40

 

Lets add partition 1 to the pool

[root@00-0c-29-92-3b-ab ~]# zpool add zones c2t1d0p1
[root@00-0c-29-92-3b-ab ~]# zpool status

  pool: zones
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        zones       ONLINE       0     0     0
          c1d1      ONLINE       0     0     0
          c0d0      ONLINE       0     0     0
          c2t1d0p1  ONLINE       0     0     0

[root@00-0c-29-92-3b-ab ~]# zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ    CAP  DEDUP  HEALTH  ALTROOT
zones  22.2G   842M  21.4G     11.6E     3%  1.00x  ONLINE  -

And success again, we have added partition 1 (20% og 7G) to the pool and now command over 22.2G

Extreme Threadpoolin’

Recently I was approached by a colleague who asked me a couple of questions about ThreadPool. Firstly what is the maximum number of concurrent threads when using ThreadPool? And secondly he was experiencing some undesirable uneven processor load on a multi core system, what could be the reason? All in all some interesting questions.

The Windows operating system have no hardcoded fixed upper thread limit, but the number of threads is ultimately limited by the size of available memory and other basic resources. Generally speaking on a 64-bit system the default stack reserve for a single thread is 256K and typically 24K is committed. I suggest reading Pushing the Limits of Windows: Processes and Threads by Mark Russinovich for a more in-depth discussion about memory limits.

But according to Microsoft documentation, the ThreadPool itself has a built-in upper limit of 32.737 threads on 64 bit platforms as of .NET version 4.0 (however only 1.023 threads on 32 bit platforms). Ok, that was pretty easy, but unfortunately here in the year 2013 it is only possible to exhaust the ThreadPool and still have a responsive system, if your threads aren’t doing any real work. In real life applications you will hit other constraints before you manage to exhaust the ThreadPool.

Besides the memory limitations, the other obvious limitation is the number of physical CPU threads. These threads also have to serve the ThreadPool along with the operating system, needless to say that CPU time slices quickly can become a limited resource. The best practice for economizing with CPU threads is to suspend ThreadPool thread execution whenever possible and especially by using asynchronous methods, following this simple design rule will give you better thread mileage even if you are not performing CPU intensive tasks.

Another major constraint is when your application is relying on 3rd. party services, this is very difficult to diagnose because it is not always obvious when you have reached a limit, and the lack of immediate performance indicators can make the diagnostics an exercise in guesswork. I found that, implementing “thread wait reporting” is very helpful i.e. when a thread reaches a certain wait threshold it reports the offending task e.g. a WebRequest, and from then on it is a simple matter of addition to identify the bottleneck. Remember that your multimega-threaded high-performance application is only as high-performance as the bottleneck.

So the answer to the question of maximum number of concurrent threads, I would say ”it depends” but theoretically it is 32.737 concurrent threads.

Regarding the matter about undesirable uneven processor load, the ThreadPool was specifically designed to remove all the headaches of manual managing of threads, it has been developed over many years and is doing a very good job at scheduling tasks for execution. Therefore I must admit that I was really surprised to hear about such behavior, so I made a simple application that fires up 4000 threads that each calculates a factorial recursively. As you can see from below taskmanager screenshot, ThredPool does a really awesome job of managing the threads and spreading the load evenly.

 


So the only explanation that I can come up with is that something in the application have altered the process’s ProcessorAffinity which forces spawned threads to run on a specific subset of processors. As you can see from below taskmanager screenshot, I have set my application to run on only 2 processors, so I think this might be the most plausible explanation.

 

A final note, ThreadPool may not be suitable for all purposes, but it’s my favorite choice when it comes to quickly fire up several thousands identical threads without having to waste time on thread management considerations.

T-SQL Group by n-minutes

There are literally hundreds if not thousands of articles on the internet explaining how to group by n-minutes, most of them utilizes this technique:

DATEADD(MINUTE, @interval *(DATEDIFF(MINUTE, '20000101', sampletime) / @interval), '20000101')  

Above will round sampletime to nearest 10 minutes interval which is desired in some cases, but if you e.g. use aggregate functions, your result will only be correct each n’th minute. Therefore I have created this little query which do not round, and is excellent for graphing time sensitive data.

DECLARE @starttime DATETIME = GETDATE() -- Start grouping from here
DECLARE
@lookback INT = 120 -- Group backwards 120 minutes from start
DECLARE
@interval INT = 20 -- Group in intervals of 20 minutes

SELECT
(t.sampleinterval * @interval) AS [+ Min], AVG(querydc) AS [QueryDC]
FROM
(SELECT FLOOR(DATEDIFF(MI, sampletime, @starttime) / @interval) AS sampleinterval, querydc
       FROM dbo.mylogtable
       WHERE (sampletime >= DATEADD(MI, -(@lookback-1), @starttime)) AND(sampletime <= @starttime)) AS t

GROUP
by t.sampleinterval
ORDER
by t.sampleinterval

Below  is the output it generates, if  @starttime is e.g. 12:13 then the first row will show the average value for QueryDC in the interval between 12:13 and 11:53, and the second row in the interval between 11:53 and 11:33 etc. etc.

+ Min     QueryDC
-----------------
0         64
20        70
40        69
60        90
80        102
100       157

SAP long text formatter

A common problem with SAP applications is that they save free text with each line in a database column; this presents some extra formatting hassle if you want to save free text from many different sources. For this purpose I have created a small application that takes some seemingly garbled text and formats it into a readable SAP friendly format.


The text must obey a few simple rules. Bulleted paragraphs may not contain any empty lines, valid bullets are sequential numbers or letters or •

Try copy the below text into the application found here to test for your self

SAP, started in 1972 by five former IBM employees in Mannheim, Germany, states that it is the world's largest inter-enterprise software company and the world's fourth-largest independent software supplier, overall.

1. The original name for SAP was German: Systeme, Anwendungen, Produkte,
2.               German for "Systems Applications and Products." The original SAP
               3.              idea was to provide customers
with the ability to
      interact with a common
corporate database for a comprehensive range of applications.
a.Gradually, the applications        have been assembled and today many corporations,
b.including IBM and Microsoft, are using SAP products to run their own businesses.
• SAP                 applications, built            around their latest
                R/3 system, provide the capability to
manage financial, asset, and cost accounting,
• production operations and materials, personnel, plants, and archived documents. The R/3 system runs on a number of platforms including Windows 2000 and uses the client/server model. The latest version of R/3 includes a comprehensive Internet-enabled package.
c.  SAP has recently recast its product offerings under a comprehensive
d.                   Web interface, called mySAP.com, 
and added             new e-business applications,
including customer      relationship management
                       (CRM) and supply chain management (SCM).
4. As of January 2007, SAP, a publicly traded
company,
 had over 38,4000 employees in over 50 countries,
5. and more than
36,200 customers around the world. SAP is turning its attention to small- and-medium sized businesses (SMB).

•A recent R/3 version was provided for IBM's AS/400 platform.

Month List

RecentPosts