overlord/ifacestate: fix auto-connect during core snap transition #3145

Closed
wants to merge 13 commits into
from

overlord/ifacestate: auto-connect core-support to core-support-plug

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information...
commit 71ce65eb95b3210515a8c81f4737e5c3d9bd18fb @zyga zyga committed Apr 6, 2017
@@ -105,15 +105,19 @@ func (m *InterfaceManager) addSnaps() error {
// network-bind slot (on core). This cures the effects of bug
// https://bugs.launchpad.net/snappy/+bug/1680097
@niemeyer

niemeyer Apr 6, 2017

Contributor

Kudos for the good comment and function name.

func (m *InterfaceManager) fixDisconnectedCorePlugs() error {
@pedronis

pedronis Apr 10, 2017

Contributor

do I understand correctly that either this will do something or #3154, the latter will do something only if there are connections but with the old names?

@pedronis

pedronis Apr 10, 2017

Contributor

after thinking with @mvo it seems we should not need this but only the bit in autoConnect, at some point we will run autoConnect with new core on the new core before trying to run the hook

- // If the core snap has network-bind-plug
- if m.repo.Plug("core", "network-bind-plug") != nil {
- // connect it to the slot (connect is a no-op if connected)
- connRef := interfaces.ConnRef{
- PlugRef: interfaces.PlugRef{Snap: "core", Name: "network-bind-plug"},
- SlotRef: interfaces.SlotRef{Snap: "core", Name: "network-bind"},
- }
- if err := m.repo.Connect(connRef); err != nil {
- logger.Noticef("%s", err)
+ const coreName = "core"
+ for _, slotName := range []string{"network-bind", "core-support"} {
@pedronis

pedronis Apr 10, 2017

Contributor

so we found out (and understood) that this is an issue only for network-bind

+ plugName := fmt.Sprintf("%s-plug", slotName)
@mvo5

mvo5 Apr 7, 2017

Collaborator

Pardon my ignorance - this means we need to modify the core snap to have a new {network-bind,core-support}-plug name, correct?

@zyga

zyga Apr 7, 2017

Contributor

Yes, that's correct

@mvo5

mvo5 Apr 10, 2017

Collaborator

AIUI landing the core snap change is not mandatory for this so we should (IMO) leave it for now.

@mvo5

mvo5 Apr 10, 2017

Collaborator

The core snap change has landed in any case.

+ // If the core snap has the plug
+ if m.repo.Plug(coreName, plugName) != nil {
+ // connect it to the slot (connect is a no-op if connected)
+ connRef := interfaces.ConnRef{
+ PlugRef: interfaces.PlugRef{Snap: coreName, Name: plugName},
+ SlotRef: interfaces.SlotRef{Snap: coreName, Name: slotName},
+ }
+ if err := m.repo.Connect(connRef); err != nil {
+ logger.Noticef("%s", err)
+ }
}
}
return nil
@@ -1893,15 +1893,26 @@ func (s *interfaceManagerSuite) TestManagerFixesNetworkBindConnectionOnInit(c *C
plugs:
network-bind-plug:
interface: network-bind
+ core-support-plug:
+ interface: core-support
slots:
network-bind:
+ core-support:
`)
mgr := s.manager(c)
+ // Check that network-bind and core-support are connected to their -plugs
connRefs, err := mgr.Repository().Connected("core", "network-bind")
c.Assert(err, IsNil)
c.Assert(connRefs, HasLen, 1)
c.Assert(connRefs, DeepEquals, []interfaces.ConnRef{{
PlugRef: interfaces.PlugRef{Snap: "core", Name: "network-bind-plug"},
SlotRef: interfaces.SlotRef{Snap: "core", Name: "network-bind"},
}})
+ connRefs, err = mgr.Repository().Connected("core", "core-support")
+ c.Assert(err, IsNil)
+ c.Assert(connRefs, HasLen, 1)
+ c.Assert(connRefs, DeepEquals, []interfaces.ConnRef{{
+ PlugRef: interfaces.PlugRef{Snap: "core", Name: "core-support-plug"},
+ SlotRef: interfaces.SlotRef{Snap: "core", Name: "core-support"},
+ }})
}