Skip to content
代码片段 群组 项目
提交 034a3f44 编辑于 作者: Andrejs Cunskis's avatar Andrejs Cunskis
浏览文件

Merge branch 'hm-fix-runner-docker-network-error-output' into 'master'

Prevent misleading ERROR logs in jobs for docker network inspect test

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119573



Merged-by: default avatarAndrejs Cunskis <acunskis@gitlab.com>
Approved-by: default avatarAndrejs Cunskis <acunskis@gitlab.com>
Reviewed-by: default avatarAndrejs Cunskis <acunskis@gitlab.com>
Reviewed-by: default avatarEdgars Bralitis <ebralitis@gitlab.com>
Co-authored-by: default avatarhmuralidhar <hmuralidhar@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -39,19 +39,20 @@ def logs
end
def network
shell "docker network inspect #{@network}"
rescue CommandError
'bridge'
else
@network
network_exists?(@network) ? @network : 'bridge'
end
def runner_network
shell "docker network inspect #{@runner_network}"
rescue CommandError
network
else
@runner_network
network_exists?(@runner_network) ? @runner_network : network
end
def inspect_network(name)
shell("docker network inspect #{name}", fail_on_exception: false, return_exit_status: true)
end
def network_exists?(name)
_, status = inspect_network(name)
status == 0
end
def pull
......
......@@ -11,9 +11,10 @@ module Shellout
module_function
def shell(command, stdin_data: nil, fail_on_exception: true, stream_progress: true, mask_secrets: []) # rubocop:disable Metrics/CyclomaticComplexity
def shell(command, stdin_data: nil, fail_on_exception: true, stream_progress: true, mask_secrets: [], return_exit_status: false) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
cmd_string = Array(command).join(' ')
cmd_output = ''
exit_status = 0
QA::Runtime::Logger.info("Executing: `#{mask_secrets_on_string(cmd_string, mask_secrets).cyan}`")
......@@ -36,7 +37,9 @@ def shell(command, stdin_data: nil, fail_on_exception: true, stream_progress: tr
# add newline after progress dots
puts if print_progress_dots && !cmd_output.empty?
if wait.value.exited? && wait.value.exitstatus.nonzero? && fail_on_exception
exit_status = wait.value.exitstatus if wait.value.exited?
if exit_status.nonzero? && fail_on_exception
Runtime::Logger.error("Command output:\n#{cmd_output.strip}") unless cmd_output.empty?
raise CommandError, "Command: `#{mask_secrets_on_string(cmd_string, mask_secrets)}` failed! ✘"
end
......@@ -44,7 +47,7 @@ def shell(command, stdin_data: nil, fail_on_exception: true, stream_progress: tr
Runtime::Logger.debug("Command output:\n#{cmd_output.strip}") unless cmd_output.empty?
end
cmd_output.strip
return_exit_status ? [cmd_output.strip, exit_status] : cmd_output.strip
end
def sql_to_docker_exec_cmd(sql, username, password, database, host, container)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册