forked from qt-creator/qt-creator
Docker: Improve error reporting
Change-Id: I7ff4d54e1a4a82baa267419930f61206f238ebce Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -193,7 +193,8 @@ public:
|
||||
|
||||
expected_str<Environment> environment();
|
||||
|
||||
CommandLine withDockerExecCmd(const CommandLine &cmd,
|
||||
expected_str<CommandLine> withDockerExecCmd(
|
||||
const CommandLine &cmd,
|
||||
const std::optional<Environment> &env = std::nullopt,
|
||||
const std::optional<FilePath> &workDir = std::nullopt,
|
||||
bool interactive = false,
|
||||
@@ -374,15 +375,25 @@ void DockerProcessImpl::start()
|
||||
const bool interactive = m_setup.m_processMode == ProcessMode::Writer
|
||||
|| !m_setup.m_writeData.isEmpty() || inTerminal;
|
||||
|
||||
const CommandLine fullCommandLine
|
||||
= m_devicePrivate->withDockerExecCmd(m_setup.m_commandLine,
|
||||
const expected_str<CommandLine> fullCommandLine = m_devicePrivate->withDockerExecCmd(
|
||||
m_setup.m_commandLine,
|
||||
m_setup.m_environment,
|
||||
m_setup.m_workingDirectory,
|
||||
interactive,
|
||||
inTerminal,
|
||||
!m_process.ptyData().has_value());
|
||||
|
||||
m_process.setCommand(fullCommandLine);
|
||||
if (!fullCommandLine) {
|
||||
emit done(ProcessResultData{
|
||||
-1,
|
||||
QProcess::ExitStatus::CrashExit,
|
||||
QProcess::ProcessError::FailedToStart,
|
||||
fullCommandLine.error(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
m_process.setCommand(*fullCommandLine);
|
||||
m_process.start();
|
||||
}
|
||||
|
||||
@@ -610,7 +621,7 @@ DockerDevice::DockerDevice()
|
||||
return fileAccess->get();
|
||||
}
|
||||
|
||||
qCWarning(dockerDeviceLog) << "Failed to start CmdBridge:" << fAccess.error()
|
||||
qCWarning(dockerDeviceLog).noquote() << "Failed to start CmdBridge:" << fAccess.error()
|
||||
<< ", falling back to slow direct access";
|
||||
|
||||
*fileAccess = std::make_unique<DockerFallbackFileAccess>(rootPath());
|
||||
@@ -679,15 +690,16 @@ expected_str<void> DockerDevice::updateContainerAccess() const
|
||||
return d->updateContainerAccess();
|
||||
}
|
||||
|
||||
CommandLine DockerDevicePrivate::withDockerExecCmd(const CommandLine &cmd,
|
||||
expected_str<CommandLine> DockerDevicePrivate::withDockerExecCmd(
|
||||
const CommandLine &cmd,
|
||||
const std::optional<Environment> &env,
|
||||
const std::optional<FilePath> &workDir,
|
||||
bool interactive,
|
||||
bool withPty,
|
||||
bool withMarker)
|
||||
{
|
||||
if (!updateContainerAccess())
|
||||
return {};
|
||||
if (const auto result = updateContainerAccess(); !result)
|
||||
return make_unexpected(result.error());
|
||||
|
||||
CommandLine dockerCmd{settings().dockerBinaryPath(), {"exec"}};
|
||||
|
||||
@@ -1101,8 +1113,12 @@ expected_str<void> DockerDevicePrivate::fetchSystemEnviroment()
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
const expected_str<CommandLine> fullCommandLine = withDockerExecCmd(CommandLine{"env"});
|
||||
if (!fullCommandLine)
|
||||
return make_unexpected(fullCommandLine.error());
|
||||
|
||||
Process proc;
|
||||
proc.setCommand(withDockerExecCmd(CommandLine{"env"}));
|
||||
proc.setCommand(*fullCommandLine);
|
||||
proc.runBlocking();
|
||||
const QString remoteOutput = proc.cleanedStdOut();
|
||||
|
||||
|
Reference in New Issue
Block a user