-
Notifications
You must be signed in to change notification settings - Fork 413
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
Bug 1861026: daemon: perform other rpm-ostree operations after OS rebase #2029
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,13 +109,42 @@ func getNodeRef(node *corev1.Node) *corev1.ObjectReference { | |
} | ||
} | ||
|
||
// updateOSAndReboot is the last step in an update(), and it can also | ||
// be called as a special case for the "bootstrap pivot". | ||
func (dn *Daemon) updateOSAndReboot(newConfig *mcfgv1.MachineConfig) (retErr error) { | ||
// Remove pending deployment on OSTree based system | ||
func removePendingDeployment() error { | ||
_, err := runGetOut("rpm-ostree", "cleanup", "-p") | ||
return err | ||
} | ||
|
||
func (dn *Daemon) applyOSChanges(oldConfig, newConfig *mcfgv1.MachineConfig) (retErr error) { | ||
if err := dn.updateOS(newConfig); err != nil { | ||
return err | ||
} | ||
return dn.finalizeAndReboot(newConfig) | ||
|
||
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 { | ||
glog.Infof("Rolling back applied changes to OS") | ||
if err := removePendingDeployment(); err != nil { | ||
retErr = errors.Wrapf(retErr, "error removing staged deployment: %v", err) | ||
return | ||
} | ||
} | ||
}() | ||
|
||
// kargs | ||
if err := dn.updateKernelArguments(oldConfig, newConfig); err != nil { | ||
return err | ||
} | ||
|
||
// Switch to real time kernel | ||
if err := dn.switchKernel(oldConfig, newConfig); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (dn *Daemon) finalizeAndReboot(newConfig *mcfgv1.MachineConfig) (retErr error) { | ||
|
@@ -353,34 +382,20 @@ func (dn *Daemon) update(oldConfig, newConfig *mcfgv1.MachineConfig) (retErr err | |
} | ||
}() | ||
|
||
// kargs | ||
if err := dn.updateKernelArguments(oldConfig, newConfig); err != nil { | ||
return err | ||
} | ||
defer func() { | ||
if retErr != nil { | ||
if err := dn.updateKernelArguments(newConfig, oldConfig); err != nil { | ||
retErr = errors.Wrapf(retErr, "error rolling back kernel arguments %v", err) | ||
return | ||
} | ||
} | ||
}() | ||
|
||
// Switch to real time kernel | ||
if err := dn.switchKernel(oldConfig, newConfig); err != nil { | ||
if err := dn.applyOSChanges(oldConfig, newConfig); err != nil { | ||
return err | ||
} | ||
|
||
defer func() { | ||
if retErr != nil { | ||
if err := dn.switchKernel(newConfig, oldConfig); err != nil { | ||
retErr = errors.Wrapf(retErr, "error rolling back Real time Kernel %v", err) | ||
if err := dn.applyOSChanges(newConfig, oldConfig); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not strictly related to this change but we're now grouping the "defer rollback" of the kargs/kernel type switch - I was going to comment about how this might cause us to incorrectly roll kargs back if we failed at the kernel type switch but then I realized: The only defer rollback we need is the (I think that defer will run last and hence win, so this code is fine as is) |
||
retErr = errors.Wrapf(retErr, "error rolling back changes to OS %v", err) | ||
return | ||
} | ||
} | ||
}() | ||
|
||
return dn.updateOSAndReboot(newConfig) | ||
return dn.finalizeAndReboot(newConfig) | ||
} | ||
|
||
// MachineConfigDiff represents an ad-hoc difference between two MachineConfig objects. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Unclear as to if this means now or previously. Currently would indicate it's in use now while communicated would indicate the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was noted this is a direct pull in from https://github.com/openshift/machine-config-operator/pull/1809/files#r442404093