Always doing it in condor_refreshd has a number of benefits: 1) It consolidates the logic in one place, getting rid of possible race issues between two things doing it at the same time.
2) It makes it asynchrnous from the point of view of the UI. That means the UI just kicks the daemon, and then goes on with life. This should speed up the UI considerably. 3) It makes it so that condor doesn't need to be running to run the spec tests. Signed-off-by: Chris Lalancette <[email protected]> --- src/app/controllers/cloud_accounts_controller.rb | 2 +- src/app/controllers/pools_controller.rb | 2 +- src/app/controllers/provider_controller.rb | 6 +++--- src/app/util/condormatic.rb | 21 +++++++++++++++++++++ src/config/environment.rb | 2 +- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/app/controllers/cloud_accounts_controller.rb b/src/app/controllers/cloud_accounts_controller.rb index 6351107..47863d6 100644 --- a/src/app/controllers/cloud_accounts_controller.rb +++ b/src/app/controllers/cloud_accounts_controller.rb @@ -54,7 +54,7 @@ class CloudAccountsController < ApplicationController flash[:notice] = "Provider account added." end redirect_to :controller => "provider", :action => "accounts", :id => @provider - condormatic_classads_sync + kick_condor end end diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb index ee95643..f699145 100644 --- a/src/app/controllers/pools_controller.rb +++ b/src/app/controllers/pools_controller.rb @@ -134,5 +134,5 @@ class PoolsController < ApplicationController end redirect_to :action => 'show', :id => @pool.id end - condormatic_classads_sync + kick_condor end diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb index 61bdfdf..5e4d32c 100644 --- a/src/app/controllers/provider_controller.rb +++ b/src/app/controllers/provider_controller.rb @@ -46,7 +46,7 @@ class ProviderController < ApplicationController require_privilege(Privilege::PROVIDER_MODIFY) @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY) @provider = Provider.new(params[:provider]) - condormatic_classads_sync + kick_condor render :show end @@ -60,7 +60,7 @@ class ProviderController < ApplicationController else render :action => "new" end - condormatic_classads_sync + kick_condor end def update @@ -74,7 +74,7 @@ class ProviderController < ApplicationController else render :action => "edit" end - condormatic_classads_sync + kick_condor end def destroy diff --git a/src/app/util/condormatic.rb b/src/app/util/condormatic.rb index 43f83d9..2b5b781 100644 --- a/src/app/util/condormatic.rb +++ b/src/app/util/condormatic.rb @@ -18,6 +18,7 @@ # also available at http://www.gnu.org/copyleft/gpl.html. require 'nokogiri' +require 'socket' def condormatic_instance_create(task) @@ -276,3 +277,23 @@ def condormatic_classads_sync Rails.logger.info "done" end end + +def kick_condor + begin + socket = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0) + in_addr = Socket.pack_sockaddr_in(7890, 'localhost') + socket.connect(in_addr) + socket.write("kick") + socket.close + rescue + # if any of the above failed, it's possible that the condor_refreshd + # daemon is not running. This is especially useful when running the + # spec tests, since you don't necessarily want condor running in that + # circumstance. + # FIXME: there are a couple of problems with ignoring errors here. The + # first is that if this does actually fail, then it's unclear when in the + # future we will update the classads next. The second problem is that + # if condor_refreshd died for some reason, but condor itself is running, + # condor could be running with stale data. + end +end diff --git a/src/config/environment.rb b/src/config/environment.rb index dbdc86a..069b08d 100644 --- a/src/config/environment.rb +++ b/src/config/environment.rb @@ -92,7 +92,7 @@ Rails::Initializer.run do |config| # them on condor on startup. Note that this can fail because this is run on startup # even for rake db:migrate etc. which won't work since the database doesn't exist # yet. - condormatic_classads_sync + kick_condor rescue Exception => ex end end -- 1.7.2.3 _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
