lib/flapjack/data/migration.rb in flapjack-1.2.2 vs lib/flapjack/data/migration.rb in flapjack-1.3.0rc1

- old
+ new

@@ -79,28 +79,27 @@ semaphore = obtain_semaphore(ENTITY_DATA_MIGRATION, 'entity check data', :redis => redis, :logger => logger) begin - logger.warn "Upgrading Flapjack's entity/check Redis indexes..." unless logger.nil? - check_names = redis.keys('check:*').map {|c| c.sub(/^check:/, '') } | Flapjack::Data::EntityCheck.find_current_names(:redis => redis) unless check_names.empty? + logger.warn "Upgrading Flapjack's entity/check Redis indexes..." unless logger.nil? + timestamp = Time.now.to_i check_names.each do |ecn| redis.zadd("all_checks", timestamp, ecn) entity_name, check = ecn.split(':', 2) redis.zadd("all_checks:#{entity_name}", timestamp, check) # not deleting the check hashes, they store useful data end + logger.warn "Checks indexed." unless logger.nil? end - logger.warn "Checks indexed." unless logger.nil? - entity_name_keys = redis.keys("entity_id:*") unless entity_name_keys.empty? ids = redis.mget(*entity_name_keys) entity_name_keys.each do |enk| @@ -110,13 +109,13 @@ redis.hset('all_entity_ids_by_name', entity_name, entity_id) redis.del(enk) redis.del("entity:#{entity_id}") end + logger.warn "Entities indexed." unless logger.nil? end - logger.warn "Entities indexed." unless logger.nil? - logger.warn "Indexing complete." unless logger.nil? + logger.warn "Indexing complete." unless logger.nil? || (check_names.empty? && entity_name_keys.empty?) ensure semaphore.release end end