Fix overriding err value when getting ingress conf
@@ -241,20 +241,23 @@ func (r *ReconcileAPI) Reconcile(request reconcile.Request) (reconcile.Result, e
userNameSpace := instance.Namespace
//get configurations file for the controller
- controlConf, err := getConfigmap(r, controllerConfName, wso2NameSpaceConst)
+ controlConf, errConf := getConfigmap(r, controllerConfName, wso2NameSpaceConst)
//get configurations file for the controller
- controlIngressConf, err := getConfigmap(r, ingressConfigs, wso2NameSpaceConst)
+ controlIngressConf, errIngressConf := getConfigmap(r, ingressConfigs, wso2NameSpaceConst)
+ confErrs := []error{errConf, errIngressConf}
+ for _, err := range confErrs {
if err != nil {
if errors.IsNotFound(err) {
- // Controller configmap is not found, could have been deleted after reconcile request.
+ // Required configmap is not found, could have been deleted after reconcile request.
// Return and requeue
- log.Error(err, "Controller configuration file is not found")
+ log.Error(err, "Required configmap is not found")
return reconcile.Result{}, err
}
// Error reading the object - requeue the request.
return reconcile.Result{}, err
}
+ }
controlConfigData := controlConf.Data
mgwToolkitImg := controlConfigData[mgwToolkitImgConst]
@@ -1123,15 +1126,15 @@ func getConfigmap(r *ReconcileAPI, mapName string, ns string) (*corev1.ConfigMap
return nil, err
} else if err != nil {
- log.Error(err, "error ")
+ log.Error(err, "error getting APIM configmap", "configmap name", mapName)
return apiConfigMap, err
}
} else {
if err != nil && errors.IsNotFound(err) {
- log.Error(err, "Specified configmap is not found: %s", mapName)
+ log.Error(err, "Specified configmap is not found", "configmap name", mapName)
return apiConfigMap, err
} else if err != nil {
- log.Error(err, "error ")
+ log.Error(err, "error getting configmap", "configmap name", mapName)
return apiConfigMap, err
}
}
