Skip to content

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Aug 28, 2025

Summary

Implements Phase 1 of the action plan for Issue #89: Metadata Output Getting Truncated. Adds configurable annotation filtering to the list_resources tool to prevent truncation issues with large annotations, particularly GPU node annotations.

Changes

New Parameters for list_resources

  • include_annotations (boolean): Whether to include annotations in output (default: true)
  • exclude_annotation_keys (array): List of annotation keys to exclude with wildcard support (e.g., nvidia.com/*)
  • include_annotation_keys (array): List of annotation keys to include exclusively
  • label_selector: Added missing parameter to tool schema

Implementation Details

  • filterAnnotations(): Core filtering function with include/exclude logic
  • matchesPattern(): Wildcard pattern matching for flexible annotation filtering
  • Backward Compatible: Default behavior excludes kubectl.kubernetes.io/last-applied-configuration
  • Include Precedence: When include_annotation_keys is specified, it takes precedence over exclude logic

Testing

  • Comprehensive unit tests covering all filtering scenarios
  • Integration tests with real Kubernetes cluster
  • All existing tests continue to pass
  • Build verification successful

Usage Examples

Exclude GPU annotations to prevent truncation:

{
  "resource_type": "clustered",
  "group": "", "version": "v1", "resource": "nodes",
  "exclude_annotation_keys": ["nvidia.com/*", "kubectl.kubernetes.io/last-applied-configuration"]
}

Include only specific annotations:

{
  "resource_type": "namespaced",
  "group": "", "version": "v1", "resource": "pods", "namespace": "default",
  "include_annotation_keys": ["app", "version"]
}

Disable annotations completely:

{
  "resource_type": "namespaced",
  "group": "", "version": "v1", "resource": "pods", "namespace": "default",
  "include_annotations": false
}

Benefits

  • Solves GPU Annotation Truncation: Users can exclude large NVIDIA annotations
  • Flexible Control: Complete user control over annotation inclusion/exclusion
  • Performance Optimization: Smaller responses when annotations are filtered
  • Backward Compatible: No breaking changes, existing integrations work unchanged
  • Wildcard Support: Easy filtering of entire annotation namespaces

Documentation

  • Updated README.md with comprehensive documentation
  • Added detailed examples for all filtering scenarios
  • Documented annotation filtering rules and behavior

Fixes #89

- Add include_annotations parameter to control annotation inclusion (default: true)
- Add exclude_annotation_keys parameter with wildcard support (e.g., nvidia.com/*)
- Add include_annotation_keys parameter for exclusive annotation inclusion
- Implement filterAnnotations function with pattern matching
- Default excludes kubectl.kubernetes.io/last-applied-configuration
- Add comprehensive unit tests for all filtering scenarios
- Update README.md with detailed documentation and examples

Resolves issue with metadata output truncation in large clusters,
particularly those with GPU nodes containing extensive NVIDIA annotations.

Fixes #89

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
@JAORMX JAORMX force-pushed the feat/annotation-filtering branch from b92bb8b to 0ee22da Compare August 28, 2025 12:14
@JAORMX JAORMX merged commit 806e3d8 into main Aug 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata Output getting truncated

3 participants