This project is read-only.


Should be defensive about non-existent user-data


The service crashes if there's no user-data for the instance.
<Data>Application: CloudInit.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Net.WebException Stack: at System.Net.HttpWebRequest.GetResponse() at CloudInit.CIEngine.DownloadFile(System.String) at CloudInit.CIEngine.Execute(System.String) at CloudInit.CIService.Main(System.Object) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()</Data>
I suggest try/catching this bit from CIEngine.cs and logging an error to the log. Took me more time than it should have to to figure out what was wrong (keep in mind reading through the event log is a bit more of a PITA on Server Core with no GUI)
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
request.Timeout = 30000;


bwight4157 wrote Jan 27, 2012 at 6:29 PM

Will defiantly make this as part of a future update. Good point, I've seen the same happen a few times on my own servers.

wrote Jan 27, 2012 at 6:37 PM

wrote Jan 27, 2012 at 6:38 PM

bwight4157 wrote Jan 27, 2012 at 7:55 PM

Packaged this into the 1.2 release. Now when you start CloudInit.NET without a user-data-file you get the following logged to the user log file.

[ 2012-01-27 19:54:00 ] Starting Service
[ 2012-01-27 19:54:00 ] Adding module: CloudInit.Modules.PowershellIncludeModule
[ 2012-01-27 19:54:00 ] Adding module: CloudInit.Modules.PowershellIncludeEncryptedModule
[ 2012-01-27 19:54:00 ] Adding module: CloudInit.Modules.PowershellModule
[ 2012-01-27 19:54:26 ] The remote server returned an error: (404) Not Found.
[ 2012-01-27 19:54:26 ] at System.Net.HttpWebRequest.GetResponse()
at CloudInit.CIEngine.DownloadFile(String url)
at CloudInit.CIEngine.Execute(String scriptUri)
at CloudInit.CIService.Main(Object state)

wrote Jan 27, 2012 at 7:55 PM

wrote Feb 13, 2013 at 10:37 PM

wrote May 16, 2013 at 2:29 AM

wrote May 16, 2013 at 2:29 AM

wrote Jun 14, 2013 at 8:11 AM