Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

o/snapstate, features, tests: remove snapd-snap experimental feature #14531

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const (
ParallelInstances
// Hotplug controls availability of dynamically creating slots based on system hardware.
Hotplug
// SnapdSnap controls possibility of installing the snapd snap.
SnapdSnap
// PerUserMountNamespace controls the persistence of per-user mount namespaces.
PerUserMountNamespace
// RefreshAppAwareness controls refresh being aware of running applications.
Expand Down Expand Up @@ -101,7 +99,6 @@ var featureNames = map[SnapdFeature]string{
Layouts: "layouts",
ParallelInstances: "parallel-instances",
Hotplug: "hotplug",
SnapdSnap: "snapd-snap",
PerUserMountNamespace: "per-user-mount-namespace",
RefreshAppAwareness: "refresh-app-awareness",

Expand Down
4 changes: 0 additions & 4 deletions features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (*featureSuite) TestName(c *C) {
check(features.Layouts, "layouts")
check(features.ParallelInstances, "parallel-instances")
check(features.Hotplug, "hotplug")
check(features.SnapdSnap, "snapd-snap")
check(features.PerUserMountNamespace, "per-user-mount-namespace")
check(features.RefreshAppAwareness, "refresh-app-awareness")
check(features.ClassicPreservesXdgRuntimeDir, "classic-preserves-xdg-runtime-dir")
Expand Down Expand Up @@ -88,8 +87,6 @@ func (*featureSuite) TestIsExported(c *C) {

check(features.Layouts, false)
check(features.Hotplug, false)
check(features.SnapdSnap, false)

check(features.ParallelInstances, true)
check(features.PerUserMountNamespace, true)
check(features.RefreshAppAwareness, true)
Expand Down Expand Up @@ -216,7 +213,6 @@ func (*featureSuite) TestIsEnabledWhenUnset(c *C) {
check(features.Layouts, true)
check(features.ParallelInstances, false)
check(features.Hotplug, false)
check(features.SnapdSnap, false)
check(features.PerUserMountNamespace, false)
check(features.RefreshAppAwareness, true)
check(features.ClassicPreservesXdgRuntimeDir, true)
Expand Down
108 changes: 0 additions & 108 deletions overlord/snapstate/snapmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package snapstate

import (
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -1169,112 +1168,6 @@ func changeInFlight(st *state.State) bool {
return false
}

// ensureSnapdSnapTransition will migrate systems to use the "snapd" snap
func (m *SnapManager) ensureSnapdSnapTransition() error {
m.state.Lock()
defer m.state.Unlock()

// we only auto-transition people on classic systems, for core we
// will need to do a proper re-model
if !release.OnClassic {
return nil
}

// Wait for the system to be seeded before transtioning
var seeded bool
err := m.state.Get("seeded", &seeded)
if err != nil {
if !errors.Is(err, state.ErrNoState) {
// already seeded or other error
return err
}
return nil
}
if !seeded {
return nil
}

// check if snapd snap is installed
var snapst SnapState
err = Get(m.state, "snapd", &snapst)
if err != nil && !errors.Is(err, state.ErrNoState) {
return err
}
// nothing to do
if snapst.IsInstalled() {
return nil
}

// check if the user opts into the snapd snap
optedIntoSnapdTransition, err := optedIntoSnapdSnap(m.state)
if err != nil {
return err
}
// nothing to do: the user does not want the snapd snap yet
if !optedIntoSnapdTransition {
return nil
}

// ensure we only transition systems that have snaps already
installedSnaps, err := NumSnaps(m.state)
if err != nil {
return err
}
// no installed snaps (yet): do nothing (fresh classic install)
if installedSnaps == 0 {
return nil
}

// get current core snap and use same channel/user for the snapd snap
err = Get(m.state, "core", &snapst)
// Note that state.ErrNoState should never happen in practice. However
// if it *does* happen we still want to fix those systems by installing
// the snapd snap.
if err != nil && !errors.Is(err, state.ErrNoState) {
return err
}
coreChannel := snapst.TrackingChannel
// snapd/core are never blocked on auth so we don't need to copy
// the userID from the snapst here
userID := 0

if changeInFlight(m.state) {
// check that there is no change in flight already, this is a
// precaution to ensure the snapd transition is safe
return nil
}

// ensure we limit the retries in case something goes wrong
var lastSnapdTransitionAttempt time.Time
err = m.state.Get("snapd-transition-last-retry-time", &lastSnapdTransitionAttempt)
if err != nil && !errors.Is(err, state.ErrNoState) {
return err
}
now := time.Now()
if !lastSnapdTransitionAttempt.IsZero() && lastSnapdTransitionAttempt.Add(snapdTransitionDelayWithRandomness).After(now) {
return nil
}
m.state.Set("snapd-transition-last-retry-time", now)

var retryCount int
err = m.state.Get("snapd-transition-retry", &retryCount)
if err != nil && !errors.Is(err, state.ErrNoState) {
return err
}
m.state.Set("snapd-transition-retry", retryCount+1)

ts, err := Install(context.Background(), m.state, "snapd", &RevisionOptions{Channel: coreChannel}, userID, Flags{})
if err != nil {
return err
}

msg := i18n.G("Transition to the snapd snap")
chg := m.state.NewChange("transition-to-snapd-snap", msg)
chg.AddAll(ts)

return nil
}

// ensureUbuntuCoreTransition will migrate systems that use "ubuntu-core"
// to the new "core" snap
func (m *SnapManager) ensureUbuntuCoreTransition() error {
Expand Down Expand Up @@ -1593,7 +1486,6 @@ func (m *SnapManager) Ensure() error {
m.ensureAliasesV2(),
m.ensureForceDevmodeDropsDevmodeFromState(),
m.ensureUbuntuCoreTransition(),
m.ensureSnapdSnapTransition(),
// we should check for full regular refreshes before
// considering issuing a hint only refresh request
m.autoRefresh.Ensure(),
Expand Down
9 changes: 0 additions & 9 deletions overlord/snapstate/snapstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,6 @@ func isParallelInstallable(snapsup *SnapSetup) error {
return fmt.Errorf("cannot install snap of type %v as %q", snapsup.Type, snapsup.InstanceName())
}

func optedIntoSnapdSnap(st *state.State) (bool, error) {
tr := config.NewTransaction(st)
experimentalAllowSnapd, err := features.Flag(tr, features.SnapdSnap)
if err != nil && !config.IsNoOption(err) {
return false, err
}
return experimentalAllowSnapd, nil
}

// refreshRetain returns refresh.retain value if set, or the default value (different for core and classic).
// It deals with potentially wrong type due to lax validation.
func refreshRetain(st *state.State) int {
Expand Down
Loading
Loading