Skip to content

Commit

Permalink
overlord/ifacestate: remove core-support-plug on startup
Browse files Browse the repository at this point in the history
This patch ensures that the "core" snap doesn't have the
core-support-plug even if one was defined statically in snap.yaml.

This is just a test of the upcoming real removal.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Jul 3, 2018
1 parent 39f348e commit 366ca43
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 13 additions & 0 deletions overlord/ifacestate/helpers.go
Expand Up @@ -51,6 +51,9 @@ func (m *InterfaceManager) initialize(extraInterfaces []interfaces.Interface, ex
if err := m.renameCorePlugConnection(); err != nil {
return err
}
if err := m.removeCoreSupportPlug(); err != nil {
return err
}
if err := removeStaleConnections(m.state); err != nil {
return err
}
Expand Down Expand Up @@ -198,6 +201,16 @@ func (m *InterfaceManager) renameCorePlugConnection() error {
return nil
}

// removeCoreSupportPlug removes the "core-support-plug" from the core snap.
// This is done in anticipation of https://github.com/snapcore/core/pull/92
func (m *InterfaceManager) removeCoreSupportPlug() error {
var err error
if m.repo.Plug("core", "core-support-plug") != nil {
err = m.repo.RemovePlug("core", "core-support-plug")
}
return err
}

// removeStaleConnections removes stale connections left by some older versions of snapd.
// Connection is considered stale if the snap on either end of the connection doesn't exist anymore.
// XXX: this code should eventually go away.
Expand Down
14 changes: 8 additions & 6 deletions overlord/ifacestate/ifacestate_test.go
Expand Up @@ -2426,7 +2426,8 @@ func (s *interfaceManagerSuite) TestCoreConnectionsRenamed(c *C) {

// Test that "network-bind" and "core-support" plugs are renamed to
// "network-bind-plug" and "core-support-plug" in order not to clash with slots
// with the same names.
// with the same names. This test also shows how core-support-plug is removed
// after being renamed.
func (s *interfaceManagerSuite) TestAutomaticCorePlugsRenamed(c *C) {
s.mockSnap(c, coreSnapYaml+`
plugs:
Expand All @@ -2438,12 +2439,13 @@ plugs:
// old plugs are gone
c.Assert(mgr.Repository().Plug("core", "network-bind"), IsNil)
c.Assert(mgr.Repository().Plug("core", "core-support"), IsNil)
// new plugs are present
c.Assert(mgr.Repository().Plug("core", "network-bind-plug"), Not(IsNil))
c.Assert(mgr.Repository().Plug("core", "core-support-plug"), Not(IsNil))
// new plugs are present (well, one of them)
c.Assert(mgr.Repository().Plug("core", "network-bind-plug"), NotNil)
// The core support plug is now removed from core.
c.Assert(mgr.Repository().Plug("core", "core-support-plug"), IsNil)
// slots are present and unchanged
c.Assert(mgr.Repository().Slot("core", "network-bind"), Not(IsNil))
c.Assert(mgr.Repository().Slot("core", "core-support"), Not(IsNil))
c.Assert(mgr.Repository().Slot("core", "network-bind"), NotNil)
c.Assert(mgr.Repository().Slot("core", "core-support"), NotNil)
}

func (s *interfaceManagerSuite) TestAutoConnectDuringCoreTransition(c *C) {
Expand Down

0 comments on commit 366ca43

Please sign in to comment.