pbacsko commented on code in PR #480:
URL: https://github.com/apache/yunikorn-k8shim/pull/480#discussion_r1023918187


##########
pkg/cache/context.go:
##########
@@ -290,33 +295,79 @@ func (ctx *Context) filterConfigMaps(obj interface{}) 
bool {
 func (ctx *Context) addConfigMaps(obj interface{}) {
        log.Logger().Debug("configMap added")
        configmap := utils.Convert2ConfigMap(obj)
-       ctx.triggerReloadConfig(configmap)
+       switch configmap.Name {
+       case constants.DefaultConfigMapName:
+               ctx.configMaps[0] = configmap
+       case constants.ConfigMapName:
+               ctx.configMaps[1] = configmap
+       default:
+               // ignore
+               return
+       }
+       ctx.triggerReloadConfig()
 }
 
 // when the configMap for the scheduler is updated, trigger hot-refresh
-func (ctx *Context) updateConfigMaps(obj, newObj interface{}) {
+func (ctx *Context) updateConfigMaps(_, newObj interface{}) {
        log.Logger().Debug("configMap updated")
        configmap := utils.Convert2ConfigMap(newObj)
-       ctx.triggerReloadConfig(configmap)
+       switch configmap.Name {
+       case constants.DefaultConfigMapName:
+               ctx.configMaps[0] = configmap
+       case constants.ConfigMapName:
+               ctx.configMaps[1] = configmap
+       default:
+               // ignore
+               return
+       }
+       ctx.triggerReloadConfig()
 }
 
 // when the configMap for the scheduler is deleted, trigger refresh using 
default config
 func (ctx *Context) deleteConfigMaps(obj interface{}) {
        log.Logger().Debug("configMap deleted")
-       ctx.triggerReloadConfig(nil)
-}
+       var configmap *v1.ConfigMap = nil
+       switch t := obj.(type) {
+       case *v1.ConfigMap:
+               configmap = t
+       case cache.DeletedFinalStateUnknown:
+               configmap = utils.Convert2ConfigMap(obj)
+       default:
+               log.Logger().Debug("unable to convert to configmap")

Review Comment:
   I know it's an unlikely code path but I'd use an `Error()` or `Warn()` here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to