From f0011351f61e147d88aed56f8efac7cc657d72e8 Mon Sep 17 00:00:00 2001 From: Milan Lenco Date: Mon, 30 Oct 2023 18:07:03 +0100 Subject: [PATCH] wwan: try to find more useful reason for failure than DeadlineExceeded When attempt to establish cellular connectivity fails, we want to publish error that helps users to determine the root cause. Context deadline exceeded is rarely usefull. With this commit, mmagent tries to find the real reason behind the timeout, and only returns the original DeadlineExceeded if it cannot do any better. Signed-off-by: Milan Lenco --- pkg/wwan/mmagent/mmdbus/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/wwan/mmagent/mmdbus/client.go b/pkg/wwan/mmagent/mmdbus/client.go index 5e5b387c5c..7698ba65cd 100644 --- a/pkg/wwan/mmagent/mmdbus/client.go +++ b/pkg/wwan/mmagent/mmdbus/client.go @@ -1243,7 +1243,16 @@ func (c *Client) runSimpleConnect(modemObj dbus.BusObject, var bearerPath dbus.ObjectPath modem := c.modems[string(modemObj.Path())] err := c.callDBusMethod(modemObj, SimpleMethodConnect, &bearerPath, connProps) - if err != nil && strings.HasPrefix(err.Error(), "No such interface") && modem != nil { + var errIsUseless bool + if err != nil { + if strings.HasPrefix(err.Error(), "No such interface") { + errIsUseless = true + } + if errors.Is(err, context.DeadlineExceeded) { + errIsUseless = true + } + } + if errIsUseless && modem != nil { // Try to determine more useful connection failure reason. for _, simCard := range modem.Status.SimCards { if !simCard.SlotActivated {