This project is read-only.

How can I debug the installation?

Nov 30, 2012 at 12:38 PM

I have installed the service on an EC2 instance leaving the default values in the instal-service.ps1 alone for now.

When I start the instance from the EC2 console using the example .ps1 code shown in the documentation as user-data, it doesn't seem to do anything. How can I debug what is (not) happening?

Nov 30, 2012 at 2:29 PM

You should check to see if it created any Events were created in the event viewer and you can also check for the log file C:\cloudinit.log

There's not really a good way to debug it on the server other than checking for events or errors in the log. If you have the source code you build it in the debug release and it will run as a console app you can debug.

Let me know if you see any events or errors in the log.

Nov 30, 2012 at 4:29 PM

Yes. Events were created. It looks like the CloudInit service is installed but crashes. I try to start it manually, but it immediately crashes again. my guess is permissions on something - although I am currently running the install manually on the EC2 instance logged in as Administrator.

Two event errors:

Error 1

Log Name:      Application
Source:        .NET Runtime
Date:          11/30/2012 3:47:32 PM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      AMAZONA-RTCD497
Description:
Application: CloudInit.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException
Stack:
   at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(System.String, System.Security.Policy.Evidence, Byte[], System.Configuration.Assemblies.AssemblyHashAlgorithm, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
   at System.Reflection.Assembly.LoadFrom(System.String)
   at CloudInit.CIAssemblyLoader+<GetAssembliesInDirectoryWithExtension>d__3.MoveNext()
   at System.Linq.Buffer`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)
   at System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
   at CloudInit.CIAssemblyLoader.Configure()
   at CloudInit.CIService.Main(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   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()

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2012-11-30T15:47:32.000000000Z" />
    <EventRecordID>55706</EventRecordID>
    <Channel>Application</Channel>
    <Computer>AMAZONA-RTCD497</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: CloudInit.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException
Stack:
   at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(System.String, System.Security.Policy.Evidence, Byte[], System.Configuration.Assemblies.AssemblyHashAlgorithm, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
   at System.Reflection.Assembly.LoadFrom(System.String)
   at CloudInit.CIAssemblyLoader+<GetAssembliesInDirectoryWithExtension>d__3.MoveNext()
   at System.Linq.Buffer`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)
   at System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
   at CloudInit.CIAssemblyLoader.Configure()
   at CloudInit.CIService.Main(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   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()
</Data>
  </EventData>
</Event>

Log Name:      Application
Source:        Application Error
Date:          11/30/2012 3:47:35 PM
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      AMAZONA-RTCD497
Description:
Faulting application name: CloudInit.exe, version: 1.3.324.5247, time stamp: 0x4f6ddb85
Faulting module name: KERNELBASE.dll, version: 6.1.7601.17651, time stamp: 0x4e21213c
Exception code: 0xe0434352
Fault offset: 0x000000000000cacd
Faulting process id: 0xf50
Faulting application start time: 0x01cdcf12013fed13
Faulting application path: C:\CloudInit.NET\CloudInit\CloudInit.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 420532c9-3b05-11e2-a098-b4733195a0f8
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>100</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2012-11-30T15:47:35.000000000Z" />
    <EventRecordID>55707</EventRecordID>
    <Channel>Application</Channel>
    <Computer>AMAZONA-RTCD497</Computer>
    <Security />
  </System>
  <EventData>
    <Data>CloudInit.exe</Data>
    <Data>1.3.324.5247</Data>
    <Data>4f6ddb85</Data>
    <Data>KERNELBASE.dll</Data>
    <Data>6.1.7601.17651</Data>
    <Data>4e21213c</Data>
    <Data>e0434352</Data>
    <Data>000000000000cacd</Data>
    <Data>f50</Data>
    <Data>01cdcf12013fed13</Data>
    <Data>C:\CloudInit.NET\CloudInit\CloudInit.exe</Data>
    <Data>C:\Windows\system32\KERNELBASE.dll</Data>
    <Data>420532c9-3b05-11e2-a098-b4733195a0f8</Data>
  </EventData>
</Event>

 

Nov 30, 2012 at 6:45 PM
Edited Nov 30, 2012 at 6:48 PM

Please check that there is a registry key named HKLM\SYSTEM\CurrentControlSet\services\CloudInit\Settings\LogFile

It could be that the installation was not successful. When the service installs it creates a user  named cloudinitservice and adds them to the Administrator group. If this user was not created or the registry keys were not created then this could be the cause of the errors. You dont need to use the cloudinitservice user any user with registry access to HKLM\SYSTEM\CurrentControlSet\services\CloudInit and file system access for the logs should work.

 

Edit:

Sorry it looks like its throwing errors when its looking for the module dlls that should be in the same directory. What does your CloudInit directory look like?

Nov 30, 2012 at 8:23 PM
Edited Nov 30, 2012 at 9:47 PM

When I debug using the source an exception is thrown as it can't read the default user-data file http://169.254.169.254/1.0/user-data. Was I meant to change that to one of my own?

EDIT: Sorry. I just read what that url does:-(

There is a registry key named HKLM\SYSTEM\CurrentControlSet\services\CloudInit\Settings\LogFile and it contains C:\CloudInit.log. It only one entry for each time the service tries to start:

[ 2012-11-30 20:09:57 ] Starting Service

Here is the folder:

Directory: C:\CloudInit.NET\CloudInit

-a---        11/28/2012  12:31 PM      24738 about_signing.txt
-a---        11/28/2012  12:23 PM      15872 CloudInit.Configuration.dll
-a---        11/28/2012  12:23 PM     262144 CloudInit.exe
-a---        11/28/2012  12:23 PM       7680 CloudInit.Modules.Core.dll
-a---        11/28/2012  12:23 PM       7680 CloudInit.Notification.Core.dll
-a---        11/30/2012   4:18 PM       3691 install-service.ps1
-a---        11/28/2012  12:23 PM        788 install.ps1
-a---        11/30/2012   4:20 PM       1539 powershell.exe - Shortcut.lnk

Nov 30, 2012 at 11:09 PM

Yes, when you start the instance you need to provide your own user data script for the service to run or when it tries to download http://169.254.169.254/1.0/user-data it will crash.

Dec 1, 2012 at 7:32 PM
Edited Dec 1, 2012 at 7:32 PM

btw I see the binaries install-service.ps1 has $runOnce = 1. I think this means once it has run the service, it is disabled and never, ever runs again. Is that right? If so, then I assume repeated reboots for testing will fail to run the service?

Dec 2, 2012 at 1:47 PM

It runs fine now. I don't really know what I did wrong, but whatever it was is fixed.

Dec 3, 2012 at 2:18 PM

Yes the $runOnce option is to stop the service from executing if the server is rebooted. All it does is disable the service once the script has been run. If the script fails the service is still disabled. You can manually re-enable the service by setting the service to 'automatic-delayed'.