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
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!"
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"
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
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
+* 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
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
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)
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
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
def get_distribution_name()
- return @project.dist_name
+ return @dist_name
end
@status = "RUNNING"
end
if not result then @status = "DISCONNECTED" end
+ else
+ @status = "DISCONNECTED"
end
client.terminate
if @status == "DISCONNECTED" then return end
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
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
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
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
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
# 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
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
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
# 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
def send_file(src_file, transporter )
+
result = true
begin
l = @socket.gets()
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
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
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
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