From 0f4914969e96a7f681c3a8e50f94759697b4c087 Mon Sep 17 00:00:00 2001 From: hataejun Date: Thu, 10 Jan 2013 10:54:50 +0900 Subject: [PATCH] [Title] packageServer -> sync command check parent server and error return [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- src/pkg_server/distribution.rb | 16 +++++++++++++--- src/pkg_server/packageServer.rb | 15 ++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/pkg_server/distribution.rb b/src/pkg_server/distribution.rb index e64816d..5aa613b 100644 --- a/src/pkg_server/distribution.rb +++ b/src/pkg_server/distribution.rb @@ -205,8 +205,9 @@ class Distribution # check distribution's server_url if @server_url.empty? then - @log.error("This distribution has not remote server", Log::LV_USER) - return false + @log.error("This distribution has not remote server") + Utils.file_unlock(sync_lock_file) + raise RuntimeError, "remote server address empty" end # generate client class @@ -217,6 +218,15 @@ class Distribution end client = Client.new( server_url, "#{@location}/binary", @log ) + # parents package server check + if client.pkg_hash_os.keys.empty? then + @log.error("Sync process stopped by error.") + @log.error("Parents package server does not have [[os_info]] file.") + + Utils.file_unlock(sync_lock_file) + raise RuntimeError, "Parents package server does not have [[os_info]] file." + end + # update os list add_os_list = client.support_os_list - @support_os_list add_os_list.each do |os| @@ -238,7 +248,7 @@ class Distribution @support_os_list.each do |os| # error check if client.pkg_hash_os[os].nil? then - @log.error("package server does not have os : #{os}", Log::LV_USER) + @log.error("os[[#{os}]] is removed in parents package server", Log::LV_USER) next end diff --git a/src/pkg_server/packageServer.rb b/src/pkg_server/packageServer.rb index 120c0fd..e490275 100644 --- a/src/pkg_server/packageServer.rb +++ b/src/pkg_server/packageServer.rb @@ -298,12 +298,17 @@ class PackageServer return end - ret = distribution.sync(mode, snapshot) - if ret then - distribution.generate_snapshot("", "", false, distribution.last_sync_changes) - end + begin + ret = distribution.sync(mode, snapshot) - @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER ) + if ret then + distribution.generate_snapshot("", "", false, distribution.last_sync_changes) + end + + @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER ) + rescue => e + @log.error( e.message, Log::LV_USER) + end end def add_distribution( dist_name, server_url, clone ) -- 2.34.1