diff --git a/interfaces/core.go b/interfaces/core.go
index d48c7bf..bb1b3b6 100644
--- a/interfaces/core.go
+++ b/interfaces/core.go
@@ -45,7 +45,7 @@ type PlugRef struct {
}
// String returns the "snap:plug" representation of a plug reference.
-func (ref *PlugRef) String() string {
+func (ref PlugRef) String() string {
return fmt.Sprintf("%s:%s", ref.Snap, ref.Name)
}
@@ -67,7 +67,7 @@ type SlotRef struct {
}
// String returns the "snap:slot" representation of a slot reference.
-func (ref *SlotRef) String() string {
+func (ref SlotRef) String() string {
return fmt.Sprintf("%s:%s", ref.Snap, ref.Name)
}
diff --git a/interfaces/core_test.go b/interfaces/core_test.go
index a224b81..7b2d0aa 100644
--- a/interfaces/core_test.go
+++ b/interfaces/core_test.go
@@ -133,6 +133,8 @@ func (s *CoreSuite) TestPlugRef(c *C) {
func (s *CoreSuite) TestPlugRefString(c *C) {
ref := PlugRef{Snap: "snap", Name: "plug"}
c.Check(ref.String(), Equals, "snap:plug")
+ refPtr := &PlugRef{Snap: "snap", Name: "plug"}
+ c.Check(refPtr.String(), Equals, "snap:plug")
}
// Slot.Ref works as expected
@@ -147,6 +149,8 @@ func (s *CoreSuite) TestSlotRef(c *C) {
func (s *CoreSuite) TestSlotRefString(c *C) {
ref := SlotRef{Snap: "snap", Name: "slot"}
c.Check(ref.String(), Equals, "snap:slot")
+ refPtr := &SlotRef{Snap: "snap", Name: "slot"}
+ c.Check(refPtr.String(), Equals, "snap:slot")
}
// ConnRef.ID works as expected
diff --git a/overlord/ifacestate/helpers.go b/overlord/ifacestate/helpers.go
index c20a83e..04df415 100644
--- a/overlord/ifacestate/helpers.go
+++ b/overlord/ifacestate/helpers.go
@@ -21,6 +21,7 @@ package ifacestate
import (
"fmt"
+ "strings"
"github.com/snapcore/snapd/asserts"
"github.com/snapcore/snapd/interfaces"
@@ -300,7 +301,16 @@ func (m *InterfaceManager) autoConnect(task *state.Task, snapName string, blackl
continue
}
candidates := m.repo.AutoConnectCandidateSlots(snapName, plug.Name, autochecker.check)
+ if len(candidates) == 0 {
+ continue
+ }
if len(candidates) != 1 {
+ crefs := make([]string, 0, len(candidates))
+ for _, candidate := range candidates {
+ cref := candidate.Ref()
+ crefs = append(crefs, cref.String())
+ }
+ task.Logf("cannot auto connect %s (plug auto-connection), candidates found: %q", plug.Ref().String(), strings.Join(crefs, ", "))
continue
}
slot := candidates[0]
@@ -308,10 +318,11 @@ func (m *InterfaceManager) autoConnect(task *state.Task, snapName string, blackl
key := connRef.ID()
if _, ok := conns[key]; ok {
// Suggested connection already exist so don't clobber it.
+ task.Logf("cannot auto connect %s to %s: (plug auto-connection), existing connection state %q in the way", connRef.PlugRef.String(), connRef.SlotRef.String(), key)
continue
}
if err := m.repo.Connect(connRef); err != nil {
- task.Logf("cannot auto connect %s to %s: %s (plug auto-connection)", connRef.PlugRef, connRef.SlotRef, err)
+ task.Logf("cannot auto connect %s to %s: %s (plug auto-connection)", connRef.PlugRef.String(), connRef.SlotRef.String(), err)
continue
}
affectedSnapNames = append(affectedSnapNames, connRef.PlugRef.Snap)