Fix K8s image misclassification by refining patterns#2206
Merged
cb-github-robot merged 1 commit intocloud-barista:mainfrom Nov 7, 2025
Merged
Fix K8s image misclassification by refining patterns#2206cb-github-robot merged 1 commit intocloud-barista:mainfrom
cb-github-robot merged 1 commit intocloud-barista:mainfrom
Conversation
- Remove overly broad 'container' pattern - Add specific patterns: container-optimized, cos-stable, amazon-eks, bottlerocket-aws-k8s, etc. - Add fallback logic in CheckK8sClusterDynamicReq for CSPs without K8s-optimized images
Member
|
/lgtm |
Member
|
Thanks! |
Member
|
/approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix K8s image misclassification by refining patterns
📋 Table of Contents
Summary
Purpose
Validate K8s image classification accuracy improvement after fixing False Positive issues identified in #2199.
Test Scope
Key Validation Points
Code Changes
1. Pattern Updates (
assets/extractionpatterns.yaml)Removed:
Added:
Modified for specificity:
2. Filtering Logic (
src/core/infra/provisioning.goline 3299-3322)Already implemented (confirmed during testing):
Effect: Ensures service availability for all CSPs while prioritizing K8s-optimized images.
BEFORE Test Results (Original Code)
Key Issues Identified
Statistics Summary (from #2199)
Root Cause:
"container"pattern inextractionpatterns.yamlmatches general OS images that mention container support in their descriptions, causing massive False Positives on GCP and Azure.AFTER Test Results (Modified Code)
Code Changes Applied
1. extractionpatterns.yaml:
"container"pattern (too broad, causes false positives)"cos"to more specific patterns:"cos-stable","cos-cloud"2. provisioning.go:
Validation Results
Statistics (All CSPs)
Command:
Result:
[ { "provider": "aws", "total": 480521, "k8sTrue": 249056 }, { "provider": "azure", "total": 26, "k8sTrue": 0 }, { "provider": "gcp", "total": 10208, "k8sTrue": 3166 }, { "provider": "ncp", "total": 97, "k8sTrue": 0 }, { "provider": "tencent", "total": 100, "k8sTrue": 0 } ]Detailed Validation Tests
1. GCP Ubuntu Images (False Positive Check)
Command:
Result:
{ "total": 2301, "k8sTrue": 0 }Analysis: ✅ All 2,301 Ubuntu images correctly classified as non-K8s (previously were False Positives)
2. Azure Images (False Positive Check)
Command:
Result:
{ "total": 26, "k8sTrue": 0 }Analysis: ✅ All 26 Azure images correctly classified as non-K8s (previously 100% False Positive)
3. GCP Container-Optimized OS (True Positive Check)
Command:
Result:
{ "total": 3114, "k8sTrue": 3114 }Analysis: ✅ All 3,114 Container-Optimized OS images correctly classified as K8s (100% accuracy)
4. K8s Images Distribution by Provider
Command:
Result:
[ { "provider": "aws", "count": 249056 }, { "provider": "gcp", "count": 3166 } ]Analysis: Only AWS and GCP have K8s-dedicated images (Azure/NCP/Tencent correctly show 0)
5. CheckK8sClusterDynamicReq API Validation (AWS)
Purpose: Verify that the recommendation API correctly filters and returns only K8s-optimized images.
Command:
Result:
{ "provider": "aws-ap-northeast-2", "totalImages": 7674, "k8sImages": 7674, "nonK8sImages": 0, "k8sPercentage": 100 }Sample Images:
Sample Result:
{ "cspImageName": "ami-061034b352adc7296", "osDistribution": "amazon-eks-node-al2023-x86_64-nvidia-1.33-v20250715", "isK8s": true } { "cspImageName": "ami-0606151bcdf669b07", "osDistribution": "bottlerocket-aws-k8s-1.26-nvidia-x86_64-v1.34.0-18d04e52", "isK8s": true } { "cspImageName": "ami-0da0c0bdcf63a8292", "osDistribution": "bottlerocket-aws-k8s-1.32-nvidia-x86_64-v1.49.0-713f44ce", "isK8s": true } { "cspImageName": "ami-084ddd4dbf228adb9", "osDistribution": "ubuntu-eks-pro/k8s_1.31/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-20250516", "isK8s": true } { "cspImageName": "ami-0ae59d2e97513de61", "osDistribution": "amazon-eks-node-al2023-arm64-standard-1.33-v20250610", "isK8s": true }Analysis:
Comparison and Conclusion
Results Summary
CSP-wise Comparison
AWS (Maintained Accuracy)
GCP (Dramatically Improved)
Azure (Perfect Fix)
NCP & Tencent (Maintained)
Key Achievements
Conclusion
✅ Pattern update (#2199) successfully achieved all objectives:
Implementation Status: ✅ Complete and validated
Closes #2199