AWS has recently introduced a few changes to their meta-data system which has inadvertently caused instances using older RightImages to fail at boot time. The following guide contains answers for commonly seen problems that have arisen since this change.
v 4.x Linux RightImages
/var/spool/ec2/meta-data.rb:4:in `require': /var/spool/ec2/meta- data-cache.rb:16: syntax error (SyntaxError) <metric context='host' type='string' unit=''>
36c36 < f.puts("ENV['#{key}'] = '#{val}'") --- > f.puts("ENV['#{key}'] = '#{val.gsub("'","\\\\'")}'") 55c55 < f.puts("export #{key}='#{val}'") --- > f.puts("export #{key}=\"#{val.gsub(/"/,'\\\"')}\"")
v 5.x Linux RightImages
Our current RightImages should be able to parse the meta-data properly, however we have noticed occasionally that the EC2 meta-server will fail to supply all the meta-data after multiple retries by our scripts. The error will resemble this in the audits and logs:
RightScale: /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:143:in `curl_get': uninitialized constant RightScale::Ec2MetadataProvider::SubprocessFormatting (NameError) RightScale: from /opt/rightscale/sandbox/lib/ruby/1.8/tmpdir.rb:129:in `mktmpdir' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:110:in `curl_get' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:91:in `recursive_fetch_metadata' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:74:in `each' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:74:in `recursive_fetch_metadata' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:89:in `recursive_fetch_metadata' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:74:in `each' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:74:in `recursive_fetch_metadata' RightScale: from /opt/rightscale/right_link/agents/lib/instance/ec2_metadata_provider.rb:53:in `metadata' RightScale: from /opt/rightscale/bin/ec2/fetch_metadata.rb:45:in `initialize' RightScale: from /opt/rightscale/bin/ec2/fetch_metadata.rb:120:in `new' RightScale: from /opt/rightscale/bin/ec2/fetch_metadata.rb:120 RightScale: uninitialized constant RightScale::Ec2MetadataProvider::SubprocessFormatting RightScale: /opt/rightscale/bin/ec2/wait_for_eip.rb:44:in `require': no such file to load -- /var/spool/ec2/meta-data.rb (LoadError) RightScale: from /opt/rightscale/bin/ec2/wait_for_eip.rb:44
You may also see something similar to this as well:
Fetching EC2 Meta-Data curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 curl: (22) The requested URL returned error: 404 fetching Ec2 meta-data curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. curl exited with status (22, retrying.. Fetching EC2 User-Data
Usually a reboot or re-launch will suffice to fix this error. If this error keeps occurring, please notify RightScale support for further investigation.
There is also another unrelated issue that you might confuse with this, as the error is similar but the cause is different. If you were to use the 11H1 RightScale App or Load Balancer ServerTemplate with a RightImage of a newer Epoch, you might see something along the lines of this:
22:23:23: : no such file to load -- /var/spool/ec2/user-data.rb (LoadError) from /opt/rightscale/lb/bin/apache_config_vhost.rb:19 22:23:23: Script exit status: 1
In the switch from RightLink 5.6 to 5.7 the location of the cached meta-data was moved from /var/spool/ec2 to /var/spool/cloud. This change was required as we hardened support for Multi-cloud usage. If you see this error, you will simply need to roll back to a compatible 11H1 RightImage or create a RightScript that makes a symlink on boot. Make sure to add it to the top of the ServerTemplate so that it is run before depedent scripts.
ln -s /var/spool/ec2 /var/spool/cloud
v 5.x Windows RightImages
All of our current publicly available Windows RightImages should be able to boot without issues, however you might need to update your ServerTemplate to use a current MultiCloud Image. If you're still seeing errors such as:
Source : RightScale Service EntryType : Error TimeGenerated : 11/30/2011 7:11:31 PM Message : Error waiting for cloud data: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at RightScaleCommon.FileUtilities.ReadDictionary(String filePath, String pairDelimiter, String pairSeparator, Boolean caseSensitive, Boolean throwOnFailure) at RightScaleCommon.Cloud.BaseCloud.WaitForScriptedData(String scriptPath, String dictionaryFilePath, WaitHandle cancelEvent) at RightScaleCommon.Cloud.BaseCloud.WaitForCloudData(WaitHandle cancelEvent, IDictionary`2& userDataDictionary) at RightScaleCommon.Services.ServiceMixin.WaitForCloudData(WaitHandle cancelEvent, IDictionary`2& userDataDictionary)
or
### Content of [C:\ProgramData\RightScale\RightScaleService\log\fetch_userdata_rb_20110731015139.log] is: curl: (22) The requested URL returned error: 404 !!!!! User data empty
then you are probably using an older image or bundled RightScale RightImage.
Patch RightLink on a stuck instance
# Fetches EC2 metadata for the current instance. # # === Returns # metadata(Hash):: tree of metadata def metadata line 52>>> url = RightScale::CloudInfo.metadata_server_url + '/latest/meta-data/' return recursive_fetch_metadata(url) end
url = RightScale::CloudInfo.metadata_server_url + '/2011-01-01/meta-data/'
net stop rightscale net stop ec2config net start ec2config net start rightscale
Upgrade RightLink
Tags recommended by the template: stage:draf
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.