On Wed, Apr 27, 2011 at 07:41:56PM +0200, jprovazn@redhat.com wrote:
From: Jan Provaznik jprovazn@redhat.com
Only class ads for provider accounts mapped to a pool family are now generated. Also added pool family info into class ads. TODO: update condor plugin to check pool family quota
src/app/util/condormatic.rb | 36 +++++++++++++++++++----------------- 1 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb index 7857cd2..808e97d 100644 --- a/src/app/util/condormatic.rb +++ b/src/app/util/condormatic.rb @@ -57,6 +57,8 @@ def condormatic_instance_create(task) Rails.logger.error "DeltacloudHardwareProfileStorage = $$(hardware_profile_storage)\n" pipe.puts "DeltacloudKeyname = $$(keypair)\n" Rails.logger.error "DeltacloudKeyname = $$(keypair)\n"
pipe.puts "DeltacloudKeyname = $$(pool_family)\n"
Rails.logger.error "DeltacloudKeyname = $$(pool_family)\n"
if realm != nil pipe.puts "DeltacloudRealmId = $$(realm_key)\n"
@@ -66,7 +68,7 @@ def condormatic_instance_create(task) # TODO: for assemblies we grab first template in an assembly template_id = instance.template ? instance.template.id : instance.assembly.templates.first.id requirements = "requirements = front_end_hardware_profile_id == "#{instance.hardware_profile.id}" && image == "#{template_id}""
- requirements += " && pool_family == "#{instance.pool.pool_family.id}"" requirements += " && realm == "#{realm.id}"" if realm != nil # Call into the deltacloud quota plugin. This uses a REST API to call back into the # conductor to check quotas as the last thing in the logical AND to match a provider
@@ -220,37 +222,36 @@ def condormatic_classads_sync
front_end_hardware_profiles = HardwareProfile.find(:all, :conditions => ["provider_id IS NULL"])
- providers.each do |provider|
- # The provider image entry gets put in the database as soon as we ask
- # to have the image built, so we only want to generate classads for it if
- # it is ready to be used. When ready it will have an image key assigned
- # to it.
- provider_images = provider.provider_images.find(:all,
:conditions => ['provider_image_key IS NOT NULL'])
- accounts = provider.provider_accounts
- realms = provider.realms
- accounts.each do |account|
- PoolFamily.all.each do |pool_family|
- pool_family.provider_accounts.each do |account|
# The provider image entry gets put in the database as soon as we ask
# to have the image built, so we only want to generate classads for it if
# it is ready to be used. When ready it will have an image key assigned
# to it.
provider_images = account.provider.provider_images.find(:all,
:conditions => ['provider_image_key IS NOT NULL'])
realms = account.provider.realms
provider_images.each do |provider_img| front_end_hardware_profiles.each do |hwp| # when user doesn't select any realm
ads << [account, provider_img, hwp, nil, nil]
ads << [account, provider_img, hwp, nil, nil, pool_family] # add all backend->frontend mappings realms.each do |realm| ads += realm.frontend_realms.collect { |frealm|
[account, provider_img, hwp, realm, frealm] }
[account, provider_img, hwp, realm, frealm, pool_family] } end # frontend can be mapped to provider (then backend realm is set to # nil)
ads += provider.frontend_realms.collect { |frealm|
[account, provider_img, hwp, nil, frealm] }
ads += account.provider.frontend_realms.collect { |frealm|
[account, provider_img, hwp, nil, frealm, pool_family] } end end
end end
ads.each { |ad|
- account, provider_image, hwp, realm, frontend_realm = *ad
account, provider_image, hwp, realm, frontend_realm, pool_family = *ad
matching_hardware_profile = HardwareProfile.match_provider_hardware_profile(account.provider, hwp) if(matching_hardware_profile != nil) && (provider_image.image.template.architecture == hwp.architecture.value)
@@ -277,6 +278,7 @@ def condormatic_classads_sync pipe.puts "password="#{account.credentials_hash['password']}"" pipe.puts "provider_account_id="#{account.id}"" pipe.puts "keypair="#{account.instance_key ? account.instance_key.name : ''}""
pipe.puts "pool_family=\"#{pool_family.id}\"" rescue Exception => ex Rails.logger.error "Error writing provider classad to condor." Rails.logger.error ex.message
Jan,
I am running into an error launching instances with this patch applied. The requests are held in Condor, citing this as the reason: "Create_Instance_Failure: InvalidKeyPair.NotFound: The key pair '1' does not exist"
The error goes away if I try without this patch.
Below is just some data that may be helpful for debugging why this is happening to me. I have removed my password and replaced it with "[filtered]".
Instance.last
=> #<Instance id: 5, external_key: nil, name: "testaroo", hardware_profile_id: 1, template_id: 1, frontend_realm_id: 1, owner_id: 1, pool_id: 1, provider_account_id: nil, instance_hwp_id: nil, public_addresses: nil, private_addresses: nil, state: "new", condor_job_id: "job_testaroo_5", last_error: nil, lock_version: 1, acc_pending_time: 0, acc_running_time: 0, acc_shutting_down_time: 0, acc_stopped_time: 0, time_last_pending: nil, time_last_running: nil, time_last_shutting_down: nil, time_last_stopped: nil, created_at: "2011-04-27 20:10:57", updated_at: "2011-04-27 20:10:57", assembly_id: nil, deployment_id: nil>
InstanceKey.first
=> #<InstanceKey id: 1, instance_key_owner_id: 1, instance_key_owner_type: "ProviderAccount", name: "ec2_1303927326_key_70264944053820", pem: "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAlmQ...", created_at: "2011-04-27 18:02:08", updated_at: "2011-04-27 18:02:08">
$ condor_q -better
-- Submitter: mawagner-laptop.bos.redhat.com : <10.16.18.194:39672> : mawagner-laptop.bos.redhat.com --- 218.000: Request is held.
Hold reason: Create_Instance_Failure: InvalidKeyPair.NotFound: The key pair '1' does not exist
mawagner /var/log/condor $ condor_status -l image_key = "ami-48a75821" front_end_hardware_profile_id = "1" password = "[filtered]" Name = "provider_combination_0" AuthenticatedIdentity = "unauthenticated@unmapped" keypair = "ec2_1303927326_key_70264944053820" realm_key = "" hardware_profile_storage = "1690.0" pool_family = "1" provider_url = "http://localhost:3003/api" image = "1" MyAddress = "<10.16.18.194:0>" realm = "" hardware_profile_key = "c1.xlarge" UpdatesHistory = "0x00000000000000000000000000000000" username = "[filtered]" UpdatesLost = 0 provider_account_id = "1" hardware_profile_cpu = "20.0" UpdatesSequenced = 0 UpdatesTotal = 7 hardware_profile_memory = "7168.0" CurrentTime = time() Requirements = true MyType = "Machine" LastHeardFrom = 1303934919
image_key = "ami-48a75821" front_end_hardware_profile_id = "1" password = "[filtered]" Name = "provider_combination_1" AuthenticatedIdentity = "unauthenticated@unmapped" keypair = "ec2_1303927326_key_70264944053820" realm_key = "us-east-1a" hardware_profile_storage = "1690.0" pool_family = "1" provider_url = "http://localhost:3003/api" image = "1" MyAddress = "<10.16.18.194:0>" realm = "1" hardware_profile_key = "c1.xlarge" UpdatesHistory = "0x00000000000000000000000000000000" username = "[filtered]" UpdatesLost = 0 provider_account_id = "1" hardware_profile_cpu = "20.0" UpdatesSequenced = 0 UpdatesTotal = 7 hardware_profile_memory = "7168.0" CurrentTime = time() Requirements = true MyType = "Machine" LastHeardFrom = 1303934919
image_key = "ami-48a75821" front_end_hardware_profile_id = "1" password = "[filtered]" Name = "provider_combination_2" AuthenticatedIdentity = "unauthenticated@unmapped" keypair = "ec2_1303927326_key_70264944053820" realm_key = "" hardware_profile_storage = "1690.0" pool_family = "1" provider_url = "http://localhost:3003/api" image = "1" MyAddress = "<10.16.18.194:0>" realm = "1" hardware_profile_key = "c1.xlarge" UpdatesHistory = "0x00000000000000000000000000000000" username = "[filtered]" UpdatesLost = 0 provider_account_id = "1" hardware_profile_cpu = "20.0" UpdatesSequenced = 0 UpdatesTotal = 7 hardware_profile_memory = "7168.0" CurrentTime = time() Requirements = true MyType = "Machine" LastHeardFrom = 1303934919