Ubuntu Pastebin

Paste from zyga at Tue, 11 Apr 2017 10:36:16 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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)
Download as text