Skip to content

Commit

Permalink
wwan: try to find more useful reason for failure than DeadlineExceeded
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
milan-zededa authored and eriknordmark committed Nov 1, 2023
1 parent 62737d6 commit f001135
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/wwan/mmagent/mmdbus/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f001135

Please sign in to comment.