Skip to content

Commit

Permalink
Merge pull request #3599 from cgwalters/always-reset-pending
Browse files Browse the repository at this point in the history
OCPBUGS-9685: daemon: Always remove pending deployment before we do updates
  • Loading branch information
sdodson authored Mar 9, 2023
2 parents 7b3939c + 112277e commit 539a2b1
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,28 @@ func (dn *CoreOSDaemon) applyLayeredOSChanges(mcDiff machineConfigDiff, oldConfi
defer os.Remove(extensionsRepo)
}

// Always clean up pending, because the RT kernel switch logic below operates on booted,
// not pending.
if err := removePendingDeployment(); err != nil {
return fmt.Errorf("failed to remove pending deployment: %w", err)
}

defer func() {
// Operations performed by rpm-ostree on the booted system are available
// as staged deployment. It gets applied only when we reboot the system.
// In case of an error during any rpm-ostree transaction, removing pending deployment
// should be sufficient to discard any applied changes.
if retErr != nil {
// Print out the error now so that if we fail to cleanup -p, we don't lose it.
glog.Infof("Rolling back applied changes to OS due to error: %v", retErr)
if err := removePendingDeployment(); err != nil {
errs := kubeErrs.NewAggregate([]error{err, retErr})
retErr = fmt.Errorf("error removing staged deployment: %w", errs)
return
}
}
}()

// If we have an OS update *or* a kernel type change, then we must undo the RT kernel
// enablement.
if mcDiff.osUpdate || mcDiff.kernelType {
Expand Down Expand Up @@ -2148,22 +2170,6 @@ func (dn *CoreOSDaemon) applyLayeredOSChanges(mcDiff machineConfigDiff, oldConfi
// if we're here, we've successfully pivoted, or pivoting wasn't necessary, so we reset the error gauge
mcdPivotErr.Set(0)

defer func() {
// Operations performed by rpm-ostree on the booted system are available
// as staged deployment. It gets applied only when we reboot the system.
// In case of an error during any rpm-ostree transaction, removing pending deployment
// should be sufficient to discard any applied changes.
if retErr != nil {
// Print out the error now so that if we fail to cleanup -p, we don't lose it.
glog.Infof("Rolling back applied changes to OS due to error: %v", retErr)
if err := removePendingDeployment(); err != nil {
errs := kubeErrs.NewAggregate([]error{err, retErr})
retErr = fmt.Errorf("error removing staged deployment: %w", errs)
return
}
}
}()

if mcDiff.kargs {
if err := dn.updateKernelArguments(oldConfig.Spec.KernelArguments, newConfig.Spec.KernelArguments); err != nil {
return err
Expand Down

0 comments on commit 539a2b1

Please sign in to comment.