Skip to content

Commit e2b6065

Browse files
bors[bot]Chris Townsend
andcommitted
Merge #2569
2569: [client/common] Throw when unable to connect to daemon r=Saviq a=townsend2010 In the logic to figure out if a cert has been accepted by the daemon, if the client cannot establish a connection and get status if it's authenticated or not, it should just throw. This will avoid the client from generating a new cert until communication with the daemon is established. Fixes #2552 Co-authored-by: Chris Townsend <[email protected]>
1 parent 74d500e commit e2b6065

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/client/common/client_common.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,24 @@ std::shared_ptr<grpc::Channel> create_channel_and_validate(const std::string& se
104104
mp::PingReply reply;
105105
auto status = stub.ping(&context, request, &reply);
106106

107-
return status.ok() ? rpc_channel : nullptr;
107+
if (status.ok())
108+
{
109+
return rpc_channel;
110+
}
111+
else if (status.error_code() == grpc::StatusCode::UNAUTHENTICATED)
112+
{
113+
return nullptr;
114+
}
115+
// Throw for other error status as we don't want the client to process any further. It will show up
116+
// as an "unhandled exception" in the client, but this is fine in this case since this is just covering
117+
// errors when the client is trying to determine the valid cert when upgrading from 1.8.
118+
// This whole function will be deprecated in the future.
119+
else
120+
{
121+
throw std::runtime_error(
122+
fmt::format("Error connecting to the Multipass daemon: {}\nPlease try again in a few moments.",
123+
status.error_message()));
124+
}
108125
}
109126

110127
bool client_certs_exist(const QString& cert_dir_path)

0 commit comments

Comments
 (0)