On Wed, 2010-07-21 at 16:21 +0200, [email protected] wrote: > From: Jan Provaznik <[email protected]> > > Instance state in condormatic_instances_sync_states is set > only once. > --- > src/app/util/condormatic.rb | 21 +++++++-------------- > 1 files changed, 7 insertions(+), 14 deletions(-) > > diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb > index 5fba43e..3a21d64 100644 > --- a/src/app/util/condormatic.rb > +++ b/src/app/util/condormatic.rb > @@ -118,15 +118,8 @@ def condormatic_instances_sync_states > > raise ("Error calling condor_q -xml") if $? != 0 > > - # Set them all to 'stopped' because if they aren't in the condor > - # queue as jobs then they are not running, pending or anything else. > - instances = Instance.find(:all) > - instances.each do |instance| > - instance.state = Instance::STATE_STOPPED > - instance.save! > - end > - > doc = Nokogiri::XML(xml) > + jobs_state = {} > doc.xpath('/classads/c').each do |jobs_ele| > job_name = (v = jobs_ele.at_xpath('./a...@n="Cmd"]/s')) ? v.text : nil > job_state= (v = jobs_ele.at_xpath('./a...@n="JobStatus"]/i')) ? v.text > : nil > @@ -134,13 +127,13 @@ def condormatic_instances_sync_states > Rails.logger.info "job name is #{job_name}" > Rails.logger.info "job state is #{job_state}" > > - instance = Instance.find(:first, :conditions => {:condor_job_id => > job_name}) > + jobs_state[job_name] = condor_to_instance_state(job_state) if job_name > + end > > - if instance > - instance.state = condor_to_instance_state(job_state) > - instance.save! > - Rails.logger.info "Instance state updated to > #{condor_to_instance_state(job_state)}" > - end > + Instance.find(:all).each do |instance| > + instance.state = jobs_state[instance.condor_job_id] || > Instance::STATE_STOPPED > + instance.save! > + Rails.logger.info "Instance state updated to #{instance.state}" > end > rescue Exception => ex > Rails.logger.error ex.message
Fancy stuff. ACK _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
