From 366ca43e3149db942207e6e81a0b17fe61f80f0c Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki Date: Tue, 3 Jul 2018 17:46:55 +0200 Subject: [PATCH] overlord/ifacestate: remove core-support-plug on startup 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 --- overlord/ifacestate/helpers.go | 13 +++++++++++++ overlord/ifacestate/ifacestate_test.go | 14 ++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/overlord/ifacestate/helpers.go b/overlord/ifacestate/helpers.go index 4c0f97104cf..b7ebea6f9f2 100644 --- a/overlord/ifacestate/helpers.go +++ b/overlord/ifacestate/helpers.go @@ -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 } @@ -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. diff --git a/overlord/ifacestate/ifacestate_test.go b/overlord/ifacestate/ifacestate_test.go index dd485ed9cc9..68a1c9e7708 100644 --- a/overlord/ifacestate/ifacestate_test.go +++ b/overlord/ifacestate/ifacestate_test.go @@ -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: @@ -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) {