[Title] Fixed some bugs about "cancel" and loggin
authordonghee yang <donghee.yang@samsung.com>
Thu, 18 Oct 2012 01:19:14 +0000 (10:19 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Thu, 18 Oct 2012 01:19:14 +0000 (10:19 +0900)
14 files changed:
build-cli
package/changelog
package/pkginfo.manifest
src/build_server/BuildJob.rb
src/build_server/PackageSync.rb
src/build_server/RegisterPackageJob.rb
src/build_server/RemoteBuildServer.rb
src/build_server/RemoteBuilder.rb
src/build_server/ReverseBuildChecker.rb
src/common/BuildComm.rb
src/pkg_server/client.rb
src/pkg_server/packageServer.rb
test/build-server.basic1/build-cli-18.testcase
upgrade

index 4e4fa0dcca11017bbe2b1e64b5be4f0a2bd30d70..cfb2da93ba9cb649657ba3eb50092e9b75526287 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -62,6 +62,9 @@ def query( ip, port, sym )
        end
        client.send "QUERY|#{sym.strip}"
        result = client.receive_data()
+       if result.nil? then 
+               puts "Error: #{client.get_error_msg()}"
+       end
        client.terminate
        return result
 end
@@ -159,7 +162,10 @@ begin
                client = BuildCommClient.create( result[0], result[1], nil, 0 )
                if not client.nil? then
                        client.send "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}"
-                               client.print_stream
+                       if not client.print_stream then
+                               puts "ERROR: #{client.get_error_msg()}"
+                       end
+
                        client.terminate
                else
                        puts "Connection to server failed!"
@@ -176,7 +182,9 @@ begin
                client = BuildCommClient.create( result[0], result[1], nil, 0 )
                if not client.nil? then
                        client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}"
-                               client.print_stream
+                       if not client.print_stream then
+                               puts "ERROR: #{client.get_error_msg()}"
+                       end
                        client.terminate
                end
        when "query"
@@ -239,10 +247,11 @@ begin
                        client = BuildCommClient.create( result[0], result[1], nil, 0 )
                        if not client.nil? then
                                client.send "CANCEL|#{option[:job]}|#{option[:passwd]}"
-                                       result1 = client.receive_data()
+                               result1 = client.receive_data()
                                if result1.nil? then
+                                       puts "Error: #{client.get_error_msg()}"
                                        client.terminate
-                                       exit(-1)
+                                       exit 1
                                end
                                puts result1
                        else
@@ -311,7 +320,9 @@ begin
                        exit(-1)
                end
                client.send("REGISTER|BINARY|#{File.basename(option[:package])}|#{option[:passwd]}|#{dock}|#{option[:dist]}")
-                       client.print_stream
+               if not client.print_stream then
+                       puts "ERROR: #{client.get_error_msg()}"
+               end
                client.terminate
 
        else
index 52dd1f7e557b09e64526d49827199c02c4107385..8238a43d45f3a5b740b75b5c800f73a6b67f17c9 100644 (file)
@@ -1,3 +1,7 @@
+* 1.2.8
+- Fixed "cancel" bug
+- Changed to remain logss about communication errors
+== hyoun jiil <jiil.hyoun@samsung.com> 2011-10-18
 * 1.2.7
 - Fixed a bug that reverse build choose wrong distribution project
 == hyoun jiil <jiil.hyoun@samsung.com> 2011-10-17
index c8411e4362bdf15e3d57cf74e3061d06cbecb0f5..f3adf10f91a789b985498db5c89c12794023e25e 100644 (file)
@@ -1,5 +1,5 @@
 Source : dibs
-Version :1.2.7
+Version :1.2.8
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com
 
 Package : dibs
index 3767788a8470957f54477d29967520a9a93c90c0..517feb3a40e51cdef9d330eae7294574a3e0f6dd 100644 (file)
@@ -51,6 +51,7 @@ class BuildJob < CommonJob
        attr_accessor :rev_fail_projects, :rev_success_jobs
        attr_accessor :pending_ancestor, :cancel_state
        attr_accessor :no_reverse
+       attr_accessor :remote_id
 
        # initialize
        def initialize (project, os, server)
index c4970196e96a59cd8da40ed339cdd9a4f4332df5..7655ccc83411e604c2843c41055779cdee21490a 100644 (file)
@@ -101,7 +101,7 @@ class PackageSyncAction < Action
                registered_jobs = []
                downloaded_files.each do  |file_path|
                        @server.log.info "Creating new job for registering \"#{file_path}\""
-                       new_job = @server.jobmgr.create_new_register_job( file_path )
+                       new_job = @server.jobmgr.create_new_register_job( file_path, @dist_name )
                        logger = JobLog.new( new_job, nil )
                        new_job.set_logger(logger)
                        logger.init
index 793106a16238d4b0e5b76966e57743a01d44b228..a95aed57bbd53e9f31500a6fe865876547467f4f 100644 (file)
@@ -87,6 +87,13 @@ class RegisterPackageJob < CommonJob
                end
                @pkginfo = nil #This info is valid only for BINARY package
                @project = project
+               if not dist_name.nil? then 
+                       @dist_name = dist_name 
+               elsif not @project.nil? then
+                       @dist_name = @project.dist_name
+               else
+                       @dist_name = "BASE"     
+               end
        end
 
 
@@ -96,7 +103,7 @@ class RegisterPackageJob < CommonJob
 
 
        def get_distribution_name()
-               return @project.dist_name
+               return @dist_name
        end
 
 
index f1356c2d5bf5999a614a2e62ff207854463a5ab5..a244d2af58539ac7cd8c0b61d14d43ef5dc8acf4 100644 (file)
@@ -82,6 +82,8 @@ class RemoteBuildServer
                                @status = "RUNNING"
                        end
                        if not result then @status = "DISCONNECTED" end
+               else
+                       @status = "DISCONNECTED"
                end
                client.terminate
                if @status == "DISCONNECTED" then return end
index facf8ac67fd8c1dc0d8835d7a20c06af70fb1b6f..e2bac0b57f59e982e649ed2dfb678a7a146c4076 100644 (file)
@@ -183,32 +183,40 @@ class RemoteBuilder
                pkg_list = local_pkg_names.join(",")
                rev = is_rev_build ? "YES":"NO"
                msg = "BUILD|GIT|#{git_repos}||#{os}|NO|#{no_reverse}|YES|#{rev}|#{commit}|#{pkg_list}|#{dock}|#{dist_name}"
-               r_job_number = Regexp.new('Added new job "([^"]*)"')
-               if client.send( msg ) then
-                       result = client.read_lines do |l|
-                               # write log first
-                               @log.output( l.strip, Log::LV_USER)
-
-                               # set remote job id
-                               if @remote_id.nil? and l =~ r_job_number then
-                                       @remote_id = $1
-                               end
+               result = client.send( msg )
+               if not result then
+                       @log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
+                       return false, result_files
+               end
 
-                               # check build result
-                               if l.include? "Job is stopped by ERROR" or
-                                       l.include? "Error:" then
-                                       result = false
-                                       break
-                               end
+               r_job_number = Regexp.new('Added new job "([^"]*)"')
+               error = false
+               result = client.read_lines do |l|
+                       # write log first
+                       @log.output( l.strip, Log::LV_USER)
+
+                       # set remote job id
+                       if not @job.nil? and  @job.remote_id.nil? and l =~ r_job_number then
+                               @job.remote_id = $1
+                       end
 
-                               # gather result files if not reverse build
-                               if not is_rev_build and l =~ /Creating package file \.\.\. (.*)/ then
-                                       file_name = $1
-                                       result_files.push file_name
-                               end
+                       # check build result
+                       if l.include? "Job is stopped by ERROR" or
+                               l.include? "Error:" then
+                               error = true
+                               break
+                       end
 
+                       # gather result files if not reverse build
+                       if not is_rev_build and l =~ /Creating package file \.\.\. (.*)/ then
+                               file_name = $1
+                               result_files.push file_name
                        end
                end
+               if not result then
+                       @log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
+               end
+               if error then result=false end
 
                # close socket
                client.terminate
index e778609e2f883c3774110ce27c155f81d1ab7521..8222b38da6f87a04165bc9a38fb246ee45f19a18 100644 (file)
@@ -131,8 +131,7 @@ class ReverseBuildChecker
                rev_build_jobs.each do |rev_job|
                        # add to job manager
                        job.server.jobmgr.add_reverse_build_job(rev_job)
-                       log.info( " * Added new job for reverse-build ... \
-                                        #{rev_job.get_project().name}(#{rev_job.os}) (#{rev_job.id})", Log::LV_USER)
+                       log.info( " * Added new job for reverse-build ... #{rev_job.get_project().name}(#{rev_job.os}) (#{rev_job.id})", Log::LV_USER)
                end
 
                # wait for job finish
index 00b801f751cc89e9e5e759a3e6930a0f0d62016e..8099cc621dfa0a104c478b125674c2ddc95a8647 100644 (file)
@@ -331,12 +331,14 @@ end
 
 class BuildCommClient
        VERSION = "1.6.0"
+       FIRST_REPONSE_TIMEOUT = 30
 
        private_class_method :new
 
        def initialize(socket, log)
                @log = log
                @socket = socket
+               @error_msg = ""
        end
 
 
@@ -369,8 +371,21 @@ class BuildCommClient
        end
 
 
+       def get_error_msg()
+               return @error_msg
+       end
+
+
+       def set_error_msg( msg )
+               @error_msg = msg
+       end
+
+
        def send( msg )
-               if @socket.nil? then return false end
+               if @socket.nil? then 
+                       @error_msg = "Connection is not available!"
+                       return false 
+               end
 
                @socket.puts( msg )
                return true
@@ -380,20 +395,22 @@ class BuildCommClient
        def print_stream
 
                begin
-                       l = @socket.gets()
+                       l = nil
+                       timeout(FIRST_REPONSE_TIMEOUT) do
+                               l = @socket.gets()
+                       end
 
                        if l.nil? then
-                               puts "Connection refused"
+                               @error_msg = "Connection closed or no more message"
                                return false
                        end
 
                        # check protocol
                        if not protocol_matched? l.strip then
-                               puts "Comm. Protocol version is mismatched! #{VERSION}"
+                               @error_msg = "Comm. Protocol version is mismatched! #{VERSION}"
                                return false
                        end
 
-
                        # get contents
                        while line = @socket.gets()
                                if line.strip == "=END" then break end
@@ -401,8 +418,12 @@ class BuildCommClient
                                # print
                                puts line.strip
                        end
-               rescue
-                       puts "Connection closed"
+               rescue Timeout::Error
+                       @error_msg = "Connection timed out!"
+                       return false
+
+               rescue => e
+                       @error_msg = e.message
                        return false
                end
 
@@ -416,32 +437,36 @@ class BuildCommClient
                begin
                        # get first line
                        l = nil
-                       timeout(30) do
+                       timeout(FIRST_REPONSE_TIMEOUT) do
                                l = @socket.gets()
                        end
 
                        if l.nil? then
+                               @error_msg = "Connection closed or No more message"
                                return false
                        end
 
                        # check protocol
                        if not protocol_matched? l.strip then
+                               @error_msg = "Comm. Protocol version is mismatched! #{VERSION}"
                                return false
                        end
 
                        # get contents
+                       result = true
                        while line = @socket.gets()
                                if line.strip == "=END" then break end
                                if line.strip == "=CHK" then next end
 
-                               # print
+                               # execute
                                yield line.strip if block_given?
                        end
                rescue Timeout::Error
-                       puts "WARN: Connection timed out"
+                       @error_msg = "Connection timed out!"
                        return false
+
                rescue => e
-                       puts e.message
+                       @error_msg = e.message
                        return false
                end
 
@@ -454,20 +479,22 @@ class BuildCommClient
                result = []
 
                begin
-                       l = @socket.gets()
+                       l = nil
+                       timeout(FIRST_REPONSE_TIMEOUT) do
+                               l = @socket.gets()
+                       end
 
                        if l.nil? then
-                               puts "Connection refused"
+                               @error_msg = "Connection closed or No more message"
                                return nil
                        end
 
                        # check protocol
                        if not protocol_matched? l.strip then
-                               puts "Comm. Protocol version is mismatched! #{VERSION}"
+                               @error_msg = "Comm. Protocol version is mismatched! #{VERSION}"
                                return nil
                        end
 
-
                        # get contents
                        while line = @socket.gets()
                                if line.strip == "=END" then break end
@@ -475,8 +502,13 @@ class BuildCommClient
                                # print
                                result.push line.strip
                        end
-               rescue
-                       puts "Connection closed"
+
+               rescue Timeout::Error
+                       @error_msg = "Connection timed out!"
+                       return nil
+
+               rescue => e
+                       @error_msg = e.message
                        return nil
                end
 
@@ -485,6 +517,7 @@ class BuildCommClient
 
 
        def send_file(src_file, transporter )
+
                result = true
                begin
                        l = @socket.gets()
index e1755aae561ec920b6de9bfdfd5605f174d58144..63836517199980b0a2aecae71d552d9fa601354a 100644 (file)
@@ -402,22 +402,23 @@ class Client
                        end
 
                        @log.info "Send register message..  [REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}]"
-                               snapshot = nil
+                       snapshot = nil
                        if client.send "REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}" then
-                               output = client.read_lines do |l|
-                               line = l.split("|")
-                               if line[0].strip == "ERROR" then
-                                       @log.error l.strip
+                               result = client.read_lines do |l|
+                                       line = l.split("|")
+                                       if line[0].strip == "ERROR" then
+                                               @log.error l.strip
+                                               break
+                                       elsif line[0].strip == "SUCC" then
+                                               snapshot = line[1].strip
+                                       end
+                               end
+
+                               if not result or snapshot.nil? then
+                                       @log.error "Failed to register! #{client.get_error_msg()}"
                                        return nil
-                               elsif line[0].strip == "SUCC" then
-                                       snapshot = line[1].strip
                                end
                        end
-                       if not output then
-                               @log.error "Failed to register"
-                               return nil
-                       end
-                       end
 
                        client.terminate
                        snapshot = @server_addr + "/snapshots/" + snapshot
index 2f254866168672c74ccbbf554e371b279145ad02..80910fa7038cd7d20972b6edee5c8bb5b233b24f 100644 (file)
@@ -508,10 +508,13 @@ class PackageServer
                client.send("STOP|#{passwd}")
 
                ret = client.receive_data
-               if ret[0].strip.eql? "SUCC" then
+               if not ret.nil? and ret[0].strip.eql? "SUCC" then
                        @log.output( "Package server is stopped", Log::LV_USER)
                else
-                       @log.output( "Package server return error message : #{ret}", Log::LV_USER)
+                       @log.output( "Package server return error message! #{ret}", Log::LV_USER)
+                       if not client.get_error_msg().empty? then
+                               @log.output( "Error: #{client.get_error_msg()}", Log::LV_USER)
+                       end
                end
                client.terminate
 
index 6c8a769d23fe5319e02bafa29ec68300d70f875b..32218a2155ec6e2e4119056836b6b8ee9bf7983a 100644 (file)
@@ -26,6 +26,6 @@ Info: Zipping...
 Info: Creating package file ... a_0.0.2_ubuntu-32.zip
 Info: Checking reverse build dependency ...
 Info:  * Will check reverse-build for projects: testb(ubuntu-32)
-Info:  * Added new job for reverse-build ...                           testb(ubuntu-32)
+Info:  * Added new job for reverse-build ... testb(ubuntu-32)
 Info:  * Reverse-build FAIL ... testb(ubuntu-32)
 Error: Job is stopped by ERROR
diff --git a/upgrade b/upgrade
index f47485f1e5dc8e3966ef8d659ea2980bf99ccde6..cf09cd3ce9ec2985d927aff7b58d183bd453dee4 100755 (executable)
--- a/upgrade
+++ b/upgrade
@@ -215,6 +215,14 @@ begin
                                                                mismatched = true
                                                        end
                                                end
+                                               if not result then
+                                                       log.info("Upgrading failed! #{build_client.get_error_msg()}", Log::LV_USER)
+                                               elsif mismatched then
+                                                       log.info("Upgrading failed! Password mismatched!", Log::LV_USER)
+                                               end
+                                       else
+                                               log.info("Upgrading failed! #{build_client.get_error_msg()}", Log::LV_USER)
+                                               next
                                        end
 
                                        # terminate