-
Notifications
You must be signed in to change notification settings - Fork 114
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
Clean Systemd files on exit #792
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 |
---|---|---|
|
@@ -77,7 +77,7 @@ type Daemon struct { | |
|
||
refreshCh chan<- Message | ||
|
||
mu *sync.Mutex | ||
mu sync.Mutex | ||
|
||
disableDrain bool | ||
|
||
|
@@ -120,7 +120,6 @@ func New( | |
eventRecorder: er, | ||
featureGate: featureGates, | ||
disabledPlugins: disabledPlugins, | ||
mu: &sync.Mutex{}, | ||
} | ||
} | ||
|
||
|
@@ -207,6 +206,20 @@ func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error { | |
for { | ||
select { | ||
case <-stopCh: | ||
// clean files from host if we are running in systemd mode and the node | ||
// is not required to be rebooted | ||
dn.mu.Lock() | ||
rebootrequired := utils.ObjectHasAnnotation(dn.desiredNodeState, | ||
consts.NodeStateDrainAnnotation, consts.RebootRequired) | ||
dn.mu.Unlock() | ||
|
||
if vars.UsingSystemdMode && !rebootrequired { | ||
err := systemd.CleanSriovFilesFromHost(vars.ClusterType == consts.ClusterTypeOpenshift) | ||
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. IIUC when the daemon is stopped we delete systemd files. if the node reboots (given pods get stop signal) wont it delete the files ? which in turn mean the node will not have SR-IOV configured on startup ? 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. What you say is correct. We should have a way to identify whether a |
||
if err != nil { | ||
log.Log.Error(err, "failed to remove all the systemd sriov files") | ||
return err | ||
} | ||
} | ||
log.Log.V(0).Info("Run(): stop daemon") | ||
return nil | ||
case err, more := <-exitCh: | ||
|
@@ -316,6 +329,8 @@ func (dn *Daemon) operatorConfigChangeHandler(old, new interface{}) { | |
} | ||
|
||
func (dn *Daemon) nodeStateSyncHandler() error { | ||
dn.mu.Lock() | ||
defer dn.mu.Unlock() | ||
var err error | ||
// Get the latest NodeState | ||
var sriovResult = &systemd.SriovResult{SyncStatus: consts.SyncStatusSucceeded, LastSyncError: ""} | ||
|
@@ -679,8 +694,6 @@ func (dn *Daemon) handleDrain(reqReboot bool) (bool, error) { | |
} | ||
|
||
func (dn *Daemon) restartDevicePluginPod() error { | ||
dn.mu.Lock() | ||
defer dn.mu.Unlock() | ||
log.Log.V(2).Info("restartDevicePluginPod(): try to restart device plugin pod") | ||
|
||
pods, err := dn.kubeClient.CoreV1().Pods(vars.Namespace).List(context.Background(), metav1.ListOptions{ | ||
|
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.
I used the method used here to close channels. But I believe there is a race in general, on exit (once main goes away, or if os.Exit is called) the goroutines are killed off immediately. So the goroutines listening on this channel will never get the chance to run their intended actions.