Skip to content

Commit

Permalink
Merge pull request #1432 from trimble-oss/add_nil_check
Browse files Browse the repository at this point in the history
Added nil checks
  • Loading branch information
meghan-bailey authored Jan 16, 2025
2 parents 701b6cb + 132990e commit 233fd91
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions pkg/core/util/hive/kernelcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ func (pH *PluginHandler) DynamicReloader(driverConfig *config.DriverConfig) {
valid = true
}
if valid {
for service, servPh := range *pH.Services {
*servPh.ConfigContext.CmdSenderChan <- core.KernelCmd{
PluginName: servPh.Name,
Command: core.PLUGIN_EVENT_STOP,
for s, sPh := range *pH.Services {
if sPh.ConfigContext != nil && *sPh.ConfigContext.CmdSenderChan != nil {
*sPh.ConfigContext.CmdSenderChan <- core.KernelCmd{
PluginName: sPh.Name,
Command: core.PLUGIN_EVENT_STOP,
}
driverConfig.CoreConfig.Log.Printf("Shutting down service: %s\n", s)
} else {
driverConfig.CoreConfig.Log.Printf("Service not properly initialized to shut down for cert reloading: %s\n", s)
goto waitToReload
}
driverConfig.CoreConfig.Log.Printf("Shutting down service: %s\n", service)
}
//TODO: Get rid of os.Exit
// 0. Reload certificates
Expand Down Expand Up @@ -169,15 +174,24 @@ func (pH *PluginHandler) DynamicReloader(driverConfig *config.DriverConfig) {

if new_sha, ok := certifyMap["trcsha256"]; ok && new_sha.(string) != servPh.Signature {
driverConfig.CoreConfig.Log.Printf("Kernel shutdown, installing new service: %s\n", service)
for service, servPh := range *pH.Services {
*servPh.ConfigContext.CmdSenderChan <- core.KernelCmd{
PluginName: servPh.Name,
Command: core.PLUGIN_EVENT_STOP,
for s, sPh := range *pH.Services {
if sPh.ConfigContext != nil && *sPh.ConfigContext.CmdSenderChan != nil {
*sPh.ConfigContext.CmdSenderChan <- core.KernelCmd{
PluginName: sPh.Name,
Command: core.PLUGIN_EVENT_STOP,
}
driverConfig.CoreConfig.Log.Printf("Shutting down service: %s\n", s)
} else {
driverConfig.CoreConfig.Log.Printf("Service not properly initialized to shut down: %s\n", s)
goto waitToReload
}
driverConfig.CoreConfig.Log.Printf("Shutting down service: %s\n", service)
}

if t, ok := certifyMap["trctype"]; ok && t.(string) == "trcshkubeservice" {
if servPh.ConfigContext == nil || *servPh.ConfigContext.CmdSenderChan == nil {
driverConfig.CoreConfig.Log.Printf("Kube service not properly initialized to shut down: %s\n", service)
goto waitToReload
}
driverConfig.CoreConfig.Log.Printf("Shutting down service: %s\n", service)
*servPh.ConfigContext.CmdSenderChan <- core.KernelCmd{
PluginName: servPh.Name,
Expand All @@ -204,6 +218,7 @@ func (pH *PluginHandler) DynamicReloader(driverConfig *config.DriverConfig) {
}
}
}
waitToReload:
time.Sleep(time.Minute)
}
}
Expand Down

0 comments on commit 233fd91

Please sign in to comment.