-
Notifications
You must be signed in to change notification settings - Fork 51
Description
What happened
: The k8sClusterRecommendNode
API endpoint is returning empty arrays for all tested cloud service providers (Azure koreacentral, AWS ap-northeast-2, GCP asia-east1). Through debugging analysis, we discovered that the RecommendK8sNode
function in /src/core/infra/recommendation.go
contains incorrect filtering logic that searches for InfraType values containing "k8s"
or "kubernetes"
, but the returned specifications all have InfraType = "vm"
, resulting in empty recommendation results despite VM specs being perfectly suitable for Kubernetes node deployment.
What you expected to happen
: The k8sClusterRecommendNode
API should return appropriate K8s node specifications when valid cloud provider and region combinations are provided, instead of returning empty arrays.
How to reproduce it (as minimally and precisely as possible)
: API Test Command
curl -X 'POST' \
'http://localhost:1323/tumblebug/k8sClusterRecommendNode' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"filter": {
"policy": [
{
"condition": [
{"operand": "18", "operator": ">="},
{"operand": "0", "operator": "<="}
],
"metric": "vCPU"
},
{
"condition": [
{"operand": "128", "operator": ">="},
{"operand": "0", "operator": "<="}
],
"metric": "memoryGiB"
},
{
"condition": [{"operand": "azure"}],
"metric": "providerName"
},
{
"condition": [{"operand": "koreacentral"}],
"metric": "regionName"
}
]
}
}'
Anything else we need to know?
: Technical Analysis
- Location:
/src/core/infra/recommendation.go
, lines 1244-1246 - Current filtering logic:
strings.Contains(SpecInfo.InfraType, model.StrK8s) || strings.Contains(SpecInfo.InfraType, model.StrKubernetes)
- Database reality: All specs have
InfraType = "VM"
- Debug verification: Added
log.Info().Msg(SpecInfo.InfraType)
at line 1243 confirms all specs are "VM"
Environment
- cb-tumblebug version: v0.11.13
- Platform: Docker Compose deployment
- Testing method: REST API calls with basic authentication
Proposed solution
// Current problematic code (lines 1244-1246):
if strings.Contains(SpecInfo.InfraType, model.StrK8s) ||
strings.Contains(SpecInfo.InfraType, model.StrKubernetes) {
// Suggested fix:
if strings.Contains(strings.ToLower(SpecInfo.InfraType), "k8s") ||
strings.Contains(strings.ToLower(SpecInfo.InfraType), "kubernetes") ||
strings.Contains(strings.ToLower(SpecInfo.InfraType), "vm") {
Any other context
- Compatibility Verification Needed: Before implementing this fix, we should verify that VM specifications can successfully create K8s clusters without issues. The current filtering assumes VM specs are suitable for K8s nodes, but this needs validation across different cloud providers.
- Future InfraType Classification: This is a temporary fix. In the future, when dedicated K8s specifications or container-optimized specs become available, they should be properly classified with
InfraType = "k8s"
,"kubernetes"
, or"container"
to enable more precise filtering.