Skip to content

Commit

Permalink
Always init snapshotter and transaction
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
  • Loading branch information
anmazzotti committed Feb 27, 2024
1 parent eeba163 commit 9feacf3
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions pkg/action/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,24 +240,6 @@ func (u *UpgradeAction) Run() (err error) {
return err
}

// Only upgrade recovery
if u.spec.RecoveryOnlyUpgrade {
u.cfg.Logger.Info("Upgrading Recovery only")
upgradeRecoveryAction := NewUpgradeRecoveryAction(u.cfg, u.spec)
if err := upgradeRecoveryAction.Run(); err != nil {
u.Error("Upgrading Recovery: %s", err)
return elementalError.NewFromError(err, elementalError.UpgradeRecovery)
}
// Update state.yaml file on recovery and state partitions
err = u.upgradeInstallStateYaml()
if err != nil {
u.Error("Failed upgrading installation metadata")
return err
}
// Nothing more to do. Exit.
return nil
}

// Init snapshotter
err = u.snapshotter.InitSnapshotter(u.spec.Partitions.State, u.spec.Partitions.EFI.MountPoint)
if err != nil {
Expand All @@ -282,18 +264,20 @@ func (u *UpgradeAction) Run() (err error) {
cleanup.PushErrorOnly(func() error { return u.snapshotter.CloseTransactionOnError(u.snapshot) })

// Deploy system image
err = elemental.DumpSource(u.cfg.Config, u.snapshot.WorkDir, u.spec.System)
if err != nil {
u.cfg.Logger.Errorf("failed deploying source: %s", u.spec.System.String())
return elementalError.NewFromError(err, elementalError.DumpSource)
}
if !u.spec.RecoveryOnlyUpgrade {
err = elemental.DumpSource(u.cfg.Config, u.snapshot.WorkDir, u.spec.System)
if err != nil {
u.cfg.Logger.Errorf("failed deploying source: %s", u.spec.System.String())
return elementalError.NewFromError(err, elementalError.DumpSource)
}

// Fine tune the dumped tree
u.cfg.Logger.Info("Fine tune the dumped root tree")
err = u.refineDeployment()
if err != nil {
u.cfg.Logger.Error("failed refining system root tree")
return err
// Fine tune the dumped tree
u.cfg.Logger.Info("Fine tune the dumped root tree")
err = u.refineDeployment()
if err != nil {
u.cfg.Logger.Error("failed refining system root tree")
return err
}
}

// Manage legacy recovery. This logic should be removed once toolkit v1.1 gets unsupported.
Expand All @@ -317,7 +301,7 @@ func (u *UpgradeAction) Run() (err error) {
}

// Upgrade recovery
if u.spec.RecoveryUpgrade {
if u.spec.RecoveryUpgrade || u.spec.RecoveryOnlyUpgrade {
recoverySystem := &u.spec.RecoverySystem
u.cfg.Logger.Info("Deploying recovery system")
if recoverySystem.Source.String() == u.spec.System.String() {
Expand Down

0 comments on commit 9feacf3

Please sign in to comment.