Thursday, July 31, 2014

TFS Batched Gated Build – Stopping the starvation

Until TFS 2013 only one gated check-in build was allowed to run consecutively, this caused, in medium and large size development teams, resource “starvation”.
Only one validation process ran for each check in, causing either a long queue and delay in development process and code sharing or a short and insufficient validation process rendering the gated build validation system redundant.
No more, in TFS 2013 a new option was added (batched gated build).
Let a step back to remind ourselves that the purpose of gated build is to protect the product from breaking on a single developer error. When it is short and quick (only validates compilation for example) it provides little protection, on the other hand if adding validation steps (tests etc.) “Costs” valuable time.
For example 30 minutes validation in a 5 developer team can cause a request to wait over 2 hours in line for validation.
Batched gated build helps solving this issue.

When setting up a build definition trigger you can determine the maximum amount of shelvesets (check-ins) you want merged when in queue.

This will cause several check-ins to run together in a single validation build.

The logic of the trigger is pretty simple: when a build is queued and the queue is empty it starts right away, if a build is already running the request will be queued, after the build is completed the server will queue the next batch in the queue together up to the number stated in the build definition.
From my experience this practice drops wait time significantly, and speeds up the development and sharing for the team.
This does not come without implications or concerns though, here are five:

 What happens if a batch fails to merge while unshelving?
When several shelvesets are unshelved together there can be conflicts (this can happen even with a single shelveset if the baseline of the shelveset is not the latest version of code). The build process template, by default marks each build request for retry (only in the Get workspace and unshelve process), the retry request will state that when this shelveset is retried it will run without a batch.

The retry behavior options are:
Do not Batch – each failed request in a batch will be retried separately by the server.
Batch Dynamically – the build server will allow retried requests to be batched regularly in the queue.
Batch Isolated – the Batch will only be retried with the requests it originally ran with.

 How to setup automatic retry for a batch?
In order to have the build server automatically start failed requests ahead of the queue you can use the “Force Retry” option.

 How to avoid an endless loop of automatic attempts?
Using the “Force” option should only be attempted with “DoNotBatch” behavior to avoid endless loop of failed Builds.

 What happens if a batch fails to validate?
The retry requests activity in the default process template resides only in the “Get Workspace” step, so other failures is not treated the same by default. You can, however use in again (by creating a custom template) in the workflow with a simple logic that will retry batched requests on their own automatically ahead of the queue and mark an unlatched request for retry Dynamically (not Automatically, of course).

 Force = True, DoNotBatch            Force = False, BatchDynamically

      What is the optimal batch size?
Using this (Kung Fu) tricks will shorten the build queue indeed but you should beware of trying to setup to small or to large batch. Keeping in mind, that with auto retry, each failed batch can take up to n+1 times of the average build time (n being the batch size). Setting batch size to small will not speed up queue progress and to big can hang the queue for a long time to validate the error.
Large batch size can increase the probability of merge conflicts as well.
My educated guess is to keep the batch size between 3 to 5, this should shorten the wait time significantly and not block the queue for excessive time on failure.

To sum up: the batched build solution is optimal for using gated check-in validation without the resource starvation it used to cause. There are other issues to be taken into consideration like modifying the shelveset validation and merge process and customize the build process to save time. Furthermore, by using batched builds a single developer can block the queue for a long time [(Batch size + 1)X(Average Build time)]. Analyzing, publishing and reporting the “shame list” of developers that checked in invalidated code causing resource starvation once more can motivate your team to run local pre validation, which will result in improving your developers as well as code while keeping the product stable (win-win-win).

Till next time.

Tuesday, January 8, 2013

SharpSSH - OpenSSH for .NET and Make-it-so sln to makefile converter

Creating cross platform build automation for compiling C++ code on MSVC (MSBuild) and g++ (GCC) was the task at hand. On the agenda was how to invoke shell commands and scripts on a Linux machine, and how to securely transfer files to and from said machine. The answer is obvious ... SSH (Secure Shell). Well, when working on Linux and UNIX machines SSH is a native tool in your toolbox, this is not so when adjusting a Microsoft Team Foundation Server 2012 to perform these tasks. To the rescue comes SharpSSH , which is a pure .NET implementation of the SSH2 client protocol suite. It provides an API for communication with SSH servers and can be integrated into any .NET application. SharpSSH allows you to read/write data and transfer files over SSH channels using an API similar to JSch's API. In addition, it provides some additional  wrapper classes which offer even simpler abstraction for SSH communication. using this easy-to use library I was able to create a TFS Build workflow code activity and design the build process template to run Bash scripts, send the source code and get the build outputs from the target Linux machine. All this sounds rather simple ... well it wouldn’t had been compete without the icing on the cake ...  Make-it-so, that converts Visual Studio solutions to Linux gcc makefiles. It needed a few tweaks to fit to the format of VS2012 sln format, but it was worth every minute. During my work I used some manual tools to run tests manually like Putty and winscp, and custom executable I wrote from SharpSSH to run manually from PowerShell.
There was only one twitch I found in this, otherwise, us full handy tool. It sets its own default environment variables (like PATH) so things don't run as smoothly as you would have expected like with native ssh. Discovering this was not without its share of trouble, things started to go "south" when I tried using complex commands like sedgrepchmod and other native shell commands. Running the scripts manually turned a different result then via my SharpSSH client and it took me a while to try to look for the reason. In the end I, of course, found and fixed the issue.
Another useful tip when writing scripts for different platforms is that windows text editors hide special characters (like - for end of line and for backspace) and editing Bash scripts with any of those will usually case the script to fail :) (That’s why god invented  vi for). to sum things up, cross platform is as cool and fun as it is interesting and informative.
This solution may prove handy the next time you want to write g++ compatible c++ code and use the comfort of visual studio as you IDE... have the best of both worlds.
'till next time  ... be free
 next ... CodeWeavers CrossOver and eclipse team explorer everywhere plug-in ,or maybe I'll conduct a comparison between remote PowerShell and SSH ... neh ... this is pointless.

Monday, January 7, 2013

Grawcho: searching for out of circulation IKEA product (TRO...

Grawcho: searching for out of circulation IKEA product (TRO...: does any one know of a way to get IKEA products that went out of circulation i bought some curtain rod's to make a  pseudo dark room dryer f...

searching for out of circulation IKEA product (TROLIG)

does any one know of a way to get IKEA products that went out of circulation i bought some curtain rod's to make a  pseudo dark room dryer for family photos.

and IKEA had stopped making them. i need a couple more (even used) to continue my project with them in an esthetically pleasing manner :)
rather then mixing, matching and \ or replacing all of them all together.
if you know of anyone that has one of them and is willing to give it up, please, let me know.
this it how it looks


Monday, September 3, 2012

Help The helpers ...

Hi again.
as you may have asserted i have new found respect for Microsoft with the new Windows 8. i have some "Air Time" with it too, i installed a machine for every preview version available (developer, consumer and release previews). in anticipation for the official release, and been an MSDN subscriber, i went ahead and assumed this will profit me in the long run.
I assumed that i will be able to upgrade my edition, and keep the hours of work put in to customize my machine.

guess what ..... i was WRONG !!!

after trying everything except for installing a fresh install (on a formatted partition), i was referred to this post and followed it. At first it looked promising (may i quote from the post: "Keep in mind that this is not supported, and could end up with a catastrophic failure if some bits are not properly upgraded,")

an of course after the third re-start, i was forced to to what i didn't want to do in the first place

Re-install (at least restoring from the web is fast).

why oh why do i like to help out ?

see you soon.


Friday, August 17, 2012

מדריך לבניית אתרי אינטרנט או המוסד לביטוח לאומי - שרות ונגישות מעל הכל

בעוונותיי אני נאלץ לשלם לביטוח לאומי, עד כאן הכל בסדר. יש אפילו אתר אינטרנט אשר בו אזרחי המדינה (הריעו לריבון) יכולים בנוחות ובצורה מאובטחת לשלם את מסיהם

אצתי, רצתי למחשב הקרוב למקום מגורי (פשוט שלפתי את הלפטופ מהתיק) ופתחתי את הדפדפן החביב עלי (בלי לנקוב בשמות) והפלא ופלא ... כלום, פשוט כלום

מוטב מראה עיניים
  כפי שוודאי אתם שמים לב... כך קשה במידה מסוימת לשלם מיסים, אך, לא לי
הנחתי שמדובר בבעית תאימות ולכן ניסיתי (ללא הצלחה) עוד מספר דפדפנים (שהציגו תמונה דומה) ומספר אמולטורים (מדמי תצורה) לפני שניגשתי ל"דבר האמיתי" הדפדפן האימתני של מיקרוסופט ... אינטרנט אקספלורר 10

הוא בטח יציל אותי ... הכל בנוי להתאים לו, ובטח אתרי האינטרנט של הרשויות אשר בחרו במיקרוסופט (בצדק) כספק התשתיות מס 1 שלהם ... את ההפתעה שציפתה לי ניתן להראות רק בתמונות

עכשיו ... אתם מתבוננים בתמונה ואומרים לעצמכם ... "על מה הוא מדבר?" הכל עובד ... אני אמרתי אותו דבר, ואז גיליתי שאין באתר כפי שהוא נראה שאף לא אפשרות פעולה אחת

לכן הפעלתי מחדש דפדפן אחר (פיירפוקס 14.0) וניסיתי דבר שלא היה עולה על דעתי לנסות אלמלא הוא עבד
הפעלתי תוסף*  שמפעיל את אקספלורר דרך פיירפוקס, לא לא, זה לא עוד מדמה או אמולטור זה ממש להריץ דפדפן אחד דרך ממשק משתמש של דפדפן אחר. וכפי שציינתי התוצאות היו מעבר לכל דמיון

כעת אני (וכל בני ישראל אשר מבינים "מעט" כמוני במחשבים) לשלם את חובותיי (אשר הלכו ותפחו מול עייני בזמן הנסיונות לשלמן) בנוחות וביעילות

אה... ועוד משהו קטן ... בעת הכניסה לאתר, משיקולי אבטחה, מוצגת שאלה אשר מבקשת מהאזרח להקליד את האותיות שבתמונה, לא תאמינו באיזה צירוף מקרים נתקלתי, כשראיתי את זה חשבתי שפשוט יש מישהו בביטוח הלאומי שפשוט צוחק עלי
לזה אני קורא צדק חברתי

עד הפעם הבאה

 (IETab לתוסף קוראים)*

Wednesday, June 6, 2012

Painstaking tasks (recursive archives)

Hi all ... this is another example of how to apply the "longer path" approach

isn't it annoying to unzip an archive only to find out that it contains another archive ?
here is a sipmle shell script that will help you unzip archives recursively...

I called it "rezip", it carries the same functionallity of originall "zip" command

ToDo: make it indifferent to type of archives (people tend to get clever and switch archiving methods)

'till nex time