fix: add check to skip controlplaneinfo in case of cloud providers

Signed-off-by: Alessio Greggi <ale_grey_91@hotmail.it>
This commit is contained in:
Alessio Greggi
2023-02-13 17:16:53 +01:00
parent 1d68d1ba67
commit 46ca5036c4
@@ -323,18 +323,9 @@ func (hsh *HostSensorHandler) CollectResources(ctx context.Context) ([]hostsenso
res = append(res, kcData...)
}
// GetControlPlaneInfo
kcData, err = hsh.GetControlPlaneInfo(ctx)
if err != nil {
addInfoToMap(ControlPlaneInfo, infoMap, err)
logger.L().Ctx(ctx).Warning(err.Error())
}
if len(kcData) > 0 {
res = append(res, kcData...)
}
// GetCloudProviderInfo
kcData, err = hsh.GetCloudProviderInfo(ctx)
isCloudProvider := (kcData != nil)
if err != nil {
addInfoToMap(CloudProviderInfo, infoMap, err)
logger.L().Ctx(ctx).Warning(err.Error())
@@ -343,6 +334,18 @@ func (hsh *HostSensorHandler) CollectResources(ctx context.Context) ([]hostsenso
res = append(res, kcData...)
}
// GetControlPlaneInfo
if !isCloudProvider { // we retrieve control plane info only if we are not using a cloud provider
kcData, err = hsh.GetControlPlaneInfo(ctx)
if err != nil {
addInfoToMap(ControlPlaneInfo, infoMap, err)
logger.L().Ctx(ctx).Warning(err.Error())
}
if len(kcData) > 0 {
res = append(res, kcData...)
}
}
// GetCNIInfo
kcData, err = hsh.GetCNIInfo(ctx)
if err != nil {